You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Sindy <si...@gmail.com> on 2011/03/10 11:19:19 UTC
can not delete one family
Hi,
I want to delete one family in the java programe,
Here is my code:
-----------------------------
Configuration conf=HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
if (admin.tableExists(tableName)) {
HTable table = new HTable(conf,tableName);
Delete d=new Delete();
admin.disableTable(tableName);
d.deleteFamily(Bytes.toBytes(family));
table.delete(d);
admin.enableTable(tableName);
System.out.println("delete family ok!");
}
System.out.println("no this table ok!");
}
-----------------------------
But it shows the exception:
Exception in thread "main" java.lang.IllegalArgumentException: Row is null
at org.apache.hadoop.hbase.KeyValue.createByteArray(KeyValue.java:434)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:399)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:368)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:347)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:317)
at org.apache.hadoop.hbase.client.Delete.deleteFamily(Delete.java:169)
at org.apache.hadoop.hbase.client.Delete.deleteFamily(Delete.java:148)
at DBOper.deleteOneFamily(DBOper.java:618)
at MainClass.main(MainClass.java:41)
Could you give me any advices? Thanks
--
Sindy
Re: can not delete one family
Posted by Ted Yu <yu...@gmail.com>.
You need to call the following method of Delete which sets row before
calling table.delete():
public Delete(byte [] row) {
Cheers
On Thu, Mar 10, 2011 at 2:19 AM, Sindy <si...@gmail.com> wrote:
> Hi,
> I want to delete one family in the java programe,
> Here is my code:
> -----------------------------
>
> Configuration conf=HBaseConfiguration.create();
> HBaseAdmin admin = new HBaseAdmin(conf);
>
> if (admin.tableExists(tableName)) {
>
> HTable table = new HTable(conf,tableName);
> Delete d=new Delete();
> admin.disableTable(tableName);
> d.deleteFamily(Bytes.toBytes(family));
> table.delete(d);
> admin.enableTable(tableName);
> System.out.println("delete family ok!");
> }
> System.out.println("no this table ok!");
> }
>
> -----------------------------
> But it shows the exception:
>
> Exception in thread "main" java.lang.IllegalArgumentException: Row is null
> at org.apache.hadoop.hbase.KeyValue.createByteArray(KeyValue.java:434)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:399)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:368)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:347)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:317)
> at org.apache.hadoop.hbase.client.Delete.deleteFamily(Delete.java:169)
> at org.apache.hadoop.hbase.client.Delete.deleteFamily(Delete.java:148)
> at DBOper.deleteOneFamily(DBOper.java:618)
> at MainClass.main(MainClass.java:41)
>
>
> Could you give me any advices? Thanks
>
> --
> Sindy
>
Re: can not delete one family
Posted by Gary Helmling <gh...@gmail.com>.
Sindy,
Are you trying to drop the column family completely from the table?
If so, you'll need to use HBaseAdmin.deleteColumn().
If you're only trying to remove values from the column family, then you will
need to specify a row, as Ted mentions. And the table must be enabled to
handle the delete.
--gh
On Thu, Mar 10, 2011 at 2:19 AM, Sindy <si...@gmail.com> wrote:
> Hi,
> I want to delete one family in the java programe,
> Here is my code:
> -----------------------------
>
> Configuration conf=HBaseConfiguration.create();
> HBaseAdmin admin = new HBaseAdmin(conf);
>
> if (admin.tableExists(tableName)) {
>
> HTable table = new HTable(conf,tableName);
> Delete d=new Delete();
> admin.disableTable(tableName);
> d.deleteFamily(Bytes.toBytes(family));
> table.delete(d);
> admin.enableTable(tableName);
> System.out.println("delete family ok!");
> }
> System.out.println("no this table ok!");
> }
>
> -----------------------------
> But it shows the exception:
>
> Exception in thread "main" java.lang.IllegalArgumentException: Row is null
> at org.apache.hadoop.hbase.KeyValue.createByteArray(KeyValue.java:434)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:399)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:368)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:347)
> at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:317)
> at org.apache.hadoop.hbase.client.Delete.deleteFamily(Delete.java:169)
> at org.apache.hadoop.hbase.client.Delete.deleteFamily(Delete.java:148)
> at DBOper.deleteOneFamily(DBOper.java:618)
> at MainClass.main(MainClass.java:41)
>
>
> Could you give me any advices? Thanks
>
> --
> Sindy
>