use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class BatchToRowReader method nextVarchar.
public static HiveVarcharWritable nextVarchar(ColumnVector vector, int row, int size, Object previous) {
if (vector.isRepeating) {
row = 0;
}
if (vector.noNulls || !vector.isNull[row]) {
HiveVarcharWritable result;
if (previous == null || previous.getClass() != HiveVarcharWritable.class) {
result = new HiveVarcharWritable();
} else {
result = (HiveVarcharWritable) previous;
}
BytesColumnVector bytes = (BytesColumnVector) vector;
result.set(bytes.toString(row), size);
return result;
} else {
return null;
}
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class BatchToRowReader method nextBinary.
public static BytesWritable nextBinary(ColumnVector vector, int row, Object previous) {
if (vector.isRepeating) {
row = 0;
}
if (vector.noNulls || !vector.isNull[row]) {
BytesWritable result;
if (previous == null || previous.getClass() != BytesWritable.class) {
result = new BytesWritable();
} else {
result = (BytesWritable) previous;
}
BytesColumnVector bytes = (BytesColumnVector) vector;
result.set(bytes.vector[row], bytes.start[row], bytes.length[row]);
return result;
} else {
return null;
}
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorExpressionWriters method testWriterText.
private void testWriterText(TypeInfo type) throws HiveException {
Text t1 = new Text("alpha");
Text t2 = new Text("beta");
BytesColumnVector bcv = new BytesColumnVector(vectorSize);
bcv.noNulls = false;
bcv.initBuffer();
bcv.setVal(0, t1.getBytes(), 0, t1.getLength());
bcv.isNull[1] = true;
bcv.setVal(2, t2.getBytes(), 0, t2.getLength());
bcv.isNull[3] = true;
bcv.setVal(4, t1.getBytes(), 0, t1.getLength());
VectorExpressionWriter vew = getWriter(type);
for (int i = 0; i < vectorSize; i++) {
Writable w = (Writable) vew.writeValue(bcv, i);
if (w != null) {
byte[] val = new byte[bcv.length[i]];
System.arraycopy(bcv.vector[i], bcv.start[i], val, 0, bcv.length[i]);
Writable expected = getWritableValue(type, val);
Assert.assertEquals(expected, w);
} else {
Assert.assertTrue(bcv.isNull[i]);
}
}
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorFilterExpressions method testFilterStringBetween.
@Test
public void testFilterStringBetween() {
int seed = 17;
VectorizedRowBatch vrb = VectorizedRowGroupGenUtil.getVectorizedRowBatch(3, 2, seed);
vrb.cols[0] = new BytesColumnVector();
BytesColumnVector bcv = (BytesColumnVector) vrb.cols[0];
bcv.initBuffer();
bcv.setVal(0, a, 0, 1);
bcv.setVal(1, b, 0, 1);
bcv.setVal(2, c, 0, 1);
VectorExpression expr = new FilterStringColumnBetween(0, b, c);
// basic test
expr.evaluate(vrb);
assertEquals(2, vrb.size);
assertTrue(vrb.selectedInUse);
assertEquals(1, vrb.selected[0]);
assertEquals(2, vrb.selected[1]);
// nulls
vrb.selectedInUse = false;
vrb.size = 3;
bcv.noNulls = false;
bcv.isNull[2] = true;
expr.evaluate(vrb);
assertEquals(1, vrb.size);
assertEquals(1, vrb.selected[0]);
assertTrue(vrb.selectedInUse);
// repeating
vrb.selectedInUse = false;
vrb.size = 3;
bcv.noNulls = true;
bcv.isRepeating = true;
expr.evaluate(vrb);
assertEquals(0, vrb.size);
// nulls and repeating
vrb.selectedInUse = false;
vrb.size = 3;
bcv.noNulls = false;
bcv.isRepeating = true;
bcv.isNull[0] = true;
bcv.setVal(0, b, 0, 1);
expr.evaluate(vrb);
assertEquals(0, vrb.size);
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorFilterExpressions method testFilterStringNotBetween.
@Test
public void testFilterStringNotBetween() {
// Spot check only. Non-standard cases are checked for the same template in another test.
int seed = 17;
VectorizedRowBatch vrb = VectorizedRowGroupGenUtil.getVectorizedRowBatch(3, 2, seed);
vrb.cols[0] = new BytesColumnVector();
BytesColumnVector bcv = (BytesColumnVector) vrb.cols[0];
bcv.initBuffer();
bcv.setVal(0, a, 0, 1);
bcv.setVal(1, b, 0, 1);
bcv.setVal(2, c, 0, 1);
VectorExpression expr = new FilterStringColumnNotBetween(0, b, c);
expr.evaluate(vrb);
assertEquals(1, vrb.size);
assertTrue(vrb.selectedInUse);
assertEquals(0, vrb.selected[0]);
}
Aggregations