final ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; final TypeInfo elementTypeInfo = listTypeInfo.getListElementTypeInfo(); return new Field(name, FieldType.nullable(MinorType.LIST.getType()), Lists.newArrayList(toField(DEFAULT_ARROW_FIELD_NAME, elementTypeInfo))); case STRUCT: structFields.add(toField(fieldNames.get(i), fieldTypeInfos.get(i))); return new Field(name, FieldType.nullable(MinorType.STRUCT.getType()), structFields); case UNION: final UnionTypeInfo unionTypeInfo = (UnionTypeInfo) typeInfo; unionFields.add(toField(DEFAULT_ARROW_FIELD_NAME, objectTypeInfos.get(i))); return new Field(name, FieldType.nullable(MinorType.UNION.getType()), unionFields); case MAP: final MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo;
private static FieldType toFieldType(TypeInfo typeInfo) { return new FieldType(true, toArrowType(typeInfo), null); }
public ArrowType getType() { return fieldType.getType(); }
public FixedSizeListVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack schemaChangeCallback) { super(name, allocator); this.validityBuffer = allocator.getEmpty(); this.vector = ZeroVector.INSTANCE; this.fieldType = fieldType; this.listSize = ((ArrowType.FixedSizeList) fieldType.getType()).getListSize(); Preconditions.checkArgument(listSize > 0, "list size must be positive"); this.reader = new UnionFixedSizeListReader(this); this.valueCount = 0; this.validityAllocationSizeInBytes = getValidityBufferSizeFromCount(INITIAL_VALUE_ALLOCATION); }
@Override public Field getField() { Field f = super.getField(); FieldType type = new FieldType(true, f.getType(), f.getFieldType().getDictionary(), f.getFieldType().getMetadata()); return new Field(f.getName(), type, f.getChildren()); }
@Override @SuppressWarnings("unchecked") public <T extends ValueVector> AddOrGetResult<T> addOrGetVector(FieldType type) { boolean created = false; if (vector == ZeroVector.INSTANCE) { vector = type.createNewSingleVector(DATA_VECTOR_NAME, allocator, null); this.reader = new UnionFixedSizeListReader(this); created = true; } // returned vector must have the same field if (!Objects.equals(vector.getField().getType(), type.getType())) { final String msg = String.format("Inner vector type mismatch. Requested type: [%s], actual type: [%s]", type.getType(), vector.getField().getType()); throw new SchemaChangeRuntimeException(msg); } return new AddOrGetResult<>((T) vector, created); }
public FieldVector createVector(BufferAllocator allocator) { FieldVector vector = fieldType.createNewSingleVector(name, allocator, null); vector.initializeChildrenFromFields(children); return vector; }
@JsonInclude(Include.NON_NULL) public DictionaryEncoding getDictionary() { return fieldType.getDictionary(); }
public Field(String name, FieldType fieldType, List<Field> children) { this(name, fieldType, children, fieldType == null ? null : TypeLayout.getTypeLayout(fieldType.getType())); }
public <T extends ValueVector> AddOrGetResult<T> addOrGetVector(FieldType fieldType) { boolean created = false; if (vector instanceof ZeroVector) { vector = fieldType.createNewSingleVector(DATA_VECTOR_NAME, allocator, callBack); // returned vector must have the same field created = true; if (callBack != null && // not a schema change if changing from ZeroVector to ZeroVector (fieldType.getType().getTypeID() != ArrowTypeID.Null)) { callBack.doWork(); } } if (vector.getField().getType().getTypeID() != fieldType.getType().getTypeID()) { final String msg = String.format("Inner vector type mismatch. Requested type: [%s], actual type: [%s]", fieldType.getType().getTypeID(), vector.getField().getType().getTypeID()); throw new SchemaChangeRuntimeException(msg); } return new AddOrGetResult<>((T) vector, created); }
protected ValueVector add(String childName, FieldType fieldType) { final ValueVector existing = getChild(childName); if (existing != null) { throw new IllegalStateException(String.format("Vector already exists: Existing[%s], Requested[%s] ", existing.getClass().getSimpleName(), fieldType)); } FieldVector vector = fieldType.createNewSingleVector(childName, allocator, callBack); putChild(childName, vector); if (callBack != null) { callBack.doWork(); } return vector; }
@Override public FieldVector getNewVector( String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { if (fieldType.getDictionary() != null) { throw new UnsupportedOperationException("Dictionary encoding not supported for complex " + "types"); } return new UnionVector(name, allocator, schemaChangeCallback); }
@Deprecated public StructVector(String name, BufferAllocator allocator, CallBack callBack) { this(name, allocator, FieldType.nullable(ArrowType.Struct.INSTANCE), callBack); }
public static FieldType nullable(ArrowType type) { return new FieldType(true, type, null, null); }
/** * Instantiate a FixedSizeBinaryVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param fieldType type of Field materialized by this vector * @param allocator allocator for memory management. */ public FixedSizeBinaryVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, allocator, fieldType, ((FixedSizeBinary) fieldType.getType()).getByteWidth()); reader = new FixedSizeBinaryReaderImpl(FixedSizeBinaryVector.this); byteWidth = ((FixedSizeBinary) fieldType.getType()).getByteWidth(); }
final T vector = clazz.cast(fieldType.createNewSingleVector(childName, allocator, callBack)); putChild(childName, vector); if (callBack != null) {
@Deprecated public ListVector(String name, BufferAllocator allocator, CallBack callBack) { this(name, allocator, FieldType.nullable(ArrowType.List.INSTANCE), callBack); }
@Deprecated public ListVector(String name, BufferAllocator allocator, DictionaryEncoding dictionary, CallBack callBack) { this(name, allocator, new FieldType(true, ArrowType.List.INSTANCE, dictionary, null), callBack); }
/** * Instantiate a TimeStampNanoTZVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param fieldType type of Field materialized by this vector * @param allocator allocator for memory management. */ public TimeStampNanoTZVector(String name, FieldType fieldType, BufferAllocator allocator) { super(name, fieldType, allocator); ArrowType.Timestamp arrowType = (ArrowType.Timestamp) fieldType.getType(); timeZone = arrowType.getTimezone(); reader = new TimeStampNanoTZReaderImpl(TimeStampNanoTZVector.this); }
/** * Instantiate a IntervalYearVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. */ public IntervalYearVector(String name, BufferAllocator allocator) { this(name, FieldType.nullable(MinorType.INTERVALYEAR.getType()), allocator); }