use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class OracleDdlTable method create.
@Override
public void create(byte[] tableMetadata) {
if (conns.get().selectExistsUnregisteredQuery("SELECT 1 FROM " + config.metadataTable().getQualifiedName() + " WHERE table_name = ?", tableRef.getQualifiedName())) {
return;
}
boolean needsOverflow = false;
TableMetadata metadata = TableMetadata.BYTES_HYDRATOR.hydrateFromBytes(tableMetadata);
if (metadata != null) {
needsOverflow = metadata.getColumns().getMaxValueSize() > AtlasDbConstants.ORACLE_OVERFLOW_THRESHOLD;
}
createTable(needsOverflow);
if (needsOverflow && config.overflowMigrationState() != OverflowMigrationState.UNSTARTED) {
createOverflowTable();
}
conns.get().insertOneUnregisteredQuery("INSERT INTO " + config.metadataTable().getQualifiedName() + " (table_name, table_size) VALUES (?, ?)", tableRef.getQualifiedName(), needsOverflow ? TableValueStyle.OVERFLOW.getId() : TableValueStyle.RAW.getId());
}
use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class KeyValueServiceScrubberStore method tryInitialize.
private void tryInitialize() {
TableMetadata scrubTableMeta = new TableMetadata(NameMetadataDescription.create(ImmutableList.of(new NameComponentDescription.Builder().componentName("row").type(ValueType.BLOB).build())), new ColumnMetadataDescription(new DynamicColumnDescription(NameMetadataDescription.create(ImmutableList.of(new NameComponentDescription.Builder().componentName("table").type(ValueType.VAR_STRING).build(), new NameComponentDescription.Builder().componentName("col").type(ValueType.BLOB).build())), ColumnValueDescription.forType(ValueType.VAR_LONG))), ConflictHandler.IGNORE_ALL, TableMetadataPersistence.LogSafety.SAFE);
keyValueService.createTable(AtlasDbConstants.SCRUB_TABLE, scrubTableMeta.persistToBytes());
}
use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class TableRowSelectionSerializer method serialize.
@Override
public void serialize(TableRowSelection 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("rows");
for (byte[] row : value.getRows()) {
AtlasSerializers.serializeRowish(jgen, metadata.getRowMetadata(), row);
}
jgen.writeEndArray();
if (!value.getColumnSelection().allColumnsSelected()) {
jgen.writeArrayFieldStart("cols");
for (byte[] col : value.getColumnSelection().getSelectedColumns()) {
jgen.writeUTF8String(col, 0, col.length);
}
jgen.writeEndArray();
}
jgen.writeEndObject();
}
use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class TableRowSelectionDeserializer method deserialize.
@Override
public TableRowSelection deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode node = jp.readValueAsTree();
String tableName = node.get("table").textValue();
TableMetadata metadata = metadataCache.getMetadata(tableName);
Iterable<byte[]> rows = AtlasDeserializers.deserializeRows(metadata.getRowMetadata(), node.get("rows"));
Iterable<byte[]> columns = AtlasDeserializers.deserializeNamedCols(metadata.getColumns(), node.get("cols"));
if (Iterables.isEmpty(columns)) {
return new TableRowSelection(tableName, rows, ColumnSelection.all());
} else {
return new TableRowSelection(tableName, rows, ColumnSelection.create(columns));
}
}
use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class AbstractKeyValueServiceTest method createTableWithNamedColumns.
private TableReference createTableWithNamedColumns(int numColumns) {
TableReference tableRef = TableReference.createFromFullyQualifiedName("ns.pt_kvs_test_named_cols_" + numColumns);
List<NamedColumnDescription> columns = new ArrayList<>();
for (int i = 1; i <= numColumns; ++i) {
columns.add(new NamedColumnDescription("c" + i, "column" + i, ColumnValueDescription.forType(ValueType.BLOB)));
}
keyValueService.createTable(tableRef, new TableMetadata(new NameMetadataDescription(), new ColumnMetadataDescription(columns), ConflictHandler.RETRY_ON_WRITE_WRITE, TableMetadataPersistence.LogSafety.SAFE).persistToBytes());
keyValueService.truncateTable(tableRef);
return tableRef;
}
Aggregations