use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class TableCellDeserializer method deserialize.
@Override
public TableCell deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode node = jp.readValueAsTree();
String tableName = node.get("table").textValue();
TableMetadata metadata = metadataCache.getMetadata(tableName);
Iterable<Cell> cells = AtlasDeserializers.deserializeCells(metadata, node.get("data"));
return new TableCell(tableName, cells);
}
use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class TableCellSerializer method serialize.
@Override
public void serialize(TableCell 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 (Cell cell : value.getCells()) {
serialize(jgen, metadata, cell);
}
jgen.writeEndArray();
jgen.writeEndObject();
}
use of com.palantir.atlasdb.table.description.TableMetadata 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.TableMetadata in project atlasdb by palantir.
the class TableRowResultDeserializer method deserialize.
@Override
public TableRowResult deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode node = jp.readValueAsTree();
String tableName = node.get("table").textValue();
Collection<RowResult<byte[]>> rowResults = Lists.newArrayList();
TableMetadata metadata = metadataCache.getMetadata(tableName);
for (JsonNode rowResult : node.get("data")) {
byte[] row = AtlasDeserializers.deserializeRow(metadata.getRowMetadata(), rowResult.get("row"));
ImmutableSortedMap.Builder<byte[], byte[]> cols = ImmutableSortedMap.orderedBy(UnsignedBytes.lexicographicalComparator());
if (metadata.getColumns().hasDynamicColumns()) {
for (JsonNode colVal : rowResult.get("cols")) {
byte[] col = AtlasDeserializers.deserializeCol(metadata.getColumns(), colVal.get("col"));
byte[] val = AtlasDeserializers.deserializeVal(metadata.getColumns().getDynamicColumn().getValue(), colVal.get("val"));
cols.put(col, val);
}
} else {
JsonNode namedCols = rowResult.get("cols");
for (NamedColumnDescription namedCol : metadata.getColumns().getNamedColumns()) {
JsonNode valNode = namedCols.get(namedCol.getLongName());
if (valNode != null) {
byte[] col = namedCol.getShortName().getBytes(StandardCharsets.UTF_8);
byte[] val = AtlasDeserializers.deserializeVal(namedCol.getValue(), valNode);
cols.put(col, val);
}
}
}
rowResults.add(RowResult.create(row, cols.build()));
}
return new TableRowResult(tableName, rowResults);
}
use of com.palantir.atlasdb.table.description.TableMetadata in project atlasdb by palantir.
the class TableRangeSerializer method serialize.
@Override
public void serialize(TableRange value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
TableMetadata metadata = metadataCache.getMetadata(value.getTableName());
jgen.writeStartObject();
jgen.writeStringField("table", value.getTableName());
jgen.writeBinaryField("raw_start", value.getStartRow());
jgen.writeBinaryField("raw_end", value.getEndRow());
jgen.writeNumberField("batch_size", value.getBatchSize());
if (!Iterables.isEmpty(value.getColumns())) {
jgen.writeArrayFieldStart("cols");
for (byte[] column : value.getColumns()) {
AtlasSerializers.serializeCol(jgen, metadata.getColumns(), column);
}
jgen.writeEndArray();
}
jgen.writeEndObject();
}
Aggregations