Search in sources :

Example 16 with TableMetadata

use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.

the class KeyValueServiceMigrator method getPartitioners.

private List<RowNamePartitioner> getPartitioners(KeyValueService kvs, TableReference table) {
    try {
        byte[] metadata = kvs.getMetadataForTable(table);
        TableMetadata tableMeta = TableMetadata.BYTES_HYDRATOR.hydrateFromBytes(metadata);
        return tableMeta.getRowMetadata().getPartitionersForRow();
    } catch (RuntimeException e) {
        processMessage("Could not resolve partitioners from table metadata for " + table + " this may result in a small decrease in performance migrating this table.", e, KvsMigrationMessageLevel.WARN);
        return ImmutableList.of();
    }
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata)

Example 17 with TableMetadata

use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.

the class TransactionRemotingTest method testGetTableMetadata.

@Test
public void testGetTableMetadata() {
    TableMetadata metadata = service.getTableMetadata("sweep.priority");
    Assert.assertFalse(metadata.getColumns().hasDynamicColumns());
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) Test(org.junit.Test)

Example 18 with TableMetadata

use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.

the class TableCellValDeserializer method deserialize.

@Override
public TableCellVal deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.readValueAsTree();
    String tableName = node.get("table").textValue();
    TableMetadata metadata = metadataCache.getMetadata(tableName);
    Map<Cell, byte[]> values = AtlasDeserializers.deserializeCellVals(metadata, node.get("data"));
    return new TableCellVal(tableName, values);
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) TableCellVal(com.palantir.atlasdb.api.TableCellVal) JsonNode(com.fasterxml.jackson.databind.JsonNode) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

Example 19 with TableMetadata

use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.

the class TableRangeDeserializer method deserialize.

@Override
public TableRange deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.readValueAsTree();
    String tableName = node.get("table").textValue();
    TableMetadata metadata = metadataCache.getMetadata(tableName);
    JsonNode optBatchSize = node.get("batch_size");
    int batchSize = optBatchSize == null ? 2000 : optBatchSize.asInt();
    Iterable<byte[]> columns = AtlasDeserializers.deserializeNamedCols(metadata.getColumns(), node.get("cols"));
    byte[] startRow = new byte[0];
    byte[] endRow = new byte[0];
    if (node.has("prefix")) {
        startRow = AtlasDeserializers.deserializeRowPrefix(metadata.getRowMetadata(), node.get("prefix"));
        endRow = RangeRequests.createEndNameForPrefixScan(startRow);
    } else {
        if (node.has("raw_start")) {
            startRow = node.get("raw_start").binaryValue();
        } else if (node.has("start")) {
            startRow = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), node.get("start"));
        }
        if (node.has("raw_end")) {
            endRow = node.get("raw_end").binaryValue();
        } else if (node.has("end")) {
            endRow = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), node.get("end"));
        }
    }
    return new TableRange(tableName, startRow, endRow, columns, batchSize);
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) TableRange(com.palantir.atlasdb.api.TableRange) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 20 with TableMetadata

use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.

the class TableCellValSerializer method serialize.

@Override
public void serialize(TableCellVal value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    TableMetadata metadata = metadataCache.getMetadata(value.getTableName());
    Preconditions.checkNotNull(metadata, "Unknown table %s", value.getTableName());
    jgen.writeStartObject();
    jgen.writeStringField("table", value.getTableName());
    jgen.writeArrayFieldStart("data");
    for (Entry<Cell, byte[]> result : value.getResults().entrySet()) {
        serialize(jgen, metadata, result);
    }
    jgen.writeEndArray();
    jgen.writeEndObject();
}
Also used : TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

Aggregations

TableMetadata (com.palantir.atlasdb.table.description.TableMetadata)26 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ColumnMetadataDescription (com.palantir.atlasdb.table.description.ColumnMetadataDescription)6 NameMetadataDescription (com.palantir.atlasdb.table.description.NameMetadataDescription)5 Test (org.junit.Test)5 Cell (com.palantir.atlasdb.keyvalue.api.Cell)4 BoundStatement (com.datastax.driver.core.BoundStatement)2 TableCell (com.palantir.atlasdb.api.TableCell)2 NamedColumnDescription (com.palantir.atlasdb.table.description.NamedColumnDescription)2 ResultSet (com.datastax.driver.core.ResultSet)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 TableCellVal (com.palantir.atlasdb.api.TableCellVal)1 TableRange (com.palantir.atlasdb.api.TableRange)1 TableRowResult (com.palantir.atlasdb.api.TableRowResult)1 TableRowSelection (com.palantir.atlasdb.api.TableRowSelection)1 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 TableMetadataPersistence (com.palantir.atlasdb.protos.generated.TableMetadataPersistence)1 DynamicColumnDescription (com.palantir.atlasdb.table.description.DynamicColumnDescription)1 TableDefinition (com.palantir.atlasdb.table.description.TableDefinition)1