Exemplo n.º 1
0
 public int getField(FlatBufferBuilder builder) {
   int nameOffset = name == null ? -1 : builder.createString(name);
   int typeOffset = type.getType(builder);
   int[] childrenData = new int[children.size()];
   for (int i = 0; i < children.size(); i++) {
     childrenData[i] = children.get(i).getField(builder);
   }
   int childrenOffset = org.apache.arrow.flatbuf.Field.createChildrenVector(builder, childrenData);
   int[] buffersData = new int[typeLayout.getVectors().size()];
   for (int i = 0; i < buffersData.length; i++) {
     VectorLayout vectorLayout = typeLayout.getVectors().get(i);
     buffersData[i] = vectorLayout.writeTo(builder);
   }
   int layoutOffset = org.apache.arrow.flatbuf.Field.createLayoutVector(builder, buffersData);
   org.apache.arrow.flatbuf.Field.startField(builder);
   if (name != null) {
     org.apache.arrow.flatbuf.Field.addName(builder, nameOffset);
   }
   org.apache.arrow.flatbuf.Field.addNullable(builder, nullable);
   org.apache.arrow.flatbuf.Field.addTypeType(builder, type.getTypeID().getFlatbufID());
   org.apache.arrow.flatbuf.Field.addType(builder, typeOffset);
   org.apache.arrow.flatbuf.Field.addChildren(builder, childrenOffset);
   org.apache.arrow.flatbuf.Field.addLayout(builder, layoutOffset);
   return org.apache.arrow.flatbuf.Field.endField(builder);
 }
Exemplo n.º 2
0
 public static Field convertField(org.apache.arrow.flatbuf.Field field) {
   String name = field.name();
   boolean nullable = field.nullable();
   ArrowType type = getTypeForField(field);
   ImmutableList.Builder<org.apache.arrow.vector.schema.VectorLayout> layout =
       ImmutableList.builder();
   for (int i = 0; i < field.layoutLength(); ++i) {
     layout.add(new org.apache.arrow.vector.schema.VectorLayout(field.layout(i)));
   }
   ImmutableList.Builder<Field> childrenBuilder = ImmutableList.builder();
   for (int i = 0; i < field.childrenLength(); i++) {
     childrenBuilder.add(convertField(field.children(i)));
   }
   List<Field> children = childrenBuilder.build();
   Field result = new Field(name, nullable, type, children, new TypeLayout(layout.build()));
   return result;
 }