WebHosting

Tuesday, January 24, 2012

How to delete a specific row or given rows in hbase using java code

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package witsml131;

import java.io.IOException;
import java.util.ArrayList;
import javax.security.auth.login.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;

/**
 *
 * @author shashwat
 */
public class DeleteFromHbase {

    public static void main(String[] args) throws IOException {

        HTable table = new HTable("well");
        ArrayList<String> rowsToDelete = new ArrayList(); //array with all rows names to delete.
        Delete del = new Delete(Bytes.toBytes("2"));//for single row named 2

        table.delete(del);
      
        //deleting all rows in rowsToDelete in array list rowsToDelete
        for (String rows : rowsToDelete) {
            del = new Delete(Bytes.toBytes(rows));//for single row named 2

            table.delete(del);
        }
        table.close();
    }
}

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS

Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...