@Test
  public void testLazyHBaseRow2() throws SerDeException {
    // column family is mapped to Map<string,string>
    List<TypeInfo> fieldTypeInfos =
      TypeInfoUtils.getTypeInfosFromTypeString(
        "string,int,array<string>,map<string,string>,string");
    List<String> fieldNames = Arrays.asList(
      new String[]{"key", "a", "b", "c", "d"});
    Text nullSequence = new Text("\\N");
    String hbaseColsMapping = ":key,cfa:a,cfa:b,cfb:,cfc:d";

    ColumnMappings columnMappings = null;

    try {
      columnMappings = HBaseSerDe.parseColumnsMapping(hbaseColsMapping);
    } catch (SerDeException e) {
      fail(e.toString());
    }

    for (ColumnMapping colMap : columnMappings) {
      if (!colMap.hbaseRowKey && colMap.qualifierName == null) {
        colMap.binaryStorage.add(false);
        colMap.binaryStorage.add(false);
      } else {
        colMap.binaryStorage.add(false);
      }
    }

    ObjectInspector oi = LazyFactory.createLazyStructInspector(
      fieldNames,
      fieldTypeInfos,
      new byte[] {' ', ':', '='},
      nullSequence, false, false, (byte) 0);
    LazyHBaseRow o = new LazyHBaseRow((LazySimpleStructObjectInspector) oi, columnMappings);

    List<Cell> kvs = new ArrayList<Cell>();
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("a"), Bytes.toBytes("123")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("b"), Bytes.toBytes("a:b:c")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfb"), Bytes.toBytes("d"), Bytes.toBytes("e")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfb"), Bytes.toBytes("f"), Bytes.toBytes("g")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfc"), Bytes.toBytes("d"), Bytes.toBytes("hi")));

    Result r = Result.create(kvs);
    o.init(r);

    assertEquals(
      ("{'key':'test-row','a':123,'b':['a','b','c'],"
        + "'c':{'d':'e','f':'g'},'d':'hi'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    kvs.clear();
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("a"), Bytes.toBytes("123")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfb"), Bytes.toBytes("d"), Bytes.toBytes("e")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfb"), Bytes.toBytes("f"), Bytes.toBytes("g")));

    r = Result.create(kvs);
    o.init(r);

    assertEquals(
      ("{'key':'test-row','a':123,'b':null,"
        + "'c':{'d':'e','f':'g'},'d':null}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    kvs.clear();
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("b"), Bytes.toBytes("a")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfb"), Bytes.toBytes("f"), Bytes.toBytes("g")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfc"), Bytes.toBytes("d"), Bytes.toBytes("no")));

    r = Result.create(kvs);
    o.init(r);

    assertEquals(
      ("{'key':'test-row','a':null,'b':['a'],"
        + "'c':{'f':'g'},'d':'no'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    kvs.clear();
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("b"), Bytes.toBytes(":a::")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfc"), Bytes.toBytes("d"), Bytes.toBytes("no")));

    r = Result.create(kvs);
    o.init(r);

    assertEquals(
      ("{'key':'test-row','a':null,'b':['','a','',''],"
        + "'c':{},'d':'no'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    kvs.clear();
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("a"), Bytes.toBytes("123")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfa"), Bytes.toBytes("b"), Bytes.toBytes("")));
    kvs.add(new KeyValue(Bytes.toBytes("test-row"),
        Bytes.toBytes("cfc"), Bytes.toBytes("d"), Bytes.toBytes("")));

    r = Result.create(kvs);
    o.init(r);

    assertEquals(
      "{'key':'test-row','a':123,'b':[],'c':{},'d':''}".replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));
  }
Test the LazyHBaseRow class with a mapping from a Hive field to
an HBase column family.
@throws SerDeException
hbase-handler/src/test/org/apache/hadoop/hive/hbase/TestLazyHBaseObject.java