Search in sources :

Example 1 with DocumentReaderWithProjection

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);
}
Also used : MapOrListWriterImpl(org.apache.drill.exec.vector.complex.impl.MapOrListWriterImpl) DocumentReaderWithProjection(org.ojai.util.DocumentReaderWithProjection) MapOrListWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapOrListWriter) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 MapOrListWriterImpl (org.apache.drill.exec.vector.complex.impl.MapOrListWriterImpl)1 MapOrListWriter (org.apache.drill.exec.vector.complex.writer.BaseWriter.MapOrListWriter)1 DocumentReaderWithProjection (org.ojai.util.DocumentReaderWithProjection)1