org.apache.arrow.vector.DateDayVector Java Examples
The following examples show how to use
org.apache.arrow.vector.DateDayVector.
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: RowDateWriter.java From flink with Apache License 2.0 | 5 votes |
@Override public void doWrite(Row value, int ordinal) { if (value.getField(ordinal) == null) { ((DateDayVector) getValueVector()).setNull(getCount()); } else { ((DateDayVector) getValueVector()).setSafe( getCount(), PythonTypeUtils.dateToInternal(((Date) value.getField(ordinal)))); } }
Example #2
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 #3
Source File: DateWriter.java From flink with Apache License 2.0 | 5 votes |
@Override public void doWrite(T in, int ordinal) { if (isNullAt(in, ordinal)) { ((DateDayVector) getValueVector()).setNull(getCount()); } else { ((DateDayVector) getValueVector()).setSafe(getCount(), readDate(in, ordinal)); } }
Example #4
Source File: DateFieldReader.java From flink with Apache License 2.0 | 5 votes |
@Override public Date read(int index) { if (getValueVector().isNull(index)) { return null; } else { return SqlDateTimeUtils.internalToDate(((DateDayVector) getValueVector()).get(index)); } }
Example #5
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 #6
Source File: RowDateWriter.java From flink with Apache License 2.0 | 4 votes |
public RowDateWriter(DateDayVector dateDayVector) { super(dateDayVector); }
Example #7
Source File: DateWriter.java From flink with Apache License 2.0 | 4 votes |
private DateWriterForArray(DateDayVector dateDayVector) { super(dateDayVector); }
Example #8
Source File: DateWriter.java From flink with Apache License 2.0 | 4 votes |
private DateWriterForRow(DateDayVector dateDayVector) { super(dateDayVector); }
Example #9
Source File: DateWriter.java From flink with Apache License 2.0 | 4 votes |
private DateWriter(DateDayVector dateDayVector) { super(dateDayVector); }
Example #10
Source File: DateWriter.java From flink with Apache License 2.0 | 4 votes |
public static DateWriter<ArrayData> forArray(DateDayVector dateDayVector) { return new DateWriterForArray(dateDayVector); }
Example #11
Source File: DateWriter.java From flink with Apache License 2.0 | 4 votes |
public static DateWriter<RowData> forRow(DateDayVector dateDayVector) { return new DateWriterForRow(dateDayVector); }
Example #12
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 #13
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 #14
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 #15
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 #16
Source File: GeneratedRowWriter.java From aws-athena-query-federation with Apache License 2.0 | 4 votes |
private FieldWriter makeFieldWriter(FieldVector vector) { Field field = vector.getField(); String fieldName = field.getName(); Types.MinorType fieldType = Types.getMinorTypeForArrowType(field.getType()); Extractor extractor = extractors.get(fieldName); ConstraintProjector constraint = constraints.get(fieldName); FieldWriterFactory factory = fieldWriterFactories.get(fieldName); if (factory != null) { return factory.create(vector, extractor, constraint); } if (extractor == null) { throw new IllegalStateException("Missing extractor for field[" + fieldName + "]"); } switch (fieldType) { case INT: return new IntFieldWriter((IntExtractor) extractor, (IntVector) vector, constraint); case BIGINT: return new BigIntFieldWriter((BigIntExtractor) extractor, (BigIntVector) vector, constraint); case DATEMILLI: return new DateMilliFieldWriter((DateMilliExtractor) extractor, (DateMilliVector) vector, constraint); case DATEDAY: return new DateDayFieldWriter((DateDayExtractor) extractor, (DateDayVector) vector, constraint); case TINYINT: return new TinyIntFieldWriter((TinyIntExtractor) extractor, (TinyIntVector) vector, constraint); case SMALLINT: return new SmallIntFieldWriter((SmallIntExtractor) extractor, (SmallIntVector) vector, constraint); case FLOAT4: return new Float4FieldWriter((Float4Extractor) extractor, (Float4Vector) vector, constraint); case FLOAT8: return new Float8FieldWriter((Float8Extractor) extractor, (Float8Vector) vector, constraint); case DECIMAL: return new DecimalFieldWriter((DecimalExtractor) extractor, (DecimalVector) vector, constraint); case BIT: return new BitFieldWriter((BitExtractor) extractor, (BitVector) vector, constraint); case VARCHAR: return new VarCharFieldWriter((VarCharExtractor) extractor, (VarCharVector) vector, constraint); case VARBINARY: return new VarBinaryFieldWriter((VarBinaryExtractor) extractor, (VarBinaryVector) vector, constraint); default: throw new RuntimeException(fieldType + " is not supported"); } }
Example #17
Source File: DateFieldReader.java From flink with Apache License 2.0 | 4 votes |
public DateFieldReader(DateDayVector dateDayVector) { super(dateDayVector); }
Example #18
Source File: ArrowDateColumnVector.java From flink with Apache License 2.0 | 4 votes |
public ArrowDateColumnVector(DateDayVector dateDayVector) { this.dateDayVector = Preconditions.checkNotNull(dateDayVector); }
Example #19
Source File: DateConverterTest.java From snowflake-jdbc with Apache License 2.0 | 4 votes |
@Test public void testRandomDates() throws SFException { int dateBound = 50000; int rowCount = 50000; Map<String, String> customFieldMeta = new HashMap<>(); customFieldMeta.put("logicalType", "DATE"); Set<Integer> nullValIndex = new HashSet<>(); // test normal date FieldType fieldType = new FieldType(true, Types.MinorType.DATEDAY.getType(), null, customFieldMeta); DateDayVector vector = new DateDayVector("date", fieldType, allocator); int[] rawDates = new int[rowCount]; for (int i = 0; i < rowCount; i++) { boolean isNull = random.nextBoolean(); if (isNull) { nullValIndex.add(i); vector.setNull(i); } else { rawDates[i] = random.nextInt(dateBound) - dateBound / 2; vector.setSafe(i, rawDates[i]); } } ArrowVectorConverter converter = new DateConverter(vector, 0, this); for (int i = 0; i < rowCount; i++) { int intVal = converter.toInt(i); String strVal = converter.toString(i); Date obj = converter.toDate(i); String str = converter.toString(i); if (nullValIndex.contains(i)) { assertThat(intVal, is(0)); assertThat(strVal, is(nullValue())); assertThat(obj, is(nullValue())); } else { Date oldObj = ArrowResultUtil.getDate(intVal); assertThat(intVal, is(rawDates[i])); assertThat(obj.getTime(), is(oldObj.getTime())); } } }
Example #20
Source File: DateConverterTest.java From snowflake-jdbc with Apache License 2.0 | 4 votes |
@Test public void testDate() throws SFException { Map<String, String> customFieldMeta = new HashMap<>(); customFieldMeta.put("logicalType", "DATE"); Set<Integer> nullValIndex = new HashSet<>(); // test normal date FieldType fieldType = new FieldType(true, Types.MinorType.DATEDAY.getType(), null, customFieldMeta); DateDayVector vector = new DateDayVector("date", fieldType, allocator); int i = 0, j = 0; while (i < testDates.length) { boolean isNull = random.nextBoolean(); if (isNull) { vector.setNull(j); nullValIndex.add(j); } else { vector.setSafe(j, testDates[i++]); } j++; } ArrowVectorConverter converter = new DateConverter(vector, 0, this); int rowCount = j; i = 0; j = 0; while (j < rowCount) { int intVal = converter.toInt(j); String strVal = converter.toString(j); Object obj = converter.toObject(j); Object oldObj = ArrowResultUtil.getDate(intVal, TimeZone.getDefault(), new SFSession()); if (nullValIndex.contains(j)) { assertThat(intVal, is(0)); assertThat(obj, is(nullValue())); assertThat(strVal, is(nullValue())); assertThat(false, is(converter.toBoolean(j))); assertThat(converter.toBytes(j), is(nullValue())); } else { assertThat(intVal, is(testDates[i])); assertThat(((Date) obj).getTime(), is(((Date) oldObj).getTime())); assertThat(obj.toString(), is(expectedDates[i])); assertThat(((Date) obj).getTime(), is(((Date) oldObj).getTime())); assertThat(oldObj.toString(), is(expectedDates[i++])); final int x = j; TestUtil.assertSFException(invalidConversionErrorCode, () -> converter.toBoolean(x)); } j++; } vector.clear(); }
Example #21
Source File: DateConverter.java From snowflake-jdbc with Apache License 2.0 | 4 votes |
public DateConverter(ValueVector fieldVector, int columnIndex, DataConversionContext context) { super(SnowflakeType.DATE.name(), fieldVector, columnIndex, context); this.dateVector = (DateDayVector) fieldVector; }
Example #22
Source File: ArrowVectorAccessors.java From iceberg with Apache License 2.0 | 4 votes |
DateAccessor(DateDayVector vector) { super(vector); this.vector = vector; }
Example #23
Source File: FlightArrowColumnVector.java From flight-spark-source with Apache License 2.0 | 4 votes |
DateAccessor(DateDayVector vector) { super(vector); this.accessor = vector; }
Example #24
Source File: FlightArrowColumnVector.java From flight-spark-source with Apache License 2.0 | 4 votes |
public FlightArrowColumnVector(ValueVector vector) { super(FlightArrowUtils.fromArrowField(vector.getField())); if (vector instanceof BitVector) { accessor = new BooleanAccessor((BitVector) vector); } else if (vector instanceof TinyIntVector) { accessor = new ByteAccessor((TinyIntVector) vector); } else if (vector instanceof SmallIntVector) { accessor = new ShortAccessor((SmallIntVector) vector); } else if (vector instanceof IntVector) { accessor = new IntAccessor((IntVector) vector); } else if (vector instanceof BigIntVector) { accessor = new LongAccessor((BigIntVector) vector); } else if (vector instanceof Float4Vector) { accessor = new FloatAccessor((Float4Vector) vector); } else if (vector instanceof Float8Vector) { accessor = new DoubleAccessor((Float8Vector) vector); } else if (vector instanceof DecimalVector) { accessor = new DecimalAccessor((DecimalVector) vector); } else if (vector instanceof VarCharVector) { accessor = new StringAccessor((VarCharVector) vector); } else if (vector instanceof VarBinaryVector) { accessor = new BinaryAccessor((VarBinaryVector) vector); } else if (vector instanceof DateDayVector) { accessor = new DateAccessor((DateDayVector) vector); } else if (vector instanceof DateMilliVector) { accessor = new DateMilliAccessor((DateMilliVector) vector); } else if (vector instanceof TimeStampMicroTZVector) { accessor = new TimestampAccessor((TimeStampMicroTZVector) vector); } else if (vector instanceof TimeStampMilliVector) { accessor = new TimestampMilliAccessor((TimeStampMilliVector) vector); } else if (vector instanceof ListVector) { ListVector listVector = (ListVector) vector; accessor = new ArrayAccessor(listVector); } else if (vector instanceof StructVector) { StructVector structVector = (StructVector) vector; accessor = new StructAccessor(structVector); childColumns = new FlightArrowColumnVector[structVector.size()]; for (int i = 0; i < childColumns.length; ++i) { childColumns[i] = new FlightArrowColumnVector(structVector.getVectorById(i)); } } else { System.out.println(vector); throw new UnsupportedOperationException(); } }
Example #25
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 #26
Source File: BlockUtils.java From aws-athena-query-federation with Apache License 2.0 | 4 votes |
/** * Used to mark a particular cell as null. * * @param vector The FieldVector to write the null value to. * @param pos The position (row) in the FieldVector to mark as null. */ private static void setNullValue(FieldVector vector, int pos) { switch (vector.getMinorType()) { case TIMESTAMPMILLITZ: ((TimeStampMilliTZVector) vector).setNull(pos); break; case DATEMILLI: ((DateMilliVector) vector).setNull(pos); break; case DATEDAY: ((DateDayVector) vector).setNull(pos); break; case FLOAT8: ((Float8Vector) vector).setNull(pos); break; case FLOAT4: ((Float4Vector) vector).setNull(pos); break; case INT: ((IntVector) vector).setNull(pos); break; case TINYINT: ((TinyIntVector) vector).setNull(pos); break; case SMALLINT: ((SmallIntVector) vector).setNull(pos); break; case UINT1: ((UInt1Vector) vector).setNull(pos); break; case UINT2: ((UInt2Vector) vector).setNull(pos); break; case UINT4: ((UInt4Vector) vector).setNull(pos); break; case UINT8: ((UInt8Vector) vector).setNull(pos); break; case BIGINT: ((BigIntVector) vector).setNull(pos); break; case VARBINARY: ((VarBinaryVector) vector).setNull(pos); break; case DECIMAL: ((DecimalVector) vector).setNull(pos); break; case VARCHAR: ((VarCharVector) vector).setNull(pos); break; case BIT: ((BitVector) vector).setNull(pos); break; default: throw new IllegalArgumentException("Unknown type " + vector.getMinorType()); } }