private void putIfNotUpdate( DbReadTable readTable, DbWriteTable writeTable, TableReference tableRef, List<Entry<Cell, byte[]>> batch, long timestamp, KeyAlreadyExistsException ex) { List<Entry<Cell, Value>> batchValues = Lists.transform(batch, input -> Maps.immutableEntry(input.getKey(), Value.create(input.getValue(), timestamp))); putIfNotUpdate(readTable, writeTable, tableRef, batchValues, ex); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> cellValues) throws KeyAlreadyExistsException { Iterable<List<Entry<Cell, Value>>> batches = IterablePartitioner.partitionByCountAndBytes( cellValues.entries(), config.mutationBatchCount(), config.mutationBatchSizeBytes(), tableRef, getValueSizingFunction()); runReadWrite(tableRef, (readTable, writeTable) -> { for (List<Entry<Cell, Value>> batch : batches) { try { writeTable.put(batch); } catch (KeyAlreadyExistsException e) { putIfNotUpdate(readTable, writeTable, tableRef, batch, e); } } return null; }); }
private void put(TableReference tableRef, Map<Cell, byte[]> values, long timestamp, boolean idempotent) { Iterable<List<Entry<Cell, byte[]>>> batches = IterablePartitioner.partitionByCountAndBytes( values.entrySet(), config.mutationBatchCount(), config.mutationBatchSizeBytes(), tableRef, getByteSizingFunction()); runReadWrite(tableRef, (readTable, writeTable) -> { for (List<Entry<Cell, byte[]>> batch : batches) { try { writeTable.put(batch, timestamp); } catch (KeyAlreadyExistsException e) { if (idempotent) { putIfNotUpdate(readTable, writeTable, tableRef, batch, timestamp, e); } else { throw e; } } } return null; }); }
private void putIfNotUpdate( DbReadTable readTable, DbWriteTable writeTable, TableReference tableRef, List<Entry<Cell, byte[]>> batch, long timestamp, KeyAlreadyExistsException ex) { List<Entry<Cell, Value>> batchValues = Lists.transform(batch, input -> Maps.immutableEntry(input.getKey(), Value.create(input.getValue(), timestamp))); putIfNotUpdate(readTable, writeTable, tableRef, batchValues, ex); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> cellValues) throws KeyAlreadyExistsException { Iterable<List<Entry<Cell, Value>>> batches = IterablePartitioner.partitionByCountAndBytes( cellValues.entries(), config.mutationBatchCount(), config.mutationBatchSizeBytes(), tableRef, getValueSizingFunction()); runReadWrite(tableRef, (readTable, writeTable) -> { for (List<Entry<Cell, Value>> batch : batches) { try { writeTable.put(batch); } catch (KeyAlreadyExistsException e) { putIfNotUpdate(readTable, writeTable, tableRef, batch, e); } } return null; }); }
private void put(TableReference tableRef, Map<Cell, byte[]> values, long timestamp, boolean idempotent) { Iterable<List<Entry<Cell, byte[]>>> batches = IterablePartitioner.partitionByCountAndBytes( values.entrySet(), config.mutationBatchCount(), config.mutationBatchSizeBytes(), tableRef, getByteSizingFunction()); runReadWrite(tableRef, (readTable, writeTable) -> { for (List<Entry<Cell, byte[]>> batch : batches) { try { writeTable.put(batch, timestamp); } catch (KeyAlreadyExistsException e) { if (idempotent) { putIfNotUpdate(readTable, writeTable, tableRef, batch, timestamp, e); } else { throw e; } } } return null; }); }