use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class DbKvs method getAllTableNames.
@Override
public Set<TableReference> getAllTableNames() {
return run(conn -> {
AgnosticResultSet results = conn.selectResultSetUnregisteredQuery("SELECT table_name FROM " + config.metadataTable().getQualifiedName());
Set<TableReference> ret = Sets.newHashSetWithExpectedSize(results.size());
for (AgnosticResultRow row : results.rows()) {
ret.add(TableReference.createUnsafe(row.getString("table_name")));
}
return ret;
});
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class OracleTableNameMapperTest method shouldThrowIfTable9999Exists.
@Test
public void shouldThrowIfTable9999Exists() {
when(resultSet.size()).thenReturn(1);
AgnosticResultRow row = mock(AgnosticResultRow.class);
when(row.getString(eq("short_table_name"))).thenReturn(getTableNameWithNumber(9999));
when(resultSet.get(eq(0))).thenReturn(row);
TableReference tableRef = TableReference.create(TEST_NAMESPACE, LONG_TABLE_NAME);
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Cannot create any more tables with name starting with a_te__ThisIsAVeryLongT");
oracleTableNameMapper.getShortPrefixedTableName(connectionSupplier, TEST_PREFIX, tableRef);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class DbkvsPostgresKeyValueServiceTest method createTwoTablesWithSamePrefix.
private void createTwoTablesWithSamePrefix(String tableNamePrefix) {
TableReference longTableName1 = TableReference.create(TEST_NAMESPACE, tableNamePrefix + "1");
TableReference longTableName2 = TableReference.create(TEST_NAMESPACE, tableNamePrefix + "2");
try {
keyValueService.createTable(longTableName1, AtlasDbConstants.GENERIC_TABLE_METADATA);
keyValueService.createTable(longTableName2, AtlasDbConstants.GENERIC_TABLE_METADATA);
} finally {
keyValueService.dropTable(longTableName1);
keyValueService.dropTable(longTableName2);
}
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class LoggingArgsTest method setUpMocks.
@BeforeClass
public static void setUpMocks() {
when(arbitrator.isTableReferenceSafe(any())).thenAnswer(invocation -> {
TableReference tableReference = (TableReference) invocation.getArguments()[0];
return tableReference.getQualifiedName().contains("safe");
});
when(arbitrator.isRowComponentNameSafe(any(), any(String.class))).thenAnswer(invocation -> {
String rowName = (String) invocation.getArguments()[1];
return rowName.contains("safe");
});
when(arbitrator.isColumnNameSafe(any(), any(String.class))).thenAnswer(invocation -> {
String columnName = (String) invocation.getArguments()[1];
return columnName.contains("safe");
});
LoggingArgs.setLogArbitrator(arbitrator);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class KeyValueServiceScrubberStore method markCellsAsScrubbed.
@Override
public void markCellsAsScrubbed(Map<TableReference, Multimap<Cell, Long>> cellToScrubTimestamp, int batchSize) {
Multimap<Cell, Long> batch = ArrayListMultimap.create();
for (Entry<TableReference, Multimap<Cell, Long>> tableEntry : cellToScrubTimestamp.entrySet()) {
byte[] tableBytes = EncodingUtils.encodeVarString(tableEntry.getKey().getQualifiedName());
for (Entry<Cell, Collection<Long>> cellEntry : tableEntry.getValue().asMap().entrySet()) {
byte[] col = EncodingUtils.add(tableBytes, cellEntry.getKey().getColumnName());
Cell cell = Cell.create(cellEntry.getKey().getRowName(), col);
for (Long timestamp : cellEntry.getValue()) {
batch.put(cell, timestamp);
if (batch.size() >= batchSize) {
keyValueService.delete(AtlasDbConstants.SCRUB_TABLE, batch);
batch.clear();
}
}
}
}
if (!batch.isEmpty()) {
keyValueService.delete(AtlasDbConstants.SCRUB_TABLE, batch);
}
}
Aggregations