Esta página aún no está disponible en su idioma local. Estamos trabajando arduamente para agregar más versiones de idiomas. Gracias por tu apoyo.

On this page

Deleting Data

Updated on 2022-09-14 GMT+08:00

Function

Delete data (a row of data or data sets) using the delete method of a Table instance.

Example Code

The following code snippet belongs to the testDelete method in the HBaseSample class of the com.huawei.bigdata.hbase.examples package.

public void testDelete() {
    LOG.info("Entering testDelete.");

    byte[] rowKey = Bytes.toBytes("012005000201");

    Table table = null;
    try {
      // Instantiate an HTable object.
      table = conn.getTable(tableName);

      // Instantiate a Delete object.
      Delete delete = new Delete(rowKey);

      // Submit a delete request.
      table.delete(delete);

      LOG.info("Delete table successfully.");
    } catch (IOException e) {
      LOG.error("Delete table failed " ,e);
    } finally {
      if (table != null) {
        try {
          // Close the HTable object.
          table.close();
        } catch (IOException e) {
          LOG.error("Close table failed " ,e);
        }
      }
    }
    LOG.info("Exiting testDelete.");
  }     
NOTE:

If secondary index is created in the family of the column where the deleted cell is, the index data is synchronously deleted.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback