static WriteInfo tombstone(TableReference tableRef, Cell cell, long timestamp) { return WriteInfo.of(WriteReference.of(tableRef, cell, true), timestamp); }
public static WriteInfo toWriteInfo(TableReference tableRef, Map.Entry<Cell, byte[]> write, long timestamp) { Cell cell = write.getKey(); boolean isTombstone = Arrays.equals(write.getValue(), PtBytes.EMPTY_BYTE_ARRAY); return WriteInfo.of(WriteReference.of(tableRef, cell, isTombstone), timestamp); }
static WriteInfo write(TableReference tableRef, Cell cell, long timestamp) { return WriteInfo.of(WriteReference.of(tableRef, cell, false), timestamp); } }
private WriteInfo getWriteInfo(long timestamp, Value value) { return WriteInfo.of( writeReferencePersister.unpersist(SweepableCellsColumnValue.hydrateValue(value.getContents())), timestamp); }
private int write(SweepQueueTable writer, long ts, Cell cell, boolean isTombstone, TableReference tableRef) { WriteInfo write = WriteInfo.of(WriteReference.of(tableRef, cell, isTombstone), ts); writer.enqueue(ImmutableList.of(write)); return write.toShard(numShards); }
@Test public void writesAddedToSweepQueueAndKvsOnPreCommitConditionFailure() { long startTs = putWriteAndFailOnPreCommitConditionReturningStartTimestamp(SINGLE_WRITE); assertThat(getEnqueuedWritesNumber(1)).containsExactly(WriteInfo.of(SINGLE_WRITE, startTs)); verify(sweepQueue, times(1)).enqueue(anyList()); assertLatestEntryForCellInKvsAtTimestamp(TABLE_CONS, TEST_CELL, startTs); }
@Test public void committedWritesAreAddedToSweepQueue() { List<WriteReference> table1Writes = ImmutableList.of( WriteReference.write(TABLE_CONS, Cell.create("a".getBytes(), "b".getBytes())), WriteReference.write(TABLE_CONS, Cell.create("a".getBytes(), "c".getBytes())), WriteReference.tombstone(TABLE_CONS, Cell.create("a".getBytes(), "d".getBytes())), WriteReference.write(TABLE_CONS, Cell.create("b".getBytes(), "d".getBytes()))); List<WriteReference> table2Writes = ImmutableList.of( WriteReference.write(TABLE_THOR, Cell.create("w".getBytes(), "x".getBytes())), WriteReference.write(TABLE_THOR, Cell.create("y".getBytes(), "z".getBytes())), WriteReference.tombstone(TABLE_THOR, Cell.create("z".getBytes(), "z".getBytes()))); long startTimestamp = txManager.runTaskWithRetry(txn -> { table1Writes.forEach(write -> put(txn, write)); table2Writes.forEach(write -> put(txn, write)); return txn.getTimestamp(); }); List<WriteInfo> expectedWrites = Stream.concat(table1Writes.stream(), table2Writes.stream()) .map(writeRef -> WriteInfo.of(writeRef, startTimestamp)) .collect(Collectors.toList()); assertThat(getEnqueuedWritesNumber(1)).hasSameElementsAs(expectedWrites); verify(sweepQueue, times(1)).enqueue(anyList()); }
@Test public void writesAddedToSweepQueueOnNoConflict() { WriteReference firstWrite = WriteReference.write(TABLE_CONS, TEST_CELL); WriteReference secondWrite = WriteReference.write(TABLE_THOR, TEST_CELL); Transaction t1 = txManager.createNewTransaction(); Transaction t2 = txManager.createNewTransaction(); put(t1, firstWrite); put(t2, secondWrite); t1.commit(); assertThat(getEnqueuedWritesNumber(1)).containsExactly(WriteInfo.of(firstWrite, t1.getTimestamp())); assertLatestEntryForCellInKvsAtTimestamp(TABLE_CONS, TEST_CELL, t1.getTimestamp()); t2.commit(); assertThat(getEnqueuedWritesNumber(2)).containsExactly(WriteInfo.of(secondWrite, t2.getTimestamp())); assertLatestEntryForCellInKvsAtTimestamp(TABLE_THOR, TEST_CELL, t2.getTimestamp()); verify(sweepQueue, times(2)).enqueue(anyList()); }
public static WriteInfo toWriteInfo(TableReference tableRef, Map.Entry<Cell, byte[]> write, long timestamp) { Cell cell = write.getKey(); boolean isTombstone = Arrays.equals(write.getValue(), PtBytes.EMPTY_BYTE_ARRAY); return WriteInfo.of(WriteReference.of(tableRef, cell, isTombstone), timestamp); }
static WriteInfo write(TableReference tableRef, Cell cell, long timestamp) { return WriteInfo.of(WriteReference.of(tableRef, cell, false), timestamp); } }
static WriteInfo tombstone(TableReference tableRef, Cell cell, long timestamp) { return WriteInfo.of(WriteReference.of(tableRef, cell, true), timestamp); }
private WriteInfo getWriteInfo(long timestamp, Value value) { return WriteInfo.of( writeReferencePersister.unpersist(SweepableCellsColumnValue.hydrateValue(value.getContents())), timestamp); }