use of org.apache.drill.exec.vector.VarCharVector in project drill by apache.
the class BatchValidator method validateNullableVector.
private void validateNullableVector(String name, NullableVector vector) {
if (vector instanceof NullableVarCharVector) {
@SuppressWarnings("resource") VarCharVector values = ((NullableVarCharVector) vector).getValuesVector();
validateVarCharVector(name + "-values", values, rowCount);
}
}
use of org.apache.drill.exec.vector.VarCharVector in project drill by apache.
the class TestOrderedBytesConvertFunctions method getRunResult.
protected Object[] getRunResult(QueryType queryType, String planString) throws Exception {
List<QueryDataBatch> resultList = testRunAndReturn(queryType, planString);
List<Object> res = new ArrayList<Object>();
RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
for (QueryDataBatch result : resultList) {
if (result.getData() != null) {
loader.load(result.getHeader().getDef(), result.getData());
ValueVector v = loader.iterator().next().getValueVector();
for (int j = 0; j < v.getAccessor().getValueCount(); j++) {
if (v instanceof VarCharVector) {
res.add(new String(((VarCharVector) v).getAccessor().get(j)));
} else {
res.add(v.getAccessor().getObject(j));
}
}
loader.clear();
result.release();
}
}
return res.toArray();
}
use of org.apache.drill.exec.vector.VarCharVector in project drill by apache.
the class VaryingStringGen method setValue.
@Override
public void setValue(ValueVector v, int index) {
VarCharVector vector = (VarCharVector) v;
vector.getMutator().setSafe(index, value().getBytes());
}
use of org.apache.drill.exec.vector.VarCharVector in project drill by apache.
the class TestWriter method simpleCsv.
@Test
public void simpleCsv() throws Exception {
// before executing the test deleting the existing CSV files in /tmp/csvtest
Path path = new Path("/tmp/csvtest");
if (fs.exists(path)) {
fs.delete(path, true);
}
String plan = Files.toString(FileUtils.getResourceAsFile("/writer/simple_csv_writer.json"), Charsets.UTF_8);
List<QueryDataBatch> results = testPhysicalWithResults(plan);
RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator());
QueryDataBatch batch = results.get(0);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
VarCharVector fragmentIdV = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 0).getValueVector();
BigIntVector recordWrittenV = (BigIntVector) batchLoader.getValueAccessorById(BigIntVector.class, 1).getValueVector();
// expected only one row in output
assertEquals(1, batchLoader.getRecordCount());
assertEquals("0_0", fragmentIdV.getAccessor().getObject(0).toString());
assertEquals(132000, recordWrittenV.getAccessor().get(0));
// now verify csv files are written to disk
assertTrue(fs.exists(path));
// expect two files
FileStatus[] fileStatuses = fs.globStatus(new Path(path.toString(), "*.csv"));
assertTrue(2 == fileStatuses.length);
for (QueryDataBatch b : results) {
b.release();
}
batchLoader.clear();
}
use of org.apache.drill.exec.vector.VarCharVector in project drill by apache.
the class TestConvertFunctions method getRunResult.
protected Object[] getRunResult(QueryType queryType, String planString) throws Exception {
List<QueryDataBatch> resultList = testRunAndReturn(queryType, planString);
List<Object> res = new ArrayList<Object>();
RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
for (QueryDataBatch result : resultList) {
if (result.getData() != null) {
loader.load(result.getHeader().getDef(), result.getData());
@SuppressWarnings("resource") ValueVector v = loader.iterator().next().getValueVector();
for (int j = 0; j < v.getAccessor().getValueCount(); j++) {
if (v instanceof VarCharVector) {
res.add(new String(((VarCharVector) v).getAccessor().get(j)));
} else {
res.add(v.getAccessor().getObject(j));
}
}
loader.clear();
result.release();
}
}
return res.toArray();
}
Aggregations