private static FieldType toFieldType(TypeInfo typeInfo) { return new FieldType(true, toArrowType(typeInfo), null); }
switch (primitiveTypeInfo.getPrimitiveCategory()) { case BOOLEAN: return Field.nullable(name, MinorType.BIT.getType()); case BYTE: return Field.nullable(name, MinorType.TINYINT.getType()); case SHORT: return Field.nullable(name, MinorType.SMALLINT.getType()); case INT: return Field.nullable(name, MinorType.INT.getType()); case LONG: return Field.nullable(name, MinorType.BIGINT.getType()); case FLOAT: return Field.nullable(name, MinorType.FLOAT4.getType()); case DOUBLE: return Field.nullable(name, MinorType.FLOAT8.getType()); case STRING: case VARCHAR: case CHAR: return Field.nullable(name, MinorType.VARCHAR.getType()); case DATE: return Field.nullable(name, MinorType.DATEDAY.getType()); case TIMESTAMP: return Field.nullable(name, MinorType.TIMESTAMPMILLI.getType()); case TIMESTAMPLOCALTZ: final TimestampLocalTZTypeInfo timestampLocalTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; final String timeZone = timestampLocalTZTypeInfo.getTimeZone().toString(); return Field.nullable(name, new ArrowType.Timestamp(TimeUnit.MILLISECOND, timeZone)); case BINARY:
case TIMESTAMP: return new ArrowType.Timestamp(TimeUnit.MICROSECOND, "UTC"); case BINARY: return Types.MinorType.VARBINARY.getType(); case DECIMAL: final DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) typeInfo; return new ArrowType.Decimal(decimalTypeInfo.precision(), decimalTypeInfo.scale()); case INTERVAL_YEAR_MONTH: return Types.MinorType.INTERVALYEAR.getType();
/** * Instantiate a TimeStampSecTZVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. */ public TimeStampSecTZVector(String name, BufferAllocator allocator, String timeZone) { this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.SECOND, timeZone)), allocator); }
/** 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; }
/** * Instantiate a DecimalVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. */ public DecimalVector(String name, BufferAllocator allocator, int precision, int scale) { this(name, FieldType.nullable( new ArrowType.Decimal(precision, scale)), allocator); }
@Override public String apply(Field field) { return field.getName(); } });
/** * Instantiate a FixedSizeBinaryVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. * @param byteWidth byte width of the binary values */ public FixedSizeBinaryVector(String name, BufferAllocator allocator, int byteWidth) { this(name, FieldType.nullable(new FixedSizeBinary(byteWidth)), allocator); }
@Override public Integer visit(Time type) { return getPrecision(type.getUnit()); }
@Override public Integer visit(Timestamp type) { return getPrecision(type.getUnit()); }
public boolean isScalar() { switch(type.getTypeID()){ case List: case Struct: case Union: return false; default: return true; } }
public Integer getScale(){ return type.accept(new AbstractArrowTypeVisitor<Integer>(){ @Override public Integer visit(Decimal type) { return type.getScale(); } @Override protected Integer visitGeneric(ArrowType type) { return null; } }); }
/** * Instantiate a TimeStampMilliTZVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. */ public TimeStampMilliTZVector(String name, BufferAllocator allocator, String timeZone) { this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MILLISECOND, timeZone)), allocator); }
public boolean isFixedWidthScalar() { switch(type.getTypeID()){ case List: case Struct: case Union: case Binary: case Utf8: return false; default: return true; } }
/** * Instantiate a TimeStampMicroTZVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. */ public TimeStampMicroTZVector(String name, BufferAllocator allocator, String timeZone) { this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.MICROSECOND, timeZone)), allocator); }
public boolean isVariableWidthScalar() { switch(type.getTypeID()){ case Utf8: case Binary: return true; default: return false; } }
/** * Instantiate a TimeStampNanoTZVector. This doesn't allocate any memory for * the data in vector. * * @param name name of the vector * @param allocator allocator for memory management. */ public TimeStampNanoTZVector(String name, BufferAllocator allocator, String timeZone) { this(name, FieldType.nullable(new ArrowType.Timestamp(TimeUnit.NANOSECOND, timeZone)), allocator); }
public boolean isComparable() { switch(type.getTypeID()) { case Struct: case List: return false; default: return true; } }