LBSerializer createLBSerializer(ObjectInspector oi) {
    switch (oi.getCategory()) {
    case PRIMITIVE:
      PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
      return createPrimitiveLBSerializer(poi);
    case LIST:
      ListObjectInspector loi = (ListObjectInspector) oi;
      ObjectInspector eoi = loi.getListElementObjectInspector();
      return new LBListSerializer(createLBSerializer(eoi));
    case MAP:
      MapObjectInspector moi = (MapObjectInspector) oi;
      ObjectInspector koi = moi.getMapKeyObjectInspector();
      ObjectInspector voi = moi.getMapValueObjectInspector();
      return new LBMapSerializer(createLBSerializer(koi), createLBSerializer(voi));
    case STRUCT:
      StructObjectInspector soi = (StructObjectInspector) oi;
      List<? extends StructField> fields = soi.getAllStructFieldRefs();
      LBSerializer[] fieldSerializers = new LBSerializer[fields.size()];
      for (int idx = 0; idx < fieldSerializers.length; ++idx) {
        fieldSerializers[idx] = createLBSerializer(fields.get(idx).getFieldObjectInspector());
      }
      return new LBStructSerializer(fieldSerializers);
    case UNION:
      UnionObjectInspector uoi = (UnionObjectInspector) oi;
      List<ObjectInspector> unionFields = uoi.getObjectInspectors();
      LBSerializer[] unionFieldSerializers = new LBSerializer[unionFields.size()];
      for (int idx = 0; idx < unionFieldSerializers.length; ++idx) {
        unionFieldSerializers[idx] = createLBSerializer(unionFields.get(idx));
      }
      return new LBUnionSerializer(unionFieldSerializers);
    default:
      throw new IllegalArgumentException("Unsupported category " + oi.getCategory());
    }
  }
Generate a LBSerializer for the given ObjectInspector
@param oi
@return
serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe2.java