org.apache.arrow.vector.Float4Vector Java Examples
The following examples show how to use
org.apache.arrow.vector.Float4Vector.
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: TestData.java From dremio-oss with Apache License 2.0 | 6 votes |
private Pair<Float4Vector, ResultVerifier> testFloat4Vector() { final String colName = "colFloat4"; final List<Float> values = asList(20.0f, 50.023f, -238423f, null, 0f); Float4Vector valuesVector = new Float4Vector(colName, allocator); valuesVector.allocateNew(values.size()); for (int i = 0; i < values.size(); i++) { if (values.get(i) == null) { valuesVector.setNull(i); } else { valuesVector.set(i, values.get(i)); } } ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { verifyDoubleValues(values, output, colName, 0.01f); } }; return Pair.of(valuesVector, verifier); }
Example #2
Source File: TestVectorizedHashAggPartitionSerializable.java From dremio-oss with Apache License 2.0 | 5 votes |
private void populateFloat(Float4Vector vector, Float[] data) { vector.allocateNew(); Random r = new Random(); for(int i =0; i < data.length; i++){ Float val = data[i]; if(val != null){ vector.setSafe(i, val); } else { vector.setSafe(i, 0, r.nextFloat()); } } vector.setValueCount(data.length); }
Example #3
Source File: RowFloatWriter.java From flink with Apache License 2.0 | 5 votes |
@Override public void doWrite(Row value, int ordinal) { if (value.getField(ordinal) == null) { ((Float4Vector) getValueVector()).setNull(getCount()); } else { ((Float4Vector) getValueVector()).setSafe(getCount(), (float) value.getField(ordinal)); } }
Example #4
Source File: FloatWriter.java From flink with Apache License 2.0 | 5 votes |
@Override public void doWrite(T in, int ordinal) { if (isNullAt(in, ordinal)) { ((Float4Vector) getValueVector()).setNull(getCount()); } else { ((Float4Vector) getValueVector()).setSafe(getCount(), readFloat(in, ordinal)); } }
Example #5
Source File: GlobalDictionaryBuilder.java From dremio-oss with Apache License 2.0 | 5 votes |
private static VectorContainer buildFloatGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null); final VectorContainer input = new VectorContainer(bufferAllocator); final Float4Vector floatVector = input.addOrGet(field); floatVector.allocateNew(); SortedSet<Float> values = Sets.newTreeSet(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToFloat(i)); } } if (existingDict != null) { final Float4Vector existingDictValues = existingDict.getValueAccessorById(Float4Vector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(existingDictValues.get(i)); } } final Iterator<Float> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { floatVector.setSafe(recordCount++, iter.next()); } floatVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
Example #6
Source File: Twister2ArrowFileWriter.java From twister2 with Apache License 2.0 | 5 votes |
@Override public <T extends FieldVector> void generate(T floatVector1, int from, int items, int isSet) { Float4Vector floatVector = (Float4Vector) floatVector1; floatVector.setInitialCapacity(items); floatVector.allocateNew(); for (int i = 0; i < items; i++) { floatVector.setSafe(i, isSet, (float) dataList.get(from + i)); } floatVector.setValueCount(items); }
Example #7
Source File: TestArrowFloatConnector.java From multiple-dimension-spread with Apache License 2.0 | 5 votes |
@Test public void T_convert_1() throws IOException{ BufferAllocator allocator = new RootAllocator( 1024 * 1024 * 10 ); Float4Vector vector = new Float4Vector( "test" , allocator ); vector.allocateNew(); vector.setSafe( 0 , (float)0 ); vector.setSafe( 1 , (float)1 ); vector.setSafe( 2 , (float)0 ); vector.setNull( 3 ); vector.setSafe( 4 , (float)1 ); vector.setSafe( 5 , (float)1 ); vector.setSafe( 6 , (float)1 ); vector.setNull( 7 ); vector.setValueCount( 8 ); IColumn column = ArrowColumnFactory.convert( "test" , vector ); assertEquals( column.getColumnName() , "test" ); assertEquals( column.size() , 8 ); assertTrue( ( column.getColumnType() == ColumnType.FLOAT ) ); assertEquals( ( (PrimitiveObject)( column.get(0).getRow() ) ).getFloat() , (float)0 ); assertEquals( ( (PrimitiveObject)( column.get(1).getRow() ) ).getFloat() , (float)1 ); assertEquals( ( (PrimitiveObject)( column.get(2).getRow() ) ).getFloat() , (float)0 ); assertEquals( column.get(3).getRow() , null ); assertEquals( ( (PrimitiveObject)( column.get(4).getRow() ) ).getFloat() , (float)1 ); assertEquals( ( (PrimitiveObject)( column.get(5).getRow() ) ).getFloat() , (float)1 ); assertEquals( ( (PrimitiveObject)( column.get(6).getRow() ) ).getFloat() , (float)1 ); assertEquals( column.get(7).getRow() , null ); }
Example #8
Source File: ArrowVectorAccessors.java From iceberg with Apache License 2.0 | 5 votes |
@NotNull @SuppressWarnings("checkstyle:CyclomaticComplexity") private static ArrowVectorAccessor getPlainVectorAccessor(FieldVector vector) { if (vector instanceof BitVector) { return new BooleanAccessor((BitVector) vector); } else if (vector instanceof IntVector) { return new IntAccessor((IntVector) vector); } else if (vector instanceof BigIntVector) { return new LongAccessor((BigIntVector) vector); } else if (vector instanceof Float4Vector) { return new FloatAccessor((Float4Vector) vector); } else if (vector instanceof Float8Vector) { return new DoubleAccessor((Float8Vector) vector); } else if (vector instanceof IcebergArrowVectors.DecimalArrowVector) { return new DecimalAccessor((IcebergArrowVectors.DecimalArrowVector) vector); } else if (vector instanceof IcebergArrowVectors.VarcharArrowVector) { return new StringAccessor((IcebergArrowVectors.VarcharArrowVector) vector); } else if (vector instanceof VarBinaryVector) { return new BinaryAccessor((VarBinaryVector) vector); } else if (vector instanceof DateDayVector) { return new DateAccessor((DateDayVector) vector); } else if (vector instanceof TimeStampMicroTZVector) { return new TimestampAccessor((TimeStampMicroTZVector) vector); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; return new ArrayAccessor(listVector); } else if (vector instanceof StructVector) { StructVector structVector = (StructVector) vector; return new StructAccessor(structVector); } throw new UnsupportedOperationException("Unsupported vector: " + vector.getClass()); }
Example #9
Source File: TestArrowFloatConnector.java From yosegi with Apache License 2.0 | 5 votes |
@Test public void T_convert_1() throws IOException{ BufferAllocator allocator = new RootAllocator( 1024 * 1024 * 10 ); Float4Vector vector = new Float4Vector( "test" , allocator ); vector.allocateNew(); vector.setSafe( 0 , (float)0 ); vector.setSafe( 1 , (float)1 ); vector.setSafe( 2 , (float)0 ); vector.setNull( 3 ); vector.setSafe( 4 , (float)1 ); vector.setSafe( 5 , (float)1 ); vector.setSafe( 6 , (float)1 ); vector.setNull( 7 ); vector.setValueCount( 8 ); IColumn column = ArrowColumnFactory.convert( "test" , vector ); assertEquals( column.getColumnName() , "test" ); assertEquals( column.size() , 8 ); assertTrue( ( column.getColumnType() == ColumnType.FLOAT ) ); assertEquals( ( (PrimitiveObject)( column.get(0).getRow() ) ).getFloat() , (float)0 ); assertEquals( ( (PrimitiveObject)( column.get(1).getRow() ) ).getFloat() , (float)1 ); assertEquals( ( (PrimitiveObject)( column.get(2).getRow() ) ).getFloat() , (float)0 ); assertEquals( column.get(3).getRow() , null ); assertEquals( ( (PrimitiveObject)( column.get(4).getRow() ) ).getFloat() , (float)1 ); assertEquals( ( (PrimitiveObject)( column.get(5).getRow() ) ).getFloat() , (float)1 ); assertEquals( ( (PrimitiveObject)( column.get(6).getRow() ) ).getFloat() , (float)1 ); assertEquals( column.get(7).getRow() , null ); }
Example #10
Source File: ArrowUtils.java From flink with Apache License 2.0 | 4 votes |
private static ArrowFieldWriter<RowData> createArrowFieldWriterForRow(ValueVector vector, LogicalType fieldType) { if (vector instanceof TinyIntVector) { return TinyIntWriter.forRow((TinyIntVector) vector); } else if (vector instanceof SmallIntVector) { return SmallIntWriter.forRow((SmallIntVector) vector); } else if (vector instanceof IntVector) { return IntWriter.forRow((IntVector) vector); } else if (vector instanceof BigIntVector) { return BigIntWriter.forRow((BigIntVector) vector); } else if (vector instanceof BitVector) { return BooleanWriter.forRow((BitVector) vector); } else if (vector instanceof Float4Vector) { return FloatWriter.forRow((Float4Vector) vector); } else if (vector instanceof Float8Vector) { return DoubleWriter.forRow((Float8Vector) vector); } else if (vector instanceof VarCharVector) { return VarCharWriter.forRow((VarCharVector) vector); } else if (vector instanceof VarBinaryVector) { return VarBinaryWriter.forRow((VarBinaryVector) vector); } else if (vector instanceof DecimalVector) { DecimalVector decimalVector = (DecimalVector) vector; return DecimalWriter.forRow(decimalVector, getPrecision(decimalVector), decimalVector.getScale()); } else if (vector instanceof DateDayVector) { return DateWriter.forRow((DateDayVector) vector); } else if (vector instanceof TimeSecVector || vector instanceof TimeMilliVector || vector instanceof TimeMicroVector || vector instanceof TimeNanoVector) { return TimeWriter.forRow(vector); } else if (vector instanceof TimeStampVector && ((ArrowType.Timestamp) vector.getField().getType()).getTimezone() == null) { int precision; if (fieldType instanceof LocalZonedTimestampType) { precision = ((LocalZonedTimestampType) fieldType).getPrecision(); } else { precision = ((TimestampType) fieldType).getPrecision(); } return TimestampWriter.forRow(vector, precision); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; LogicalType elementType = ((ArrayType) fieldType).getElementType(); return ArrayWriter.forRow(listVector, createArrowFieldWriterForArray(listVector.getDataVector(), elementType)); } else if (vector instanceof StructVector) { RowType rowType = (RowType) fieldType; ArrowFieldWriter<RowData>[] fieldsWriters = new ArrowFieldWriter[rowType.getFieldCount()]; for (int i = 0; i < fieldsWriters.length; i++) { fieldsWriters[i] = createArrowFieldWriterForRow( ((StructVector) vector).getVectorById(i), rowType.getTypeAt(i)); } return RowWriter.forRow((StructVector) vector, fieldsWriters); } else { throw new UnsupportedOperationException(String.format( "Unsupported type %s.", fieldType)); } }
Example #11
Source File: HiveORCCopiers.java From dremio-oss with Apache License 2.0 | 4 votes |
DoubleToFloat4Copier(DoubleColumnVector inputVector, Float4Vector outputVector) { this.inputVector = inputVector; this.outputVector = outputVector; }
Example #12
Source File: HiveFieldConverter.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final float value = (float) ((FloatObjectInspector)oi).getPrimitiveJavaObject(hiveFieldValue); ((Float4Vector) outputVV).setSafe(outputIndex, value); }
Example #13
Source File: TestHiveUDFs.java From dremio-oss with Apache License 2.0 | 4 votes |
@Test public void testGenericUDF() throws Throwable { int numRecords = 0; String planString = Resources.toString(Resources.getResource("functions/hive/GenericUDF.json"), Charsets.UTF_8); List<QueryDataBatch> results = testPhysicalWithResults(planString); RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator()); for (QueryDataBatch result : results) { batchLoader.load(result.getHeader().getDef(), result.getData()); if (batchLoader.getRecordCount() <= 0) { result.release(); batchLoader.clear(); continue; } // Output columns and types // 1. str1 : VarChar // 2. upperStr1 : VarChar // 3. concat : VarChar // 4. flt1 : Float4 // 5. format_number : Float8 // 6. nullableStr1 : VarChar // 7. upperStr1 : VarChar VarCharVector str1V = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 0).getValueVector(); VarCharVector upperStr1V = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 1).getValueVector(); VarCharVector concatV = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 2).getValueVector(); Float4Vector flt1V = (Float4Vector) batchLoader.getValueAccessorById(Float4Vector.class, 3).getValueVector(); VarCharVector format_numberV = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 4).getValueVector(); VarCharVector nullableStr1V = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 5).getValueVector(); VarCharVector upperNullableStr1V = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 6).getValueVector(); for (int i=0; i<batchLoader.getRecordCount(); i++) { if (str1V.isNull(i)) { continue; } String in = new String(str1V.get(i), Charsets.UTF_8); String upper = new String(upperStr1V.get(i), Charsets.UTF_8); assertTrue(in.toUpperCase().equals(upper)); String concat = new String(concatV.get(i), Charsets.UTF_8); assertTrue(concat.equals(in+"-"+in)); float flt1 = flt1V.get(i); String format_number = new String(format_numberV.get(i), Charsets.UTF_8); String nullableStr1 = null; if (!nullableStr1V.isNull(i)) { nullableStr1 = new String(nullableStr1V.get(i), Charsets.UTF_8); } String upperNullableStr1 = null; if (!upperNullableStr1V.isNull(i)) { upperNullableStr1 = new String(upperNullableStr1V.get(i), Charsets.UTF_8); } assertEquals(nullableStr1 != null, upperNullableStr1 != null); if (nullableStr1 != null) { assertEquals(nullableStr1.toUpperCase(), upperNullableStr1); } numRecords++; } result.release(); batchLoader.clear(); } }
Example #14
Source File: TestHiveUDFs.java From dremio-oss with Apache License 2.0 | 4 votes |
@Test public void testUDF() throws Throwable { int numRecords = 0; String planString = Resources.toString(Resources.getResource("functions/hive/UDF.json"), Charsets.UTF_8); List<QueryDataBatch> results = testPhysicalWithResults(planString); RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator()); for (QueryDataBatch result : results) { batchLoader.load(result.getHeader().getDef(), result.getData()); if (batchLoader.getRecordCount() <= 0) { result.release(); batchLoader.clear(); continue; } // Output columns and types // 1. str1 : VarChar // 2. str1Length : Int // 3. str1Ascii : Int // 4. flt1 : Float4 // 5. pow : Float8 VarCharVector str1V = (VarCharVector) batchLoader.getValueAccessorById(VarCharVector.class, 0).getValueVector(); IntVector str1LengthV = (IntVector) batchLoader.getValueAccessorById(IntVector.class, 1).getValueVector(); IntVector str1AsciiV = (IntVector) batchLoader.getValueAccessorById(IntVector.class, 2).getValueVector(); Float4Vector flt1V = (Float4Vector) batchLoader.getValueAccessorById(Float4Vector.class, 3).getValueVector(); Float8Vector powV = (Float8Vector) batchLoader.getValueAccessorById(Float8Vector.class, 4).getValueVector(); for (int i=0; i<batchLoader.getRecordCount(); i++) { if (str1V.isNull(i)) { continue; } String str1 = new String(str1V.get(i), Charsets.UTF_8); long str1Length = str1LengthV.get(i); assertTrue(str1.length() == str1Length); int str1Ascii = str1AsciiV.get(i); float flt1 = flt1V.get(i); double pow = 0; if (!powV.isNull(i)) { pow = powV.get(i); assertTrue(Math.pow(flt1, 2.0) == pow); } numRecords++; } result.release(); batchLoader.clear(); } }
Example #15
Source File: HiveORCCopiers.java From dremio-oss with Apache License 2.0 | 4 votes |
LongToFloat4Copier(LongColumnVector inputVector, Float4Vector outputVector) { this.inputVector = inputVector; this.outputVector = outputVector; }
Example #16
Source File: HiveORCCopiers.java From dremio-oss with Apache License 2.0 | 4 votes |
DoubleToFloat4Copier(DoubleColumnVector inputVector, Float4Vector outputVector) { this.inputVector = inputVector; this.outputVector = outputVector; }
Example #17
Source File: HiveFieldConverter.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final float value = (float) ((FloatObjectInspector)oi).getPrimitiveJavaObject(hiveFieldValue); ((Float4Vector) outputVV).setSafe(outputIndex, value); }
Example #18
Source File: ArrowFloatColumnVector.java From flink with Apache License 2.0 | 4 votes |
public ArrowFloatColumnVector(Float4Vector floatVector) { this.floatVector = Preconditions.checkNotNull(floatVector); }
Example #19
Source File: FloatFieldReader.java From flink with Apache License 2.0 | 4 votes |
public FloatFieldReader(Float4Vector floatVector) { super(floatVector); }
Example #20
Source File: FloatFieldReader.java From flink with Apache License 2.0 | 4 votes |
@Override public Float read(int index) { return ((Float4Vector) getValueVector()).getObject(index); }
Example #21
Source File: ArrowUtils.java From flink with Apache License 2.0 | 4 votes |
private static ArrowFieldWriter<Row> createRowArrowFieldWriter(ValueVector vector, LogicalType fieldType) { if (vector instanceof TinyIntVector) { return new RowTinyIntWriter((TinyIntVector) vector); } else if (vector instanceof SmallIntVector) { return new RowSmallIntWriter((SmallIntVector) vector); } else if (vector instanceof IntVector) { return new RowIntWriter((IntVector) vector); } else if (vector instanceof BigIntVector) { return new RowBigIntWriter((BigIntVector) vector); } else if (vector instanceof BitVector) { return new RowBooleanWriter((BitVector) vector); } else if (vector instanceof Float4Vector) { return new RowFloatWriter((Float4Vector) vector); } else if (vector instanceof Float8Vector) { return new RowDoubleWriter((Float8Vector) vector); } else if (vector instanceof VarCharVector) { return new RowVarCharWriter((VarCharVector) vector); } else if (vector instanceof VarBinaryVector) { return new RowVarBinaryWriter((VarBinaryVector) vector); } else if (vector instanceof DecimalVector) { DecimalVector decimalVector = (DecimalVector) vector; return new RowDecimalWriter(decimalVector, getPrecision(decimalVector), decimalVector.getScale()); } else if (vector instanceof DateDayVector) { return new RowDateWriter((DateDayVector) vector); } else if (vector instanceof TimeSecVector || vector instanceof TimeMilliVector || vector instanceof TimeMicroVector || vector instanceof TimeNanoVector) { return new RowTimeWriter(vector); } else if (vector instanceof TimeStampVector && ((ArrowType.Timestamp) vector.getField().getType()).getTimezone() == null) { return new RowTimestampWriter(vector); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; LogicalType elementType = ((ArrayType) fieldType).getElementType(); return new RowArrayWriter(listVector, createRowArrowFieldWriter(listVector.getDataVector(), elementType)); } else if (vector instanceof StructVector) { RowType rowType = (RowType) fieldType; ArrowFieldWriter<Row>[] fieldsWriters = new ArrowFieldWriter[rowType.getFieldCount()]; for (int i = 0; i < fieldsWriters.length; i++) { fieldsWriters[i] = createRowArrowFieldWriter( ((StructVector) vector).getVectorById(i), rowType.getTypeAt(i)); } return new RowRowWriter((StructVector) vector, fieldsWriters); } else { throw new UnsupportedOperationException(String.format( "Unsupported type %s.", fieldType)); } }
Example #22
Source File: HiveORCCopiers.java From dremio-oss with Apache License 2.0 | 4 votes |
LongToFloat4Copier(LongColumnVector inputVector, Float4Vector outputVector) { this.inputVector = inputVector; this.outputVector = outputVector; }
Example #23
Source File: ArrowUtils.java From flink with Apache License 2.0 | 4 votes |
private static ArrowFieldWriter<ArrayData> createArrowFieldWriterForArray(ValueVector vector, LogicalType fieldType) { if (vector instanceof TinyIntVector) { return TinyIntWriter.forArray((TinyIntVector) vector); } else if (vector instanceof SmallIntVector) { return SmallIntWriter.forArray((SmallIntVector) vector); } else if (vector instanceof IntVector) { return IntWriter.forArray((IntVector) vector); } else if (vector instanceof BigIntVector) { return BigIntWriter.forArray((BigIntVector) vector); } else if (vector instanceof BitVector) { return BooleanWriter.forArray((BitVector) vector); } else if (vector instanceof Float4Vector) { return FloatWriter.forArray((Float4Vector) vector); } else if (vector instanceof Float8Vector) { return DoubleWriter.forArray((Float8Vector) vector); } else if (vector instanceof VarCharVector) { return VarCharWriter.forArray((VarCharVector) vector); } else if (vector instanceof VarBinaryVector) { return VarBinaryWriter.forArray((VarBinaryVector) vector); } else if (vector instanceof DecimalVector) { DecimalVector decimalVector = (DecimalVector) vector; return DecimalWriter.forArray(decimalVector, getPrecision(decimalVector), decimalVector.getScale()); } else if (vector instanceof DateDayVector) { return DateWriter.forArray((DateDayVector) vector); } else if (vector instanceof TimeSecVector || vector instanceof TimeMilliVector || vector instanceof TimeMicroVector || vector instanceof TimeNanoVector) { return TimeWriter.forArray(vector); } else if (vector instanceof TimeStampVector && ((ArrowType.Timestamp) vector.getField().getType()).getTimezone() == null) { int precision; if (fieldType instanceof LocalZonedTimestampType) { precision = ((LocalZonedTimestampType) fieldType).getPrecision(); } else { precision = ((TimestampType) fieldType).getPrecision(); } return TimestampWriter.forArray(vector, precision); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; LogicalType elementType = ((ArrayType) fieldType).getElementType(); return ArrayWriter.forArray(listVector, createArrowFieldWriterForArray(listVector.getDataVector(), elementType)); } else if (vector instanceof StructVector) { RowType rowType = (RowType) fieldType; ArrowFieldWriter<RowData>[] fieldsWriters = new ArrowFieldWriter[rowType.getFieldCount()]; for (int i = 0; i < fieldsWriters.length; i++) { fieldsWriters[i] = createArrowFieldWriterForRow( ((StructVector) vector).getVectorById(i), rowType.getTypeAt(i)); } return RowWriter.forArray((StructVector) vector, fieldsWriters); } else { throw new UnsupportedOperationException(String.format( "Unsupported type %s.", fieldType)); } }
Example #24
Source File: ArrowUtils.java From flink with Apache License 2.0 | 4 votes |
public static ArrowFieldReader createRowArrowFieldReader(ValueVector vector, LogicalType fieldType) { if (vector instanceof TinyIntVector) { return new TinyIntFieldReader((TinyIntVector) vector); } else if (vector instanceof SmallIntVector) { return new SmallIntFieldReader((SmallIntVector) vector); } else if (vector instanceof IntVector) { return new IntFieldReader((IntVector) vector); } else if (vector instanceof BigIntVector) { return new BigIntFieldReader((BigIntVector) vector); } else if (vector instanceof BitVector) { return new BooleanFieldReader((BitVector) vector); } else if (vector instanceof Float4Vector) { return new FloatFieldReader((Float4Vector) vector); } else if (vector instanceof Float8Vector) { return new DoubleFieldReader((Float8Vector) vector); } else if (vector instanceof VarCharVector) { return new VarCharFieldReader((VarCharVector) vector); } else if (vector instanceof VarBinaryVector) { return new VarBinaryFieldReader((VarBinaryVector) vector); } else if (vector instanceof DecimalVector) { return new DecimalFieldReader((DecimalVector) vector); } else if (vector instanceof DateDayVector) { return new DateFieldReader((DateDayVector) vector); } else if (vector instanceof TimeSecVector || vector instanceof TimeMilliVector || vector instanceof TimeMicroVector || vector instanceof TimeNanoVector) { return new TimeFieldReader(vector); } else if (vector instanceof TimeStampVector && ((ArrowType.Timestamp) vector.getField().getType()).getTimezone() == null) { return new TimestampFieldReader(vector); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; LogicalType elementType = ((ArrayType) fieldType).getElementType(); return new ArrayFieldReader(listVector, createRowArrowFieldReader(listVector.getDataVector(), elementType), elementType); } else if (vector instanceof StructVector) { StructVector structVector = (StructVector) vector; ArrowFieldReader[] fieldReaders = new ArrowFieldReader[structVector.size()]; for (int i = 0; i < fieldReaders.length; i++) { fieldReaders[i] = createRowArrowFieldReader(structVector.getVectorById(i), ((RowType) fieldType).getTypeAt(i)); } return new RowFieldReader(structVector, fieldReaders); } else { throw new UnsupportedOperationException(String.format( "Unsupported type %s.", fieldType)); } }
Example #25
Source File: ArrowUtils.java From flink with Apache License 2.0 | 4 votes |
public static ColumnVector createColumnVector(ValueVector vector, LogicalType fieldType) { if (vector instanceof TinyIntVector) { return new ArrowTinyIntColumnVector((TinyIntVector) vector); } else if (vector instanceof SmallIntVector) { return new ArrowSmallIntColumnVector((SmallIntVector) vector); } else if (vector instanceof IntVector) { return new ArrowIntColumnVector((IntVector) vector); } else if (vector instanceof BigIntVector) { return new ArrowBigIntColumnVector((BigIntVector) vector); } else if (vector instanceof BitVector) { return new ArrowBooleanColumnVector((BitVector) vector); } else if (vector instanceof Float4Vector) { return new ArrowFloatColumnVector((Float4Vector) vector); } else if (vector instanceof Float8Vector) { return new ArrowDoubleColumnVector((Float8Vector) vector); } else if (vector instanceof VarCharVector) { return new ArrowVarCharColumnVector((VarCharVector) vector); } else if (vector instanceof VarBinaryVector) { return new ArrowVarBinaryColumnVector((VarBinaryVector) vector); } else if (vector instanceof DecimalVector) { return new ArrowDecimalColumnVector((DecimalVector) vector); } else if (vector instanceof DateDayVector) { return new ArrowDateColumnVector((DateDayVector) vector); } else if (vector instanceof TimeSecVector || vector instanceof TimeMilliVector || vector instanceof TimeMicroVector || vector instanceof TimeNanoVector) { return new ArrowTimeColumnVector(vector); } else if (vector instanceof TimeStampVector && ((ArrowType.Timestamp) vector.getField().getType()).getTimezone() == null) { return new ArrowTimestampColumnVector(vector); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; return new ArrowArrayColumnVector(listVector, createColumnVector(listVector.getDataVector(), ((ArrayType) fieldType).getElementType())); } else if (vector instanceof StructVector) { StructVector structVector = (StructVector) vector; ColumnVector[] fieldColumns = new ColumnVector[structVector.size()]; for (int i = 0; i < fieldColumns.length; ++i) { fieldColumns[i] = createColumnVector(structVector.getVectorById(i), ((RowType) fieldType).getTypeAt(i)); } return new ArrowRowColumnVector(structVector, fieldColumns); } else { throw new UnsupportedOperationException(String.format( "Unsupported type %s.", fieldType)); } }
Example #26
Source File: FloatWriter.java From flink with Apache License 2.0 | 4 votes |
public static FloatWriter<RowData> forRow(Float4Vector floatVector) { return new FloatWriterForRow(floatVector); }
Example #27
Source File: FloatWriter.java From flink with Apache License 2.0 | 4 votes |
public static FloatWriter<ArrayData> forArray(Float4Vector floatVector) { return new FloatWriterForArray(floatVector); }
Example #28
Source File: FloatWriter.java From flink with Apache License 2.0 | 4 votes |
private FloatWriter(Float4Vector floatVector) { super(floatVector); }
Example #29
Source File: BlockUtils.java From aws-athena-query-federation with Apache License 2.0 | 4 votes |
/** * In some filtering situations it can be useful to 'unset' a row as an indication to a later processing stage * that the row is irrelevant. The mechanism by which we 'unset' a row is actually field type specific and as such * this method is not supported for all field types. * * @param row The row number to unset in the provided Block. * @param block The Block where we'd like to unset the specified row. */ public static void unsetRow(int row, Block block) { for (FieldVector vector : block.getFieldVectors()) { switch (vector.getMinorType()) { case TIMESTAMPMILLITZ: ((TimeStampMilliTZVector) vector).setNull(row); break; case DATEDAY: ((DateDayVector) vector).setNull(row); break; case DATEMILLI: ((DateMilliVector) vector).setNull(row); break; case TINYINT: ((TinyIntVector) vector).setNull(row); break; case UINT1: ((UInt1Vector) vector).setNull(row); break; case SMALLINT: ((SmallIntVector) vector).setNull(row); break; case UINT2: ((UInt2Vector) vector).setNull(row); break; case UINT4: ((UInt4Vector) vector).setNull(row); break; case INT: ((IntVector) vector).setNull(row); break; case UINT8: ((UInt8Vector) vector).setNull(row); break; case BIGINT: ((BigIntVector) vector).setNull(row); break; case FLOAT4: ((Float4Vector) vector).setNull(row); break; case FLOAT8: ((Float8Vector) vector).setNull(row); break; case DECIMAL: ((DecimalVector) vector).setNull(row); break; case VARBINARY: ((VarBinaryVector) vector).setNull(row); break; case VARCHAR: ((VarCharVector) vector).setNull(row); break; case BIT: ((BitVector) vector).setNull(row); break; case STRUCT: ((StructVector) vector).setNull(row); break; case LIST: UnionListWriter writer = ((ListVector) vector).getWriter(); writer.setPosition(row); writer.startList(); writer.endList(); writer.setValueCount(0); break; default: throw new IllegalArgumentException("Unknown type " + vector.getMinorType()); } } }
Example #30
Source File: FloatWriter.java From flink with Apache License 2.0 | 4 votes |
private FloatWriterForRow(Float4Vector floatVector) { super(floatVector); }