use of io.prestosql.decoder.json.JsonFieldDecoder in project pulsar by yahoo.
the class PulsarJsonRowDecoder method decodeRow.
/**
* decode ByteBuf by {@link org.apache.pulsar.client.api.schema.GenericSchema}.
* @param byteBuf
* @return
*/
@Override
public Optional<Map<DecoderColumnHandle, FieldValueProvider>> decodeRow(ByteBuf byteBuf) {
GenericJsonRecord record = (GenericJsonRecord) genericJsonSchema.decode(byteBuf);
JsonNode tree = record.getJsonNode();
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = new HashMap<>();
for (Map.Entry<DecoderColumnHandle, JsonFieldDecoder> entry : fieldDecoders.entrySet()) {
DecoderColumnHandle columnHandle = entry.getKey();
JsonFieldDecoder decoder = entry.getValue();
JsonNode node = locateNode(tree, columnHandle);
decodedRow.put(columnHandle, decoder.decode(node));
}
return Optional.of(decodedRow);
}
use of io.prestosql.decoder.json.JsonFieldDecoder in project pulsar by apache.
the class PulsarJsonRowDecoder method decodeRow.
/**
* decode ByteBuf by {@link org.apache.pulsar.client.api.schema.GenericSchema}.
* @param byteBuf
* @return
*/
@Override
public Optional<Map<DecoderColumnHandle, FieldValueProvider>> decodeRow(ByteBuf byteBuf) {
GenericJsonRecord record = (GenericJsonRecord) genericJsonSchema.decode(byteBuf);
JsonNode tree = record.getJsonNode();
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = new HashMap<>();
for (Map.Entry<DecoderColumnHandle, JsonFieldDecoder> entry : fieldDecoders.entrySet()) {
DecoderColumnHandle columnHandle = entry.getKey();
JsonFieldDecoder decoder = entry.getValue();
JsonNode node = locateNode(tree, columnHandle);
decodedRow.put(columnHandle, decoder.decode(node));
}
return Optional.of(decodedRow);
}
Aggregations