@SuppressWarnings("unchecked")
  private void testListLong() throws HiveException {
    LongColumnVector icv = VectorizedRowGroupGenUtil.generateLongColumnVector(true, false,
        5, new Random(10));
    ListColumnVector cv = new ListColumnVector(3, icv);
    cv.init();

    // set the offset and length for the two elements
    cv.offsets[0] = 0;
    cv.lengths[0] = 2;
    cv.offsets[1] = 2;
    cv.lengths[1] = 3;

    // initialize the integer values
    for (int i = 0; i < 5; i++) {
      icv.vector[i] = i;
      icv.isNull[i] = false;
    }
    icv.noNulls = true;

    cv.isNull[0] = false;
    cv.isNull[1] = false;
    cv.isNull[2] = true;
    cv.noNulls = false;

    SettableListObjectInspector listOI =
        ObjectInspectorFactory.getStandardListObjectInspector(
            PrimitiveObjectInspectorFactory.writableIntObjectInspector);

    VectorExpressionWriter vew = VectorExpressionWriterFactory.genVectorExpressionWritable(listOI);

    List<Object> values1 = (List<Object>) listOI.create(2);
    vew.setValue(values1, cv, 0);

    List<Object> values2 = (List<Object>) listOI.create(3);
    vew.setValue(values2, cv, 1);

    TestCase.assertEquals(values1.size(), 2);
    TestCase.assertEquals(values2.size(), 3);

    for (int i = 0; i < values1.size(); i++) {
      IntWritable w = (IntWritable) values1.get(i);
      TestCase.assertEquals(i, w.get());
    }

    for (int i = 0; i < values2.size(); i++) {
      IntWritable w = (IntWritable) values2.get(i);
      TestCase.assertEquals(2 + i, w.get());
    }

    List<Object> values3 = (List<Object>) vew.writeValue(cv, 0);
    TestCase.assertEquals(2, values3.size());
    for (int i = 0; i < values1.size(); i++) {
      IntWritable w = (IntWritable) values3.get(i);
      TestCase.assertEquals(i, w.get());
    }

    List<Object> values4 = (List<Object>) vew.writeValue(cv, 1);
    TestCase.assertEquals(3, values4.size());
    for (int i = 0; i < values2.size(); i++) {
      IntWritable w = (IntWritable) values4.get(i);
      TestCase.assertEquals(2 + i, w.get());
    }

    List<Object> values5 = (List<Object>) vew.writeValue(cv, 2);
    TestCase.assertNull(values5);
  }
Unit tests for vector expression writers.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorExpressionWriters.java