private static VectorExpressionWriter genVectorExpressionWritableStruct(
      SettableStructObjectInspector fieldObjInspector) throws HiveException {

    return new VectorExpressionWriterStruct() {
      private Object obj;
      private VectorExtractRow vectorExtractRow;
      private StructTypeInfo structTypeInfo;

      public VectorExpressionWriter init(SettableStructObjectInspector objInspector)
          throws HiveException {
        super.init(objInspector);
        obj = initValue(null);
        vectorExtractRow = new VectorExtractRow();
        structTypeInfo = (StructTypeInfo)
            TypeInfoUtils.getTypeInfoFromTypeString(objInspector.getTypeName());
        return this;
      }

      @Override
      public Object initValue(Object ignored) {
        return ((SettableStructObjectInspector) this.objectInspector).create();
      }

      @Override
      public Object writeValue(ColumnVector column, int row) throws HiveException {
        return setValueInternal(obj, column, row);
      }

      @Override
      public Object setValue(Object struct, ColumnVector column, int row) throws HiveException {
        if (struct == null) {
          struct = initValue(null);
        }

        return setValueInternal(struct, column, row);
      }

      private Object setValueInternal(final Object struct, ColumnVector colVector, int batchIndex) {
        if (colVector == null) {
          // The planner will not include unneeded columns for reading but other parts of execution
          // may ask for them..
          return null;
        }

        final int adjustedIndex = (colVector.isRepeating ? 0 : batchIndex);
        if (!colVector.noNulls && colVector.isNull[adjustedIndex]) {
          return null;
        }

        final StructColumnVector structColumnVector = (StructColumnVector) colVector;
        final StandardStructObjectInspector structInspector =
            (StandardStructObjectInspector) objectInspector;
        final List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
        final int size = fieldTypeInfos.size();
        final List<? extends StructField> structFields =
            structInspector.getAllStructFieldRefs();

        for (int i = 0; i < size; i++) {
          final StructField structField = structFields.get(i);
          final TypeInfo fieldTypeInfo = fieldTypeInfos.get(i);
          final Object value = vectorExtractRow.extractRowColumn(
              structColumnVector.fields[i],
              fieldTypeInfo,
              structField.getFieldObjectInspector(),
              adjustedIndex);
          structInspector.setStructFieldData(struct, structField, value);
        }
        return struct;
      }
    }.init(fieldObjInspector);
  }
Compiles the appropriate vector expression writers based on a struct object
inspector.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/VectorExpressionWriterFactory.java