use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class SchemasTest method testCreateTables.
@Test
public void testCreateTables() {
TableReference tableName1 = TableReference.createWithEmptyNamespace(TABLE_NAME + "1");
TableReference tableName2 = TableReference.createWithEmptyNamespace(TABLE_NAME + "2");
mockery.checking(new Expectations() {
{
oneOf(kvs).createTables(with(tableMapContainsEntry(tableName1, getSimpleTableDefinitionAsBytes(tableName1))));
oneOf(kvs).createTables(with(tableMapContainsEntry(tableName2, getSimpleTableDefinitionAsBytes(tableName2))));
}
});
Map<TableReference, TableDefinition> tables = Maps.newHashMap();
tables.put(tableName1, getSimpleTableDefinition(tableName1));
tables.put(tableName2, getSimpleTableDefinition(tableName2));
Schemas.createTables(kvs, tables);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class OracleTableNameMapper method getShortPrefixedTableName.
public String getShortPrefixedTableName(ConnectionSupplier connectionSupplier, String tablePrefix, TableReference tableRef) {
Preconditions.checkState(tablePrefix.length() <= AtlasDbConstants.MAX_TABLE_PREFIX_LENGTH, "The tablePrefix can be at most %s characters long", AtlasDbConstants.MAX_TABLE_PREFIX_LENGTH);
TableReference shortenedNamespaceTableRef = truncateNamespace(tableRef);
String prefixedTableName = tablePrefix + DbKvs.internalTableName(shortenedNamespaceTableRef);
String truncatedTableName = truncate(prefixedTableName, NAMESPACED_TABLE_NAME_LENGTH);
String fullTableName = tablePrefix + DbKvs.internalTableName(tableRef);
return truncatedTableName + "_" + getTableNumber(connectionSupplier, fullTableName, truncatedTableName);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class DbKvs method getMetadataForTables.
@Override
public Map<TableReference, byte[]> getMetadataForTables() {
return run(conn -> {
AgnosticResultSet results = conn.selectResultSetUnregisteredQuery("SELECT table_name, value FROM " + config.metadataTable().getQualifiedName());
Map<TableReference, byte[]> ret = Maps.newHashMapWithExpectedSize(results.size());
for (AgnosticResultRow row : results.rows()) {
ret.put(TableReference.createUnsafe(row.getString("table_name")), row.getBytes("value"));
}
return ret;
});
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class DbkvsPostgresKeyValueServiceTest method shouldNotThrowWhenCreatingDifferentLongTablesWithDifferentFirstCharactersUntilTheTableNameLimit.
@Test
public void shouldNotThrowWhenCreatingDifferentLongTablesWithDifferentFirstCharactersUntilTheTableNameLimit() {
TableReference longTableName1 = TableReference.create(TEST_NAMESPACE, "a" + TEST_LONG_TABLE_NAME);
TableReference longTableName2 = TableReference.create(TEST_NAMESPACE, "b" + TEST_LONG_TABLE_NAME);
keyValueService.createTable(longTableName1, AtlasDbConstants.GENERIC_TABLE_METADATA);
keyValueService.createTable(longTableName2, AtlasDbConstants.GENERIC_TABLE_METADATA);
keyValueService.dropTable(longTableName1);
keyValueService.dropTable(longTableName2);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class OracleTableNameMapperTest method shouldModifyTableNameForShortTableName.
@Test
public void shouldModifyTableNameForShortTableName() {
when(resultSet.size()).thenReturn(0);
TableReference tableRef = TableReference.create(Namespace.create("ns1"), "short");
String shortPrefixedTableName = oracleTableNameMapper.getShortPrefixedTableName(connectionSupplier, TEST_PREFIX, tableRef);
assertThat(shortPrefixedTableName, is("a_ns__short_0000"));
}
Aggregations