Search in sources :

Example 51 with TableReference

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);
}
Also used : Expectations(org.jmock.Expectations) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Test(org.junit.Test)

Example 52 with TableReference

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);
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference)

Example 53 with TableReference

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;
    });
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) AgnosticResultSet(com.palantir.nexus.db.sql.AgnosticResultSet) AgnosticResultRow(com.palantir.nexus.db.sql.AgnosticResultRow)

Example 54 with TableReference

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);
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Test(org.junit.Test)

Example 55 with TableReference

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"));
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Test(org.junit.Test)

Aggregations

TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)112 Cell (com.palantir.atlasdb.keyvalue.api.Cell)41 Test (org.junit.Test)41 Map (java.util.Map)17 ImmutableMap (com.google.common.collect.ImmutableMap)13 Multimap (com.google.common.collect.Multimap)13 Entry (java.util.Map.Entry)13 Set (java.util.Set)13 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)12 Value (com.palantir.atlasdb.keyvalue.api.Value)12 Collection (java.util.Collection)12 List (java.util.List)12 ImmutableSet (com.google.common.collect.ImmutableSet)11 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)11 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)11 SortedMap (java.util.SortedMap)11 Lists (com.google.common.collect.Lists)10 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)10 Sets (com.google.common.collect.Sets)9 InsufficientConsistencyException (com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException)9