private void verifyFlatten(ColumnVector v) {

    // verify that flattening and unflattenting no-nulls works
    v.noNulls = true;
    v.isNull[1] = true;
    int[] sel = {0, 2};
    int size = 2;
    v.flatten(true, sel, size);
    Assert.assertFalse(v.noNulls);
    Assert.assertFalse(v.isNull[0] || v.isNull[2]);
    v.unFlatten();
    Assert.assertTrue(v.noNulls);

    // verify that flattening and unflattening "isRepeating" works
    v.isRepeating = true;
    v.noNulls = false;
    v.isNull[0] = true;
    v.flatten(true, sel, 2);
    Assert.assertFalse(v.noNulls);
    Assert.assertTrue(v.isNull[0] && v.isNull[2]);
    Assert.assertFalse(v.isRepeating);
    v.unFlatten();
    Assert.assertFalse(v.noNulls);
    Assert.assertTrue(v.isRepeating);

    // verify extension of values in the array
    v.noNulls = true;
    if (v instanceof LongColumnVector) {
      ((LongColumnVector) v).vector[0] = 100;
      v.flatten(true, sel, 2);
      Assert.assertTrue(((LongColumnVector) v).vector[2] == 100);
    } else if (v instanceof DoubleColumnVector) {
      ((DoubleColumnVector) v).vector[0] = 200d;
      v.flatten(true, sel, 2);
      Assert.assertTrue(((DoubleColumnVector) v).vector[2] == 200d);
    } else if (v instanceof BytesColumnVector) {
      BytesColumnVector bv = (BytesColumnVector) v;
      byte[] b = null;
      try {
        b = "foo".getBytes("UTF-8");
      } catch (Exception e) {
        ; // eat it
      }
      bv.setRef(0, b, 0, b.length);
      bv.flatten(true, sel, 2);
      Assert.assertEquals(bv.vector[0],  bv.vector[2]);
      Assert.assertEquals(bv.start[0], bv.start[2]);
      Assert.assertEquals(bv.length[0], bv.length[2]);
    }
  }
Set the vector to random data in the range 0 to 99.
This has significant overhead for random number generation. Use setSample() to reduce overhead.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorizedRowBatch.java