protected static void writeStruct()

in athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/BlockUtils.java [560:601]


    protected static void writeStruct(BufferAllocator allocator,
            StructWriter writer,
            Field field,
            int pos,
            Object value,
            FieldResolver resolver)
    {
        //We expect null writes to have been handled earlier so this is a no-op.
        if (value == null) {
            return;
        }

        //Indicate the beginning of the struct value, this is how Apache Arrow handles the variable length of Struct types.
        writer.start();
        for (Field nextChild : field.getChildren()) {
            //For each child field that comprises the struct, attempt to extract and write the corresponding value
            //using the FieldResolver.
            Object childValue = resolver.getFieldValue(nextChild, value);
            switch (Types.getMinorTypeForArrowType(nextChild.getType())) {
                case LIST:
                    writeList(allocator,
                            (FieldWriter) writer.list(nextChild.getName()),
                            nextChild,
                            pos,
                            ((List) childValue).iterator(),
                            resolver);
                    break;
                case STRUCT:
                    writeStruct(allocator,
                            writer.struct(nextChild.getName()),
                            nextChild,
                            pos,
                            childValue,
                            resolver);
                    break;
                default:
                    writeStructValue(writer, nextChild, allocator, childValue);
                    break;
            }
        }
        writer.end();
    }