to = new UnionVector(name, allocator, callBack); internalStructVectorTransferPair = internalStruct.makeTransferPair(to.internalStruct);
public MinorType getMinorType() { return TYPES[data.getTypeValue(idx())]; }
@Override public void clear() { data.clear(); }
/** Helper method which creates a union vector with no data */ private static UnionVector testEmptyUnionVector() { final UnionVector unionVector = new UnionVector("unionVector", ALLOCATOR, null); unionVector.initializeChildrenFromFields( asList( Field.nullable("intType", new ArrowType.Int(32, true)), Field.nullable("decimalType", new ArrowType.Decimal(4, 10)) ) ); return unionVector; }
private static Pair<UnionVector, ResultVerifier> testUnionVector(final int startIndexInCurrentOutput, final int startIndexInJob) { UnionVector colUnionV = new UnionVector("colUnion", allocator, null); unionWriter.writeVarChar(0, varCharVal.length, tempBuf); colUnionV.setValueCount(5);
private FieldWriter promoteToUnion() { String name = vector.getField().getName(); TransferPair tp = vector.getTransferPair(vector.getMinorType().name().toLowerCase(), vector.getAllocator()); tp.transfer(); if (parentContainer != null) { // TODO allow dictionaries in complex types unionVector = parentContainer.addOrGetUnion(name); unionVector.allocateNew(); } else if (listVector != null) { unionVector = listVector.promoteToUnion(); } unionVector.addVector((FieldVector) tp.getTo()); writer = new UnionWriter(unionVector, nullableStructWriterFactory); writer.setPosition(idx()); for (int i = 0; i <= idx(); i++) { unionVector.setType(i, vector.getMinorType()); } vector = null; state = State.UNION; return writer; }
public void materialize(Field field) { for (Field child : field.getChildren()) { FieldVector v = TypeHelper.getNewVector(child, unionVector.getAllocator()); ComplexTypeHelper.materialize(v, child); unionVector.addVector(v); } }
public SerializedField getMetadata() { SerializedField.Builder b = SerializedField.newBuilder() .setNamePart(NamePart.newBuilder().setName(unionVector.getField().getName())) .setMajorType(Types.optional(MinorType.UNION)) .setBufferLength(unionVector.getBufferSize()) .setValueCount(unionVector.valueCount); b.addChild(buildTypeField()); b.addChild(TypeHelper.getMetadata(unionVector.internalStruct)); return b.build(); }
@Override public Field getField() { return data.getField(); }
public UnionSqlAccessor(UnionVector vector) { reader = vector.getReader(); }
@Override public void splitAndTransfer(int startIndex, int length) { to.clear(); internalStructVectorTransferPair.splitAndTransfer(startIndex, length); final int startPoint = startIndex * TYPE_WIDTH; final int sliceLength = length * TYPE_WIDTH; to.typeBuffer = typeBuffer.slice(startPoint, sliceLength).transferOwnership(to.allocator).buffer; to.setValueCount(length); }
UnionVector unionVector = new UnionVector(field.getName(), allocator, callBack); if(!children.isEmpty()){ unionVector.initializeChildrenFromFields(children);
@Override public Field getField() { return data.getField(); }
@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); }
@Override public void writeValue() throws IOException { consumer.startGroup(); int type = unionReader.data.getTypeValue(unionReader.getPosition()); Types.MinorType minorType = Types.MinorType.values()[type]; converterMap.get(minorType.name().toLowerCase()).writeField(); consumer.endGroup(); }
public void load(UserBitShared.SerializedField metadata, ArrowBuf buffer) { /* clear the current buffers (if any) */ unionVector.clear(); unionVector.valueCount = metadata.getValueCount(); int typesLength = metadata.getChild(0).getBufferLength(); int mapLength = metadata.getChild(1).getBufferLength(); loadTypeBuffer(metadata.getChild(0), buffer); TypeHelper.load(unionVector.internalStruct, metadata.getChild(1), buffer.slice(typesLength, mapLength)); }
@Override public UnionVector promoteToUnion() { UnionVector vector = new UnionVector(name, allocator, null); this.vector.clear(); this.vector = vector; this.reader = new UnionFixedSizeListReader(this); return vector; }
@Override public DataType extractType(String column, int index){ Pair<RecordBatchData, Integer> dataBatch = find(index); Column columnDef = getColumn(column); ValueVector vv = dataBatch.getKey().getVectors().get(columnDef.getIndex()); if (columnDef.getType() == DataType.MIXED) { final int typeValue = ((UnionVector)vv).getTypeValue(dataBatch.getValue()); return DataTypeUtil.getDataType(getMinorTypeFromArrowMinorType(MinorType.values()[typeValue])); } return columnDef.getType(); }
@Override public UnionVector promoteToUnion() { UnionVector vector = new UnionVector("$data$", allocator, callBack); replaceDataVector(vector); reader = new UnionListReader(this); if (callBack != null) { callBack.doWork(); } return vector; }