use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class JdbcKeyValueService method getAllTableNames.
private Set<TableReference> getAllTableNames(DSLContext ctx) {
Result<? extends Record> records = ctx.select(TABLE_NAME).from(METADATA_TABLE).fetch();
Set<TableReference> tableRefs = Sets.newHashSetWithExpectedSize(records.size());
for (Record record : records) {
tableRefs.add(TableReference.createUnsafe(record.getValue(TABLE_NAME)));
}
return tableRefs;
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class AtlasDbServiceImplTest method shouldTruncateNamespacedTables.
@Test
public void shouldTruncateNamespacedTables() throws Exception {
atlasDbService.truncateTable("ns.table");
TableReference tableToTruncate = TableReference.createFromFullyQualifiedName("ns.table");
verify(kvs, atLeastOnce()).truncateTable(tableToTruncate);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method truncateShouldBeIdempotent.
@Test
public void truncateShouldBeIdempotent() {
TableReference fooBar = TableReference.createUnsafe("foo.bar");
keyValueService.createTable(fooBar, AtlasDbConstants.GENERIC_TABLE_METADATA);
keyValueService.truncateTable(fooBar);
keyValueService.truncateTable(fooBar);
keyValueService.dropTable(fooBar);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method doTestGetRangePaging.
private void doTestGetRangePaging(int numColumnsInMetadata, int batchSizeHint, boolean reverse) {
TableReference tableRef = createTableWithNamedColumns(numColumnsInMetadata);
Map<Cell, byte[]> values = new HashMap<Cell, byte[]>();
values.put(Cell.create(PtBytes.toBytes("00"), PtBytes.toBytes("c1")), PtBytes.toBytes("a"));
values.put(Cell.create(PtBytes.toBytes("00"), PtBytes.toBytes("c2")), PtBytes.toBytes("b"));
values.put(Cell.create(PtBytes.toBytes("01"), RangeRequests.getFirstRowName()), PtBytes.toBytes("c"));
values.put(Cell.create(PtBytes.toBytes("02"), PtBytes.toBytes("c1")), PtBytes.toBytes("d"));
values.put(Cell.create(PtBytes.toBytes("02"), PtBytes.toBytes("c2")), PtBytes.toBytes("e"));
values.put(Cell.create(PtBytes.toBytes("03"), PtBytes.toBytes("c1")), PtBytes.toBytes("f"));
values.put(Cell.create(PtBytes.toBytes("04"), PtBytes.toBytes("c1")), PtBytes.toBytes("g"));
values.put(Cell.create(PtBytes.toBytes("04"), RangeRequests.getLastRowName()), PtBytes.toBytes("h"));
values.put(Cell.create(PtBytes.toBytes("05"), PtBytes.toBytes("c1")), PtBytes.toBytes("i"));
values.put(Cell.create(RangeRequests.getLastRowName(), PtBytes.toBytes("c1")), PtBytes.toBytes("j"));
keyValueService.put(tableRef, values, TEST_TIMESTAMP);
RangeRequest request = RangeRequest.builder(reverse).batchHint(batchSizeHint).build();
try (ClosableIterator<RowResult<Value>> iter = keyValueService.getRange(tableRef, request, Long.MAX_VALUE)) {
List<RowResult<Value>> results = ImmutableList.copyOf(iter);
List<RowResult<Value>> expected = ImmutableList.of(RowResult.create(PtBytes.toBytes("00"), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("a"), TEST_TIMESTAMP)).put(PtBytes.toBytes("c2"), Value.create(PtBytes.toBytes("b"), TEST_TIMESTAMP)).build()), RowResult.create(PtBytes.toBytes("01"), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(RangeRequests.getFirstRowName(), Value.create(PtBytes.toBytes("c"), TEST_TIMESTAMP)).build()), RowResult.create(PtBytes.toBytes("02"), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("d"), TEST_TIMESTAMP)).put(PtBytes.toBytes("c2"), Value.create(PtBytes.toBytes("e"), TEST_TIMESTAMP)).build()), RowResult.create(PtBytes.toBytes("03"), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("f"), TEST_TIMESTAMP)).build()), RowResult.create(PtBytes.toBytes("04"), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("g"), TEST_TIMESTAMP)).put(RangeRequests.getLastRowName(), Value.create(PtBytes.toBytes("h"), TEST_TIMESTAMP)).build()), RowResult.create(PtBytes.toBytes("05"), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("i"), TEST_TIMESTAMP)).build()), RowResult.create(RangeRequests.getLastRowName(), ImmutableSortedMap.<byte[], Value>orderedBy(UnsignedBytes.lexicographicalComparator()).put(PtBytes.toBytes("c1"), Value.create(PtBytes.toBytes("j"), TEST_TIMESTAMP)).build()));
assertEquals(reverse ? Lists.reverse(expected) : expected, results);
}
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method testGetAllTableNames.
@Test
public void testGetAllTableNames() {
final TableReference anotherTable = TableReference.createWithEmptyNamespace("AnotherTable");
assertEquals(1, keyValueService.getAllTableNames().size());
assertEquals(TEST_TABLE, keyValueService.getAllTableNames().iterator().next());
keyValueService.createTable(anotherTable, AtlasDbConstants.GENERIC_TABLE_METADATA);
assertEquals(2, keyValueService.getAllTableNames().size());
assertTrue(keyValueService.getAllTableNames().contains(anotherTable));
assertTrue(keyValueService.getAllTableNames().contains(TEST_TABLE));
keyValueService.dropTable(anotherTable);
assertEquals(1, keyValueService.getAllTableNames().size());
assertEquals(TEST_TABLE, keyValueService.getAllTableNames().iterator().next());
}
Aggregations