use of com.palantir.atlasdb.table.description.ColumnMetadataDescription 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.ColumnMetadataDescription 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;
}
use of com.palantir.atlasdb.table.description.ColumnMetadataDescription in project atlasdb by palantir.
the class TableMetadataDeserializer method deserializeNamedCols.
private ColumnMetadataDescription deserializeNamedCols(JsonNode node) {
Collection<NamedColumnDescription> cols = Lists.newArrayList();
for (JsonNode colNode : node.get("columns")) {
String name = colNode.get("name").asText();
String longName = colNode.get("long_name").asText();
ColumnValueDescription val = deserializeValue(colNode.get("value"));
cols.add(new NamedColumnDescription(name, longName, val));
}
return new ColumnMetadataDescription(cols);
}
use of com.palantir.atlasdb.table.description.ColumnMetadataDescription in project atlasdb by palantir.
the class TableMetadataDeserializer method deserialize.
@Override
public TableMetadata deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode node = jp.readValueAsTree();
NameMetadataDescription row = deserializeRowish(node);
ColumnMetadataDescription col;
if (node.get("is_dynamic").asBoolean()) {
col = deserializeDynamicCol(node);
} else {
col = deserializeNamedCols(node);
}
return new TableMetadata(row, col, ConflictHandler.IGNORE_ALL);
}
use of com.palantir.atlasdb.table.description.ColumnMetadataDescription in project atlasdb by palantir.
the class TableMetadataSerializer method serialize.
@Override
public void serialize(TableMetadata value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeStartObject();
NameMetadataDescription rowMetadata = value.getRowMetadata();
ColumnMetadataDescription columnMetadata = value.getColumns();
boolean isDynamic = columnMetadata.hasDynamicColumns();
jgen.writeBooleanField("is_dynamic", isDynamic);
jgen.writeArrayFieldStart("row");
serialize(jgen, rowMetadata);
jgen.writeEndArray();
if (isDynamic) {
DynamicColumnDescription dynamicColumn = columnMetadata.getDynamicColumn();
jgen.writeArrayFieldStart("column");
serialize(jgen, dynamicColumn.getColumnNameDesc());
jgen.writeEndArray();
jgen.writeObjectFieldStart("value");
serialize(jgen, dynamicColumn.getValue());
jgen.writeEndObject();
} else {
jgen.writeArrayFieldStart("columns");
for (NamedColumnDescription namedColumn : columnMetadata.getNamedColumns()) {
jgen.writeStartObject();
jgen.writeObjectField("name", namedColumn.getShortName());
jgen.writeObjectField("long_name", namedColumn.getLongName());
jgen.writeObjectFieldStart("value");
serialize(jgen, namedColumn.getValue());
jgen.writeEndObject();
jgen.writeEndObject();
}
jgen.writeEndArray();
}
jgen.writeEndObject();
}
Aggregations