use of co.cask.cdap.data2.util.hbase.PutBuilder in project cdap by caskdata.
the class HBaseMessageTable method persist.
@Override
protected void persist(Iterator<RawMessageTableEntry> entries) throws IOException {
List<Put> batchPuts = new ArrayList<>();
while (entries.hasNext()) {
RawMessageTableEntry entry = entries.next();
PutBuilder putBuilder = tableUtil.buildPut(rowKeyDistributor.getDistributedKey(entry.getKey()));
if (entry.getTxPtr() != null) {
putBuilder.add(columnFamily, TX_COL, entry.getTxPtr());
}
if (entry.getPayload() != null) {
putBuilder.add(columnFamily, PAYLOAD_COL, entry.getPayload());
}
batchPuts.add(putBuilder.build());
}
try {
if (!batchPuts.isEmpty()) {
hTable.put(batchPuts);
if (!hTable.isAutoFlush()) {
hTable.flushCommits();
}
}
} catch (IOException e) {
throw exceptionHandler.handle(e);
}
}
Aggregations