当行ID相同时,Accumulo删除行项

时间:2015-07-28 15:34:30

标签: java accumulo

我试图找出一种从表中删除特定行的方法,当它与Accumulo中的另外几行具有相同的行ID时。这就是我设置表格的方式:

m0 : property : name -> erp
m0 : property : age -> 23
m0 : purchase : food -> 5.00
m0 : purchase : gas -> 24.00
m0 : purchase : beer -> 15.00

说我想删除表中的气体。我知道我可以使用connection.tableOperations().deleteRows(table, start, stop)但如果我将m0 - 1m0的行ID传递给该函数,它将删除所有这些条目。我可以删除colFam = something和colQual = something的地方吗?我没有在API中看到任何支持这一点的东西,但frankenstein代码也很酷:)

1 个答案:

答案 0 :(得分:2)

Yes it is possible. I was thinking of rows and columns still in a sql mindest. In order to delete a column (which is what I was thinking of) rather than a row. You just write another mutation. For example:

Text rowId = new Text("m0");
Text colFam = new Text("purchase");
Text colQual = new Text("gas");
Mutation mut = new Mutation(rowId);
mut.putDelete(colFam, colQual);

writer = connection.createBatchWriter(tableName, new BatchWriter());
try{
    writer.addMutation(mut);
}catch{
   ...
}

Works perfect :)