Search in sources :

Example 1 with TableReference

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

Example 2 with TableReference

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

Example 3 with TableReference

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

Example 4 with TableReference

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

Example 5 with TableReference

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);
    }
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) Multimap(com.google.common.collect.Multimap) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Collection(java.util.Collection) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

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