ListVector
@Override
public void initializeChildrenFromFields(List<Field> children) {
if (children.size() != 1) {
throw new IllegalArgumentException("Lists have only one child. Found: " + children);
}
Field field = children.get(0);
AddOrGetResult<FieldVector> addOrGetVector = addOrGetVector(field.getFieldType());
if (!addOrGetVector.isCreated()) {
throw new IllegalArgumentException("Child vector already existed: " + addOrGetVector.getVector());
}
addOrGetVector.getVector().initializeChildrenFromFields(field.getChildren());
}
/**
* Get the buffers belonging to this vector.
* @return the inner buffers.
*/
@Override
public List<ArrowBuf> getFieldBuffers() {
List<ArrowBuf> result = new ArrayList<>(2);
setReaderAndWriterIndex();
result.add(validityBuffer);
result.add(offsetBuffer);
return result;
}
MapVector
@Override
public void initializeChildrenFromFields(List<Field> children) {
checkArgument(children.size() == 1, "Maps have one List child. Found: %s", children);
Field structField = children.get(0);
MinorType minorType = Types.getMinorTypeForArrowType(structField.getType());
checkArgument(minorType == MinorType.STRUCT && !structField.isNullable(),
"Map data should be a non-nullable struct type");
checkArgument(structField.getChildren().size() == 2,
"Map data should be a struct with 2 children. Found: %s", children);
Field keyField = structField.getChildren().get(0);
checkArgument(!keyField.isNullable(), "Map data key type should be a non-nullable");
AddOrGetResult<FieldVector> addOrGetVector = addOrGetVector(structField.getFieldType());
checkArgument(addOrGetVector.isCreated(), "Child vector already existed: %s", addOrGetVector.getVector());
addOrGetVector.getVector().initializeChildrenFromFields(structField.getChildren());
}
|