use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class ExpressionInterpreterTest method doTest.
protected void doTest(String expressionStr, String[] colNames, TypeProtos.MajorType[] colTypes, String[] expectFirstTwoValues, BitControl.PlanFragment planFragment) throws Exception {
@SuppressWarnings("resource") final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
@SuppressWarnings("resource") final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
bit1.run();
// Create a mock scan batch as input for evaluation.
assertEquals(colNames.length, colTypes.length);
final MockTableDef.MockColumn[] columns = new MockTableDef.MockColumn[colNames.length];
for (int i = 0; i < colNames.length; i++) {
columns[i] = new MockTableDef.MockColumn(colNames[i], colTypes[i].getMinorType(), colTypes[i].getMode(), 0, 0, 0, null, null, null);
}
final MockTableDef.MockScanEntry entry = new MockTableDef.MockScanEntry(10, false, 0, 1, columns);
final MockSubScanPOP scanPOP = new MockSubScanPOP("testTable", false, java.util.Collections.singletonList(entry));
@SuppressWarnings("resource") final ScanBatch batch = createMockScanBatch(bit1, scanPOP, planFragment);
batch.next();
@SuppressWarnings("resource") final ValueVector vv = evalExprWithInterpreter(expressionStr, batch, bit1);
// Verify the first 2 values in the output of evaluation.
assertEquals(2, expectFirstTwoValues.length);
assertEquals(expectFirstTwoValues[0], getValueFromVector(vv, 0));
assertEquals(expectFirstTwoValues[1], getValueFromVector(vv, 1));
showValueVectorContent(vv);
vv.clear();
batch.close();
batch.getContext().close();
bit1.close();
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class ParquetResultListener method dataArrived.
@Override
public synchronized void dataArrived(QueryDataBatch result, ConnectionThrottle throttle) {
logger.debug("result arrived in test batch listener.");
int columnValCounter = 0;
FieldInfo currentField;
count += result.getHeader().getRowCount();
boolean schemaChanged = false;
final RecordBatchLoader batchLoader = new RecordBatchLoader(allocator);
try {
schemaChanged = batchLoader.load(result.getHeader().getDef(), result.getData());
// TODO: Clean: DRILL-2933: That load(...) no longer throws
// SchemaChangeException, so check/clean catch clause below.
} catch (SchemaChangeException e) {
throw new RuntimeException(e);
}
// used to make sure each vector in the batch has the same number of records
int valueCount = batchLoader.getRecordCount();
// print headers.
if (schemaChanged) {
}
for (final VectorWrapper vw : batchLoader) {
final ValueVector vv = vw.getValueVector();
currentField = props.fields.get(vv.getField().getPath());
if (!valuesChecked.containsKey(vv.getField().getPath())) {
valuesChecked.put(vv.getField().getPath(), 0);
columnValCounter = 0;
} else {
columnValCounter = valuesChecked.get(vv.getField().getPath());
}
printColumnMajor(vv);
if (testValues) {
for (int j = 0; j < vv.getAccessor().getValueCount(); j++) {
assertField(vv, j, currentField.type, currentField.values[columnValCounter % 3], currentField.name + "/");
columnValCounter++;
}
} else {
columnValCounter += vv.getAccessor().getValueCount();
}
valuesChecked.remove(vv.getField().getPath());
assertEquals("Mismatched value count for vectors in the same batch.", valueCount, vv.getAccessor().getValueCount());
valuesChecked.put(vv.getField().getPath(), columnValCounter);
}
if (ParquetRecordReaderTest.VERBOSE_DEBUG) {
printRowMajor(batchLoader);
}
batchCounter++;
batchLoader.clear();
result.release();
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class TestOutputMutator method replace.
private void replace(ValueVector newVector, SchemaPath schemaPath) {
List<ValueVector> vectors = Lists.newArrayList();
for (VectorWrapper w : container) {
ValueVector vector = w.getValueVector();
if (vector.getField().getPath().equals(schemaPath)) {
vectors.add(newVector);
} else {
vectors.add(w.getValueVector());
}
container.remove(vector);
}
container.addCollection(vectors);
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class AbstractContainerVector method getLastPathType.
MajorType getLastPathType() {
if ((this.getField().getType().getMinorType() == MinorType.LIST && this.getField().getType().getMode() == DataMode.REPEATED)) {
// Use Repeated scalar type instead of Required List.
VectorWithOrdinal vord = getChildVectorWithOrdinal(null);
ValueVector v = vord.vector;
if (!(v instanceof AbstractContainerVector)) {
return v.getField().getType();
}
} else if (this.getField().getType().getMinorType() == MinorType.MAP && this.getField().getType().getMode() == DataMode.REPEATED) {
// Use Required Map
return this.getField().getType().toBuilder().setMode(DataMode.REQUIRED).build();
}
return this.getField().getType();
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class AbstractMapVector method close.
@Override
public void close() {
for (final ValueVector valueVector : vectors.values()) {
valueVector.close();
}
vectors.clear();
super.close();
}
Aggregations