[英]HBase - delete columns of rows with range of timestamp without scanning
我想知道是否可以在不掃描整個數據庫的情況下刪除帶有時間戳的某些行的某些列
我的代碼如下:
public static final void deleteBatch(long date, String column, String...ids) throws Exception{
Connection con = null; // connection instance
HTable table = null; // htable instance
List<Delete> deletes = new ArrayList<Delete>(ids.length);
for(int i = 0; i < ids.length; i++){
String id = ids[i];
Delete delete = new Delete(id.getBytes());
delete.addColumn(/* CF */, Bytes.toString(column));
/*
also tried:
delete.addColumn(/* CF */, Bytes.toString(column), date);
*/
delete.setTimestamp(date);
deletes.add(delete);
}
table.delete(deletes);
table.close();
}
這可行,但會刪除給定日期之前的所有列,我想要這樣的東西:
Delete delete = new Delete(id.getBytes());
delete.setTimestamp(date-1, date);
我不想在特定日期之前或之后刪除,我想刪除我給出的確切時間范圍。 此外,我的 HTableDescriptor 的 MaxVersion 設置為 Integer.MAX_VALUE 以保留所有更改。
如刪除 API 文檔中所述:
指定時間戳,deleteFamily 和 deleteColumns 將刪除所有時間戳小於或等於傳遞的版本
它刪除其時間戳等於或小於給定日期的所有列。
我怎樣才能做到這一點?
任何答案表示贊賞
經過幾周的努力,我找到了解決這個問題的方法。
apache HBase具有稱為 協處理器的功能,它托管和管理數據級操作(獲取、刪除、放置...)的核心執行,並且可以覆蓋(開發)自定義計算,如數據聚合和批量處理外部數據客戶 scope。
對於批量刪除等常見問題有一些基本實現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.