Java Code Examples for org.apache.arrow.vector.complex.ListVector#addOrGetVector()
The following examples show how to use
org.apache.arrow.vector.complex.ListVector#addOrGetVector() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrowFixedSchemaMemoryAllocatorFactory.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
public static IMemoryAllocator getFromListVector( final IField schema , final String columnName , final BufferAllocator allocator , final ListVector vector , final int rowCount ) throws IOException{ switch( schema.getFieldType() ){ case UNION: return NullMemoryAllocator.INSTANCE; case ARRAY: AddOrGetResult<ListVector> listVector = vector.addOrGetVector( new FieldType( true , ArrowType.List.INSTANCE , null , null ) ); return new ArrowFixedSchemaArrayMemoryAllocator( (ArrayContainerField)schema , allocator , listVector.getVector() , rowCount ); case MAP: AddOrGetResult<StructVector> mapVector = vector.addOrGetVector( new FieldType( true , ArrowType.Struct.INSTANCE , null , null ) ); return new ArrowFixedSchemaMapMemoryAllocator( (MapContainerField)schema , allocator , mapVector.getVector() , rowCount ); case STRUCT: AddOrGetResult<StructVector> structVector = vector.addOrGetVector( new FieldType( true , ArrowType.Struct.INSTANCE , null , null ) ); return new ArrowFixedSchemaStructMemoryAllocator( (StructContainerField)schema , allocator , structVector.getVector() , rowCount ); case BOOLEAN: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.BOOLEAN , columnName , allocator , vector , rowCount ); case BYTE: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.BYTE , columnName , allocator , vector , rowCount ); case SHORT: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.SHORT , columnName , allocator , vector , rowCount ); case INTEGER: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.INTEGER , columnName , allocator , vector , rowCount ); case LONG: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.LONG , columnName , allocator , vector , rowCount ); case FLOAT: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.FLOAT , columnName , allocator , vector , rowCount ); case DOUBLE: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.DOUBLE , columnName , allocator , vector , rowCount ); case STRING: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.STRING , columnName , allocator , vector , rowCount ); case BYTES: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.BYTES , columnName , allocator , vector , rowCount ); default: return NullMemoryAllocator.INSTANCE; } }
Example 2
Source File: ArrowFixedSchemaMemoryAllocatorFactory.java From yosegi with Apache License 2.0 | 4 votes |
/** * Function to convert to IMemoryAllocator for List vector. */ public static IMemoryAllocator getFromListVector( final IField schema , final String columnName , final BufferAllocator allocator , final ListVector vector , final int rowCount ) throws IOException { switch ( schema.getFieldType() ) { case UNION: return NullMemoryAllocator.INSTANCE; case ARRAY: AddOrGetResult<ListVector> listVector = vector.addOrGetVector( new FieldType( true , ArrowType.List.INSTANCE , null , null ) ); return new ArrowFixedSchemaArrayMemoryAllocator( (ArrayContainerField)schema , allocator , listVector.getVector() , rowCount ); case MAP: AddOrGetResult<StructVector> mapVector = vector.addOrGetVector( new FieldType( true , ArrowType.Struct.INSTANCE , null , null ) ); return new ArrowFixedSchemaMapMemoryAllocator( (MapContainerField)schema , allocator , mapVector.getVector() , rowCount ); case STRUCT: AddOrGetResult<StructVector> structVector = vector.addOrGetVector( new FieldType( true , ArrowType.Struct.INSTANCE , null , null ) ); return new ArrowFixedSchemaStructMemoryAllocator( (StructContainerField)schema , allocator , structVector.getVector() , rowCount ); case BOOLEAN: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.BOOLEAN , columnName , allocator , vector , rowCount ); case BYTE: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.BYTE , columnName , allocator , vector , rowCount ); case SHORT: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.SHORT , columnName , allocator , vector , rowCount ); case INTEGER: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.INTEGER , columnName , allocator , vector , rowCount ); case LONG: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.LONG , columnName , allocator , vector , rowCount ); case FLOAT: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.FLOAT , columnName , allocator , vector , rowCount ); case DOUBLE: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.DOUBLE , columnName , allocator , vector , rowCount ); case STRING: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.STRING , columnName , allocator , vector , rowCount ); case BYTES: return ArrowMemoryAllocatorFactory.getFromListVector( ColumnType.BYTES , columnName , allocator , vector , rowCount ); default: return NullMemoryAllocator.INSTANCE; } }
Example 3
Source File: ArrowMemoryAllocatorFactory.java From yosegi with Apache License 2.0 | 4 votes |
/** * Set the vector of List and initialize it. */ public static IMemoryAllocator getFromListVector( final ColumnType columnType , final String columnName , final BufferAllocator allocator , final ListVector vector , final int rowCount ) { switch ( columnType ) { case UNION: AddOrGetResult<UnionVector> unionVector = vector.addOrGetVector( new FieldType( true , MinorType.UNION.getType() , null , null ) ); return new ArrowUnionMemoryAllocator( allocator , unionVector.getVector() , rowCount ); case ARRAY: AddOrGetResult<ListVector> listVector = vector.addOrGetVector( new FieldType( true , ArrowType.List.INSTANCE , null , null ) ); return new ArrowArrayMemoryAllocator( allocator , listVector.getVector() , rowCount ); case SPREAD: AddOrGetResult<StructVector> mapVector = vector.addOrGetVector( new FieldType( true , ArrowType.Struct.INSTANCE , null , null ) ); return new ArrowMapMemoryAllocator( allocator , mapVector.getVector() , rowCount ); case BOOLEAN: AddOrGetResult<BitVector> bitVector = vector.addOrGetVector( new FieldType( true , ArrowType.Bool.INSTANCE , null , null ) ); return new ArrowBooleanMemoryAllocator( bitVector.getVector() , rowCount ); case BYTE: AddOrGetResult<TinyIntVector> byteVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 8 , true ) , null , null ) ); return new ArrowByteMemoryAllocator( byteVector.getVector() , rowCount ); case SHORT: AddOrGetResult<SmallIntVector> shortVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 16 , true ) , null , null ) ); return new ArrowShortMemoryAllocator( shortVector.getVector() , rowCount ); case INTEGER: AddOrGetResult<IntVector> integerVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 32 , true ) , null , null ) ); return new ArrowIntegerMemoryAllocator( integerVector.getVector() , rowCount ); case LONG: AddOrGetResult<BigIntVector> longVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 64 , true ) , null , null ) ); return new ArrowLongMemoryAllocator( longVector.getVector() , rowCount ); case FLOAT: AddOrGetResult<Float4Vector> floatVector = vector.addOrGetVector( new FieldType( true , new ArrowType.FloatingPoint( FloatingPointPrecision.HALF ) , null , null ) ); return new ArrowFloatMemoryAllocator( floatVector.getVector() , rowCount ); case DOUBLE: AddOrGetResult<Float8Vector> doubleVector = vector.addOrGetVector( new FieldType( true , new ArrowType.FloatingPoint( FloatingPointPrecision.DOUBLE ) , null , null ) ); return new ArrowDoubleMemoryAllocator( doubleVector.getVector() , rowCount ); case STRING: AddOrGetResult<VarCharVector> charVector = vector.addOrGetVector( new FieldType( true , ArrowType.Utf8.INSTANCE , null , null ) ); return new ArrowStringMemoryAllocator( charVector.getVector() , rowCount ); case BYTES: AddOrGetResult<VarBinaryVector> binaryVector = vector.addOrGetVector( new FieldType( true , ArrowType.Binary.INSTANCE , null , null ) ); return new ArrowBytesMemoryAllocator( binaryVector.getVector() , rowCount ); case NULL: case EMPTY_ARRAY: case EMPTY_SPREAD: default: return NullMemoryAllocator.INSTANCE; } }
Example 4
Source File: ArrowMemoryAllocatorFactory.java From multiple-dimension-spread with Apache License 2.0 | 4 votes |
public static IMemoryAllocator getFromListVector( final ColumnType columnType , final String columnName , final BufferAllocator allocator , final ListVector vector , final int rowCount ){ switch( columnType ){ case UNION: AddOrGetResult<UnionVector> unionVector = vector.addOrGetVector( new FieldType( true , MinorType.UNION.getType() , null , null ) ); return new ArrowUnionMemoryAllocator( allocator , unionVector.getVector() , rowCount ); case ARRAY: AddOrGetResult<ListVector> listVector = vector.addOrGetVector( new FieldType( true , ArrowType.List.INSTANCE , null , null ) ); return new ArrowArrayMemoryAllocator( allocator , listVector.getVector() , rowCount ); case SPREAD: AddOrGetResult<StructVector> mapVector = vector.addOrGetVector( new FieldType( true , ArrowType.Struct.INSTANCE , null , null ) ); return new ArrowMapMemoryAllocator( allocator , mapVector.getVector() , rowCount ); case BOOLEAN: AddOrGetResult<BitVector> bitVector = vector.addOrGetVector( new FieldType( true , ArrowType.Bool.INSTANCE , null , null ) ); return new ArrowBooleanMemoryAllocator( bitVector.getVector() , rowCount ); case BYTE: AddOrGetResult<TinyIntVector> byteVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 8 , true ) , null , null ) ); return new ArrowByteMemoryAllocator( byteVector.getVector() , rowCount ); case SHORT: AddOrGetResult<SmallIntVector> shortVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 16 , true ) , null , null ) ); return new ArrowShortMemoryAllocator( shortVector.getVector() , rowCount ); case INTEGER: AddOrGetResult<IntVector> integerVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 32 , true ) , null , null ) ); return new ArrowIntegerMemoryAllocator( integerVector.getVector() , rowCount ); case LONG: AddOrGetResult<BigIntVector> longVector = vector.addOrGetVector( new FieldType( true , new ArrowType.Int( 64 , true ) , null , null ) ); return new ArrowLongMemoryAllocator( longVector.getVector() , rowCount ); case FLOAT: AddOrGetResult<Float4Vector> floatVector = vector.addOrGetVector( new FieldType( true , new ArrowType.FloatingPoint( FloatingPointPrecision.HALF ) , null , null ) ); return new ArrowFloatMemoryAllocator( floatVector.getVector() , rowCount ); case DOUBLE: AddOrGetResult<Float8Vector> doubleVector = vector.addOrGetVector( new FieldType( true , new ArrowType.FloatingPoint( FloatingPointPrecision.DOUBLE ) , null , null ) ); return new ArrowDoubleMemoryAllocator( doubleVector.getVector() , rowCount ); case STRING: AddOrGetResult<VarCharVector> charVector = vector.addOrGetVector( new FieldType( true , ArrowType.Utf8.INSTANCE , null , null ) ); return new ArrowStringMemoryAllocator( charVector.getVector() , rowCount ); case BYTES: AddOrGetResult<VarBinaryVector> binaryVector = vector.addOrGetVector( new FieldType( true , ArrowType.Binary.INSTANCE , null , null ) ); return new ArrowBytesMemoryAllocator( binaryVector.getVector() , rowCount ); case NULL: case EMPTY_ARRAY: case EMPTY_SPREAD: default: return NullMemoryAllocator.INSTANCE; } }