@Override public String visit(Date type) { String name = "date"; DateUnit unit = type.getUnit(); if (unit == DateUnit.MILLISECOND) { return name; } return String.format("%s(%s)", name, unit); }
org.apache.arrow.flatbuf.Date dateType = (org.apache.arrow.flatbuf.Date) field.type(new org.apache.arrow.flatbuf.Date()); short unit = dateType.unit(); return new ArrowType.Date(DateUnit.fromFlatbufID(unit));
.addField(new Field("decimal", FieldType.nullable(new ArrowType.Decimal(0, 0)), null)) .addField(new Field("int", FieldType.nullable(new ArrowType.Int(8, false)), null)) .addField(new Field("date", FieldType.nullable(new ArrowType.Date(DateUnit.MILLISECOND)), null)) .addField(new Field("time", FieldType.nullable(new ArrowType.Time(TimeUnit.MILLISECOND, 8)), null)) .build();
return new Field(name, true, new Date(DateUnit.MILLISECOND), null);
/** * Create a field given the input {@link ColumnType} * and name * @param name the name of the field * @param columnType the column type to add * @return */ public static Field getFieldForColumn(String name,ColumnType columnType) { switch(columnType) { case Long: return field(name,new ArrowType.Int(64,false)); case Integer: return field(name,new ArrowType.Int(32,false)); case Double: return field(name,new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE)); case Float: return field(name,new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)); case Boolean: return field(name, new ArrowType.Bool()); case Categorical: return field(name,new ArrowType.Utf8()); case Time: return field(name,new ArrowType.Date(DateUnit.MILLISECOND)); case Bytes: return field(name,new ArrowType.Binary()); case NDArray: return field(name,new ArrowType.Binary()); case String: return field(name,new ArrowType.Utf8()); default: throw new IllegalArgumentException("Column type invalid " + columnType); } }
@Override public TypeLayout visit(Date type) { switch (type.getUnit()) { case DAY: return newFixedWidthTypeLayout(BufferLayout.dataBuffer(32)); case MILLISECOND: return newFixedWidthTypeLayout(BufferLayout.dataBuffer(64)); default: throw new UnsupportedOperationException("Unknown unit " + type.getUnit()); } }
@Override public MinorType visit(Date type) { switch (type.getUnit()) { case DAY: return MinorType.DATEDAY; case MILLISECOND: return MinorType.DATEMILLI; default: throw new IllegalArgumentException("unknown unit: " + type); } }