public static boolean hasComplexObjects(
      LazyBinaryStructObjectInspector lazyBinaryStructObjectInspector) {
    List<? extends StructField> fields = lazyBinaryStructObjectInspector.getAllStructFieldRefs();

    for (StructField field : fields) {
      if (field.getFieldObjectInspector().getCategory() != Category.PRIMITIVE) {
        return true;
      }
    }
    return false;
  }
 public LazyBinaryKvWriter(
     SerDe keySerDe, LazyBinaryStructObjectInspector valSoi, boolean hasFilterTag)
     throws SerDeException {
   this.keySerDe = keySerDe;
   if (hasFilterTag) {
     List<? extends StructField> fields = valSoi.getAllStructFieldRefs();
     int ix = fields.size() - 1;
     if (!(fields.get(ix).getFieldObjectInspector() instanceof ShortObjectInspector)) {
       throw new SerDeException(
           "Has filter tag, but corresponding OI is "
               + fields.get(ix).getFieldObjectInspector());
     }
     filterGetter = new LazyBinaryStruct.SingleFieldGetter(valSoi, fields.size() - 1);
   } else {
     filterGetter = null;
   }
 }
  /*
   * For primitive types, use LazyBinary's object.
   * For complex types, make a standard (Java) object from LazyBinary's object.
   */
  public static List<Object> getComplexFieldsAsList(
      LazyBinaryStruct lazyBinaryStruct,
      ArrayList<Object> objectArrayBuffer,
      LazyBinaryStructObjectInspector lazyBinaryStructObjectInspector) {

    List<? extends StructField> fields = lazyBinaryStructObjectInspector.getAllStructFieldRefs();
    for (int i = 0; i < fields.size(); i++) {
      StructField field = fields.get(i);
      ObjectInspector objectInspector = field.getFieldObjectInspector();
      Category category = objectInspector.getCategory();
      Object object = lazyBinaryStruct.getField(i);
      if (category == Category.PRIMITIVE) {
        objectArrayBuffer.set(i, object);
      } else {
        objectArrayBuffer.set(
            i,
            ObjectInspectorUtils.copyToStandardObject(
                object, objectInspector, ObjectInspectorCopyOption.WRITABLE));
      }
    }
    return objectArrayBuffer;
  }