@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> values) { delegate1.putWithTimestamps(tableRef, values); delegate2.putWithTimestamps(tableRef, values); }
private void writeToCell(Cell cell, byte[] data) { Value val = Value.create(data, TEST_TIMESTAMP + 1); keyValueService.putWithTimestamps(TEST_TABLE, ImmutableMultimap.of(cell, val)); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> values) { delegate().putWithTimestamps(tableRef, values); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> values) { getDelegate(tableRef).putWithTimestamps(tableRef, values); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> cellValues) { delegate().putWithTimestamps(tableRef, cellValues); writesByTable.add(tableRef, cellValues.size()); recordModifications(cellValues.size()); recordModificationsSize(cellValues.entries().stream() .mapToLong(cellEntry -> cellEntry.getValue().getContents().length).sum()); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> values) { try { delegate().putWithTimestamps(tableMapper.getMappedTableName(tableRef), values); } catch (TableMappingNotFoundException e) { throw new IllegalArgumentException(e); } }
private static void flush(Context context, Multimap<Cell, Value> batchToCreate, Multimap<Cell, Long> batchToDelete) { context.kvs.delete(AtlasDbConstants.OLD_SCRUB_TABLE, batchToDelete); context.totalDeletes += batchToDelete.size(); batchToDelete.clear(); try { context.kvs.putWithTimestamps(AtlasDbConstants.SCRUB_TABLE, batchToCreate); } catch (KeyAlreadyExistsException e) { context.kvs.delete(AtlasDbConstants.SCRUB_TABLE, Multimaps.transformValues(batchToCreate, Value::getTimestamp)); context.kvs.putWithTimestamps(AtlasDbConstants.SCRUB_TABLE, batchToCreate); } context.totalPuts += batchToCreate.size(); batchToCreate.clear(); context.output.println("Moved " + context.totalDeletes + " cells from " + "the old scrub queue into " + context.totalPuts + " cells in " + "the new scrub queue."); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> values) { maybeLog(() -> delegate.putWithTimestamps(tableRef, values), logCellsAndSize("putWithTimestamps", tableRef, values.keySet().size(), byteSize(values))); }
@Override public void putWithTimestamps(TableReference tableRef, Multimap<Cell, Value> values) { //noinspection unused - try-with-resources closes trace try (CloseableTrace trace = startLocalTrace("putWithTimestamps({}, {} values)", LoggingArgs.safeTableOrPlaceholder(tableRef), values.size())) { delegate().putWithTimestamps(tableRef, values); } }
return; delegate.putWithTimestamps(tableRef, cellValues);
@Test public void putWithTimestamps() throws Exception { Multimap<Cell, Value> values = ImmutableMultimap.of(CELL, VALUE); kvs.putWithTimestamps(TABLE_REF, values); checkSpan("atlasdb-kvs.putWithTimestamps({table}, 1 values)"); verify(delegate).putWithTimestamps(TABLE_REF, values); verifyNoMoreInteractions(delegate); }
@Test public void testPutWithTimestamps() { putTestDataForMultipleTimestamps(); final Value val1 = Value.create(val(0, 7), TEST_TIMESTAMP + 1); final Value val5 = Value.create(val(0, 9), TEST_TIMESTAMP + 5); keyValueService.putWithTimestamps(TEST_TABLE, ImmutableMultimap.of(TEST_CELL, val5)); assertEquals( val5, keyValueService.get(TEST_TABLE, ImmutableMap.of(TEST_CELL, TEST_TIMESTAMP + 6)).get(TEST_CELL)); assertEquals( val1, keyValueService.get(TEST_TABLE, ImmutableMap.of(TEST_CELL, TEST_TIMESTAMP + 5)).get(TEST_CELL)); keyValueService.delete(TEST_TABLE, ImmutableMultimap.of(TEST_CELL, TEST_TIMESTAMP + 5)); }
@Test public void deleteTimestampRangesIncludingSentinelsEdgeCases() { long minTs = 0; keyValueService.addGarbageCollectionSentinelValues(TEST_TABLE, ImmutableSet.of(TEST_CELL)); keyValueService.putWithTimestamps(TEST_TABLE, ImmutableMultimap.of( TEST_CELL, Value.create(val(0, 5), minTs), TEST_CELL, Value.create(val(0, 7), TEST_TIMESTAMP - 1), TEST_CELL, Value.create(val(0, 9), TEST_TIMESTAMP))); keyValueService.deleteAllTimestamps(TEST_TABLE, ImmutableMap.of(TEST_CELL, TEST_TIMESTAMP), true); assertThat(getAllTimestampsForTestCell(), contains(TEST_TIMESTAMP)); }
@Test public void deleteTimestampRangesEdgeCases() { long minTs = 0; keyValueService.addGarbageCollectionSentinelValues(TEST_TABLE, ImmutableSet.of(TEST_CELL)); keyValueService.putWithTimestamps(TEST_TABLE, ImmutableMultimap.of( TEST_CELL, Value.create(val(0, 5), minTs), TEST_CELL, Value.create(val(0, 7), TEST_TIMESTAMP - 1), TEST_CELL, Value.create(val(0, 9), TEST_TIMESTAMP))); keyValueService.deleteAllTimestamps(TEST_TABLE, ImmutableMap.of(TEST_CELL, TEST_TIMESTAMP), false); assertThat(getAllTimestampsForTestCell(), contains(Value.INVALID_VALUE_TIMESTAMP, TEST_TIMESTAMP)); }
@Test public void deleteTimestampRangesIncludingSentinelsDeletesForSingleColumn() { long ts1 = 5L; long ts2 = 10L; long latestTs = 15L; keyValueService.putWithTimestamps(TEST_TABLE, ImmutableMultimap.of( TEST_CELL, Value.create(val(0, 5), ts1), TEST_CELL, Value.create(val(0, 7), ts2), TEST_CELL, Value.create(val(0, 9), latestTs))); keyValueService.deleteAllTimestamps(TEST_TABLE, ImmutableMap.of(TEST_CELL, latestTs), true); assertThat(getAllTimestampsForTestCell(), contains(latestTs)); assertThat(keyValueService.get(TEST_TABLE, ImmutableMap.of(TEST_CELL, Long.MAX_VALUE)).get(TEST_CELL), equalTo(Value.create(val(0, 9), latestTs))); }
@Test public void deleteTimestampRangesDeletesForSingleColumn() { long ts1 = 5L; long ts2 = 10L; long latestTs = 15L; keyValueService.putWithTimestamps(TEST_TABLE, ImmutableMultimap.of( TEST_CELL, Value.create(val(0, 5), ts1), TEST_CELL, Value.create(val(0, 7), ts2), TEST_CELL, Value.create(val(0, 9), latestTs))); keyValueService.deleteAllTimestamps(TEST_TABLE, ImmutableMap.of(TEST_CELL, latestTs), false); assertThat(getAllTimestampsForTestCell(), contains(latestTs)); assertThat(keyValueService.get(TEST_TABLE, ImmutableMap.of(TEST_CELL, Long.MAX_VALUE)).get(TEST_CELL), equalTo(Value.create(val(0, 9), latestTs))); }
@Override public void setupTableData() { getKvs().truncateTable(getTableRef()); getKvs().putWithTimestamps(getTableRef(), allVersions); }
Cell cell3 = Cell.create(new byte[] {1, 2, 3}, new byte[] {7, 8, 9}); kvs.createTable(AtlasDbConstants.OLD_SCRUB_TABLE, new byte[] {0}); kvs.putWithTimestamps(AtlasDbConstants.OLD_SCRUB_TABLE, ImmutableMultimap.of( cell1, Value.create("foo\0bar".getBytes(), 10), cell1, Value.create("baz".getBytes(), 20),
@Test public void deletionTakesPlaceAtFreshTimestamp() throws Exception { TableReference tableReference = TableReference.createFromFullyQualifiedName("test." + RandomStringUtils.randomAlphanumeric(16)); keyValueService.createTable(tableReference, AtlasDbConstants.GENERIC_TABLE_METADATA); byte[] data = PtBytes.toBytes("data"); byte[] moreData = PtBytes.toBytes("data2"); keyValueService.putWithTimestamps(tableReference, ImmutableListMultimap.of(CELL, Value.create(data, 8L))); keyValueService.putWithTimestamps(tableReference, ImmutableListMultimap.of(CELL, Value.create(moreData, 88L))); keyValueService.delete(tableReference, ImmutableListMultimap.of(CELL, 8L)); putDummyValueAtCellAndTimestamp(tableReference, CELL, 8L, STARTING_ATLAS_TIMESTAMP - 1); Map<Cell, Value> results = keyValueService.get(tableReference, ImmutableMap.of(CELL, 8L + 1)); assertThat(results.containsKey(CELL), is(false)); }
@Test public void testScrubQueueIsCleared() { Cell cell1 = Cell.create(new byte[] {1}, new byte[] {2}); Cell cell2 = Cell.create(new byte[] {2}, new byte[] {3}); Cell cell3 = Cell.create(new byte[] {3}, new byte[] {4}); TableReference tableRef = TableReference.createFromFullyQualifiedName("foo.bar"); kvs.createTable(tableRef, new byte[] {}); kvs.putWithTimestamps(tableRef, ImmutableMultimap.<Cell, Value>builder() .put(cell1, Value.create(new byte[] {3}, 10)) .put(cell1, Value.create(new byte[] {4}, 20)) .put(cell2, Value.create(new byte[] {4}, 30)) .put(cell2, Value.create(new byte[] {5}, 40)) .put(cell2, Value.create(new byte[] {6}, 50)) .put(cell3, Value.create(new byte[] {7}, 60)) .build()); transactions.putUnlessExists(10, 15); transactions.putUnlessExists(20, 25); transactions.putUnlessExists(30, 35); transactions.putUnlessExists(50, 55); transactions.putUnlessExists(60, 65); scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell1, tableRef), 10, 100); scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell1, tableRef), 20, 100); scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell2, tableRef), 40, 100); scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell2, tableRef), 50, 100); scrubStore.queueCellsForScrubbing(ImmutableMultimap.of(cell3, tableRef), 60, 100); scrubber.runBackgroundScrubTask(null); List<SortedMap<Long, Multimap<TableReference, Cell>>> scrubQueue = BatchingVisitables.copyToList( scrubStore.getBatchingVisitableScrubQueue(Long.MAX_VALUE, null, null)); Assert.assertEquals(ImmutableList.of(), scrubQueue); }