Search in sources :

Example 1 with HyperVectorValueIterator

use of org.apache.drill.exec.HyperVectorValueIterator in project drill by apache.

the class DrillTestWrapper method compareHyperVectors.

private void compareHyperVectors(Map<String, HyperVectorValueIterator> expectedRecords, Map<String, HyperVectorValueIterator> actualRecords) throws Exception {
    for (String s : expectedRecords.keySet()) {
        assertNotNull("Expected column '" + s + "' not found.", actualRecords.get(s));
        assertEquals(expectedRecords.get(s).getTotalRecords(), actualRecords.get(s).getTotalRecords());
        HyperVectorValueIterator expectedValues = expectedRecords.get(s);
        HyperVectorValueIterator actualValues = actualRecords.get(s);
        int i = 0;
        while (expectedValues.hasNext()) {
            compareValuesErrorOnMismatch(expectedValues.next(), actualValues.next(), i, s);
            i++;
        }
    }
    cleanupHyperValueIterators(expectedRecords.values());
    cleanupHyperValueIterators(actualRecords.values());
}
Also used : HyperVectorValueIterator(org.apache.drill.exec.HyperVectorValueIterator)

Example 2 with HyperVectorValueIterator

use of org.apache.drill.exec.HyperVectorValueIterator in project drill by apache.

the class DrillTestWrapper method compareResultsHyperVector.

public void compareResultsHyperVector() throws Exception {
    RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
    test(testOptionSettingQueries);
    List<QueryDataBatch> results = testRunAndReturn(queryType, query);
    checkNumBatches(results);
    // To avoid extra work for test writers, types can optionally be inferred from the test query
    addTypeInfoIfMissing(results.get(0), testBuilder);
    Map<String, HyperVectorValueIterator> actualSuperVectors = addToHyperVectorMap(results, loader);
    test(baselineOptionSettingQueries);
    List<QueryDataBatch> expected = testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
    Map<String, HyperVectorValueIterator> expectedSuperVectors = addToHyperVectorMap(expected, loader);
    compareHyperVectors(expectedSuperVectors, actualSuperVectors);
    cleanupBatches(results, expected);
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) HyperVectorValueIterator(org.apache.drill.exec.HyperVectorValueIterator)

Example 3 with HyperVectorValueIterator

use of org.apache.drill.exec.HyperVectorValueIterator in project drill by apache.

the class DrillTestWrapper method addToHyperVectorMap.

private Map<String, HyperVectorValueIterator> addToHyperVectorMap(final List<QueryDataBatch> records, final RecordBatchLoader loader) throws SchemaChangeException, UnsupportedEncodingException {
    // TODO - this does not handle schema changes
    Map<String, HyperVectorValueIterator> combinedVectors = new TreeMap<>();
    long totalRecords = 0;
    QueryDataBatch batch;
    int size = records.size();
    for (int i = 0; i < size; i++) {
        batch = records.get(i);
        loader.load(batch.getHeader().getDef(), batch.getData());
        logger.debug("reading batch with " + loader.getRecordCount() + " rows, total read so far " + totalRecords);
        totalRecords += loader.getRecordCount();
        for (VectorWrapper<?> w : loader) {
            String field = SchemaPath.getSimplePath(w.getField().getPath()).toExpr();
            if (!combinedVectors.containsKey(field)) {
                MaterializedField mf = w.getField();
                ValueVector[] vvList = (ValueVector[]) Array.newInstance(mf.getValueClass(), 1);
                vvList[0] = w.getValueVector();
                combinedVectors.put(field, new HyperVectorValueIterator(mf, new HyperVectorWrapper<>(mf, vvList)));
            } else {
                combinedVectors.get(field).getHyperVector().addVector(w.getValueVector());
            }
        }
    }
    for (HyperVectorValueIterator hvi : combinedVectors.values()) {
        hvi.determineTotalSize();
    }
    return combinedVectors;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) MaterializedField(org.apache.drill.exec.record.MaterializedField) HyperVectorWrapper(org.apache.drill.exec.record.HyperVectorWrapper) TreeMap(java.util.TreeMap) HyperVectorValueIterator(org.apache.drill.exec.HyperVectorValueIterator)

Aggregations

HyperVectorValueIterator (org.apache.drill.exec.HyperVectorValueIterator)3 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)2 TreeMap (java.util.TreeMap)1 HyperVectorWrapper (org.apache.drill.exec.record.HyperVectorWrapper)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)1 ValueVector (org.apache.drill.exec.vector.ValueVector)1