use of org.ojai.util.DocumentReaderWithProjection in project drill by apache.
the class ProjectionPassthroughVectorWriter method writeDBDocument.
@Override
protected void writeDBDocument(VectorContainerWriter vectorWriter, DBDocumentReaderBase reader) throws SchemaChangeException {
if (reader.next() != EventType.START_MAP) {
throw dataReadError(logger, "The document did not start with START_MAP!");
}
MapOrListWriterImpl writer = new MapOrListWriterImpl(vectorWriter.rootAsMap());
writer.start();
MapOrListWriter documentMapWriter = writer.map(DBConstants.DOCUMENT_FIELD);
documentMapWriter.start();
// write _id field data
if (includeId) {
valueWriter.writeBinary(documentMapWriter, DocumentConstants.ID_KEY, reader.getIdData());
}
// write rest of the data buffers
Map<Integer, ByteBuffer> dataMap = reader.getDataMap();
for (Entry<Integer, ByteBuffer> familyData : dataMap.entrySet()) {
valueWriter.writeBinary(documentMapWriter, String.valueOf(familyData.getKey()), familyData.getValue());
}
documentMapWriter.end();
DocumentReaderWithProjection p = new DocumentReaderWithProjection(reader, projector);
valueWriter.writeToListOrMap(writer, p);
}
Aggregations