@SuppressWarnings("unchecked")
  private void testMapLong() throws HiveException {
    LongColumnVector kcv = VectorizedRowGroupGenUtil.generateLongColumnVector(true, false,
        5, new Random(10));
    LongColumnVector vcv = VectorizedRowGroupGenUtil.generateLongColumnVector(true, false,
        5, new Random(10));
    MapColumnVector cv = new MapColumnVector(3, kcv, vcv);
    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 keys and values
    for (int i = 0; i < 5; i++) {
      kcv.vector[i] = i;
      kcv.isNull[i] = false;
    }
    kcv.noNulls = true;

    for (int i = 0; i < 5; i++) {
      vcv.vector[i] = 5 + i;
      vcv.isNull[i] = false;
    }
    vcv.noNulls = true;

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

    SettableMapObjectInspector mapOI =
        ObjectInspectorFactory.getStandardMapObjectInspector(
            PrimitiveObjectInspectorFactory.writableIntObjectInspector,
            PrimitiveObjectInspectorFactory.writableIntObjectInspector);

    VectorExpressionWriter vew = VectorExpressionWriterFactory.genVectorExpressionWritable(mapOI);

    Map<Object, Object> values1 = (Map<Object, Object>) mapOI.create();
    vew.setValue(values1, cv, 0);

    Map<Object, Object> values2 = (Map<Object, Object>) mapOI.create();
    vew.setValue(values2, cv, 1);

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

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

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

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

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

    Map<Object, Object> values5 = (Map<Object, 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