public static void addRandomNulls(VectorizedRowBatch batch) { for (int i = 0; i != batch.numCols; i++) { addRandomNulls(batch.cols[i]); } }
public void addSampleNulls(VectorizedRowBatch batch) { for (int i = 0; i != batch.numCols; i++) { addSampleNulls(batch.cols[i]); } }
/** * Set vector elements to sample string data from colorsBytes string table. * @param col */ public static void setSampleStringCol(BytesColumnVector col) { initColors(); int size = col.vector.length; for(int i = 0; i != size; i++) { int pos = i % colorsBytes.length; col.setRef(i, colorsBytes[pos], 0, colorsBytes[pos].length); } }
private VectorizedRowBatch makeBatch() { VectorizedRowBatch batch = new VectorizedRowBatch(3); LongColumnVector lv = new LongColumnVector(); DoubleColumnVector dv = new DoubleColumnVector(); BytesColumnVector bv = new BytesColumnVector(); setSampleStringCol(bv); batch.cols[0] = lv; batch.cols[1] = dv; batch.cols[2] = bv; addRandomNulls(batch); return batch; }
private LongColumnVector getLongVector(int len) { LongColumnVector lcv = new LongColumnVector(len); TestVectorizedRowBatch.setRandomLongCol(lcv); return lcv; } }
public static void setSample(VectorizedRowBatch batch) { batch.size = VectorizedRowBatch.DEFAULT_SIZE; for (int i = 0; i != batch.numCols; i++) { setSampleLongCol((LongColumnVector) batch.cols[i]); } }
@Test /** * Make sure you can create a batch and that all columns are the * default size. */ public void testVectorizedRowBatchCreate() { VectorizedRowBatch batch = makeBatch(); Assert.assertEquals(3, batch.numCols); Assert.assertEquals(VectorizedRowBatch.DEFAULT_SIZE, batch.size); Assert.assertEquals(((LongColumnVector) batch.cols[0]).vector.length, VectorizedRowBatch.DEFAULT_SIZE); Assert.assertEquals(((DoubleColumnVector) batch.cols[1]).vector.length, VectorizedRowBatch.DEFAULT_SIZE); Assert.assertEquals(((BytesColumnVector) batch.cols[2]).vector.length, VectorizedRowBatch.DEFAULT_SIZE); }
@Test public void testFlatten() { verifyFlatten(new LongColumnVector()); verifyFlatten(new DoubleColumnVector()); verifyFlatten(new BytesColumnVector()); }
public static void setRandom(VectorizedRowBatch batch) { batch.size = VectorizedRowBatch.DEFAULT_SIZE; for (int i = 0; i != batch.numCols; i++) { batch.cols[i] = new LongColumnVector(VectorizedRowBatch.DEFAULT_SIZE); setRandomLongCol((LongColumnVector) batch.cols[i]); } }
/** * Set to sample data, re-using existing columns in batch. * * @param batch */ public static void setSampleOverwrite(VectorizedRowBatch batch) { // Put sample data in the columns. for (int i = 0; i != batch.numCols; i++) { setSampleLongCol((LongColumnVector) batch.cols[i]); } // Reset the selection vector. batch.selectedInUse = false; batch.size = VectorizedRowBatch.DEFAULT_SIZE; }
@Test public void testLongScalarSubtractLongColWithNulls() throws HiveException { VectorizedRowBatch batch = getVectorizedRowBatchSingleLongVector( VectorizedRowBatch.DEFAULT_SIZE); LongColumnVector lcv = (LongColumnVector) batch.cols[0]; TestVectorizedRowBatch.addRandomNulls(lcv); LongScalarSubtractLongColumn expr = new LongScalarSubtractLongColumn(100, 0, 1); expr.evaluate(batch); //verify for (int i=0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) { if (!lcv.isNull[i]) { Assert.assertEquals(100 - i * 37, ((LongColumnVector)batch.cols[1]).vector[i]); } else { Assert.assertTrue(((LongColumnVector)batch.cols[1]).isNull[i]); } } Assert.assertFalse(((LongColumnVector)batch.cols[1]).noNulls); Assert.assertFalse(((LongColumnVector)batch.cols[1]).isRepeating); TestVectorArithmeticExpressions.verifyLongNullDataVectorEntries( (LongColumnVector) batch.cols[1], batch.selected, batch.selectedInUse, batch.size); }
private void longColAddLongScalarCheckedWithNulls(boolean isChecked) throws HiveException { VectorizedRowBatch batch = getVectorizedRowBatchSingleLongVector( VectorizedRowBatch.DEFAULT_SIZE); LongColumnVector lcv = (LongColumnVector) batch.cols[0]; LongColumnVector lcvOut = (LongColumnVector) batch.cols[1]; TestVectorizedRowBatch.addRandomNulls(lcv); VectorExpression expr; if (isChecked) { expr = new LongColAddLongScalarChecked(0, 23, 1); expr.setOutputTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("bigint")); } else { expr = new LongColAddLongScalar(0, 23, 1); } expr.evaluate(batch); // verify for (int i=0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) { if (!lcv.isNull[i]) { Assert.assertEquals(i*37+23, lcvOut.vector[i]); } else { Assert.assertTrue(lcvOut.isNull[i]); } } Assert.assertFalse(lcvOut.noNulls); Assert.assertFalse(lcvOut.isRepeating); verifyLongNullDataVectorEntries(lcvOut, batch.selected, batch.selectedInUse, batch.size); }
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFYear(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFYear(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFMinute(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFMinute(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFMinute(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFMinute(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFMinute(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFMinute(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFMinute(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFSecond(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFSecond(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFSecond(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFSecond(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFSecond(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFSecond(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFSecond(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFHour(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFHour(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFHour(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFHour(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFHour(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFHour(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFHour(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFUnixTimeStamp(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFUnixTimeStamp(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFUnixTimeStamp(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFUnixTimeStamp(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFUnixTimeStamp(batch, testType); batch = getVectorizedRandomRowBatch(200, VectorizedRowBatch.DEFAULT_SIZE, testType); verifyUDFUnixTimeStamp(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFUnixTimeStamp(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFUnixTimeStamp(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFDayOfMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFDayOfMonth(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFDayOfMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFDayOfMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFDayOfMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFDayOfMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFDayOfMonth(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFMonth(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFMonth(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFMonth(batch, testType);
Assert.assertFalse(((LongColumnVector) batch.cols[1]).isRepeating); verifyUDFWeekOfYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFWeekOfYear(batch, testType); batch = getVectorizedRowBatch(boundaries, boundaries.length, testType); verifyUDFWeekOfYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFWeekOfYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFWeekOfYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[0]); verifyUDFWeekOfYear(batch, testType); TestVectorizedRowBatch.addRandomNulls(batch.cols[1]); verifyUDFWeekOfYear(batch, testType);