SingleColumnValueFilter を使用して、削除したい行のリストを返しています。
SingleColumnValueFilter fileTimestampFilter = new SingleColumnValueFilter(
Bytes.toBytes('a'),
Bytes.toBytes('date'),
CompareFilter.CompareOp.GREATER,
Bytes.toBytes("20140101000000")
);
次に、Delete オブジェクトを作成し、各列を削除します。
Delete delete = new Delete(Bytes.toBytes(rowKey));
delete.deleteColumn(Bytes.toBytes('a'), Bytes.toBytes('date'));
htable.delete(delete);
取得コードは
private List<String> getRecordsToDelete(long maxResultSize)
{
ResultScanner rs = null;
HTableInterface table = null;
List<String> keyList = new ArrayList<String>();
try
{
log.debug("Retrieving records");
HbaseConnection hbaseConnectionConfig = myConfig.getHbaseConnection();
Configuration configuration = getHbaseConfiguration(hbaseConnectionConfig);
table = new HTable(configuration, 'mytable');
FilterList list = new FilterList(FilterList.Operator.MUST_PASS_ALL);
Filter filter = HbaseDao.getFilter();
list.addFilter(filter);
list.addFilter(new PageFilter(maxResultSize));
Scan scan = new Scan();
scan.setFilter(list);
//scan.setMaxResultSize(maxResultSize);
//scan.setCaching(1);
//scan.setCacheBlocks(false);
//log.debug("Scan raw? = " + scan.isRaw());
//scan.setRaw(false);
rs = table.getScanner(scan);
Iterator<Result> iterator = rs.iterator();
while (iterator.hasNext())
{
Result result = iterator.next();
String key = Bytes.toString(result.getRow());
log.debug("**************** f key = " + key); //the same keys are always added here
keyList.add(key);
}
log.debug("Done processing retrieval of records to delete Size = " + keyList.size());
}
catch (Exception ex)
{
log.error("Unable to process retrieval of records.", ex);
}
finally
{
try
{
if (table != null)
{
table.close();
}
if (rs != null)
{
rs.close();
}
}
catch (IOException ioEx)
{
//do nothing
log.error(ioEx);
}
}
return keyList;
}
このタスクはスケジュールされており、再度実行すると同じ行が取得されます。hbase は行を削除するようにマークし、メジャー圧縮後にのみ物理的に削除されることを理解しています。タスクの実行中に hbase シェルを介して行をクエリすると、列は確実に削除されています。このタスクの後続の実行でスキャンが同じ行を返すのはなぜですか?
前もって感謝します!