Search in sources :

Example 36 with VectorWrapper

use of org.apache.drill.exec.record.VectorWrapper in project drill by apache.

the class ParquetResultListener method printRowMajor.

public void printRowMajor(RecordBatchLoader batchLoader) {
    for (int i = 0; i < batchLoader.getRecordCount(); i++) {
        if (i % 50 == 0) {
            System.out.println();
            for (VectorWrapper vw : batchLoader) {
                ValueVector v = vw.getValueVector();
                System.out.print(Strings.padStart(v.getField().getPath(), 20, ' ') + " ");
            }
            System.out.println();
            System.out.println();
        }
        for (final VectorWrapper vw : batchLoader) {
            final ValueVector v = vw.getValueVector();
            Object o = v.getAccessor().getObject(i);
            if (o instanceof byte[]) {
                try {
                    // TODO - in the dictionary read error test there is some data that does not look correct
                    // the output of our reader matches the values of the parquet-mr cat/head tools (no full comparison was made,
                    // but from a quick check of a few values it looked consistent
                    // this might have gotten corrupted by pig somehow, or maybe this is just how the data is supposed ot look
                    // TODO - check this!!
                    //              for (int k = 0; k < ((byte[])o).length; k++ ) {
                    //                // check that the value at each position is a valid single character ascii value.
                    //
                    //                if (((byte[])o)[k] > 128) {
                    //                  System.out.println("batch: " + batchCounter + " record: " + recordCount);
                    //                }
                    //              }
                    o = new String((byte[]) o, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.print(Strings.padStart(o + "", 20, ' ') + " ");
        }
        System.out.println();
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) VectorWrapper(org.apache.drill.exec.record.VectorWrapper) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

VectorWrapper (org.apache.drill.exec.record.VectorWrapper)36 ValueVector (org.apache.drill.exec.vector.ValueVector)23 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)17 Test (org.junit.Test)17 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)16 DrillClient (org.apache.drill.exec.client.DrillClient)13 Drillbit (org.apache.drill.exec.server.Drillbit)13 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)13 ExecTest (org.apache.drill.exec.ExecTest)4 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)4 Stopwatch (com.google.common.base.Stopwatch)3 IOException (java.io.IOException)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 ClassTransformationException (org.apache.drill.exec.exception.ClassTransformationException)3 MaterializedField (org.apache.drill.exec.record.MaterializedField)3 TypedFieldId (org.apache.drill.exec.record.TypedFieldId)3 VectorContainer (org.apache.drill.exec.record.VectorContainer)3 VarBinaryHolder (org.apache.drill.exec.expr.holders.VarBinaryHolder)2 RecordBatchData (org.apache.drill.exec.physical.impl.sort.RecordBatchData)2 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)2