Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/vector/src/main/codegen/data/ArrowTypes.tdd
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
{
name: "Time",
fields: []
fields: [{name: "unit", type: short, valueType: TimeUnit}, {name: "bitWidth", type: int}]
},
{
name: "Timestamp",
Expand Down
39 changes: 2 additions & 37 deletions java/vector/src/main/codegen/templates/NullableValueVectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,43 +84,8 @@ public final class ${className} extends BaseDataValueVector implements <#if type
values = new ${valuesName}(valuesField, allocator);
mutator = new Mutator();
accessor = new Accessor();
<#if minor.class == "TinyInt" ||
minor.class == "SmallInt" ||
minor.class == "Int" ||
minor.class == "BigInt">
field = new Field(name, true, new Int(${type.width} * 8, true), dictionary, null);
<#elseif minor.class == "UInt1" ||
minor.class == "UInt2" ||
minor.class == "UInt4" ||
minor.class == "UInt8">
field = new Field(name, true, new Int(${type.width} * 8, false), dictionary, null);
<#elseif minor.class == "Date">
field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Date(), dictionary, null);
<#elseif minor.class == "Time">
field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Time(), dictionary, null);
<#elseif minor.class == "Float4">
field = new Field(name, true, new FloatingPoint(org.apache.arrow.vector.types.FloatingPointPrecision.SINGLE), dictionary, null);
<#elseif minor.class == "Float8">
field = new Field(name, true, new FloatingPoint(org.apache.arrow.vector.types.FloatingPointPrecision.DOUBLE), dictionary, null);
<#elseif minor.class == "TimeStampSec">
field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.SECOND), dictionary, null);
<#elseif minor.class == "TimeStampMilli">
field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.MILLISECOND), dictionary, null);
<#elseif minor.class == "TimeStampMicro">
field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.MICROSECOND), dictionary, null);
<#elseif minor.class == "TimeStampNano">
field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.NANOSECOND), dictionary, null);
<#elseif minor.class == "IntervalDay">
field = new Field(name, true, new Interval(org.apache.arrow.vector.types.IntervalUnit.DAY_TIME), dictionary, null);
<#elseif minor.class == "IntervalYear">
field = new Field(name, true, new Interval(org.apache.arrow.vector.types.IntervalUnit.YEAR_MONTH), dictionary, null);
<#elseif minor.class == "VarChar">
field = new Field(name, true, new Utf8(), dictionary, null);
<#elseif minor.class == "VarBinary">
field = new Field(name, true, new Binary(), dictionary, null);
<#elseif minor.class == "Bit">
field = new Field(name, true, new Bool(), dictionary, null);
</#if>
ArrowType type = Types.MinorType.${minor.class?upper_case}.getType();
field = new Field(name, true, type, dictionary, null);
innerVectors = Collections.unmodifiableList(Arrays.<BufferBacked>asList(
bits,
<#if type.major = "VarLen">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public TypeLayout visit(Date type) {

@Override
public TypeLayout visit(Time type) {
return newFixedWidthTypeLayout(dataVector(64));
return newFixedWidthTypeLayout(dataVector(type.getBitWidth()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class Types {
private static final Field UINT4_FIELD = new Field("", true, new Int(32, false), null);
private static final Field UINT8_FIELD = new Field("", true, new Int(64, false), null);
private static final Field DATE_FIELD = new Field("", true, Date.INSTANCE, null);
private static final Field TIME_FIELD = new Field("", true, Time.INSTANCE, null);
private static final Field TIME_FIELD = new Field("", true, new Time(TimeUnit.MILLISECOND, 32), null);
private static final Field TIMESTAMPSEC_FIELD = new Field("", true, new Timestamp(TimeUnit.SECOND), null);
private static final Field TIMESTAMPMILLI_FIELD = new Field("", true, new Timestamp(TimeUnit.MILLISECOND), null);
private static final Field TIMESTAMPMICRO_FIELD = new Field("", true, new Timestamp(TimeUnit.MICROSECOND), null);
Expand Down Expand Up @@ -235,7 +235,7 @@ public FieldWriter getNewFieldWriter(ValueVector vector) {
return new DateWriterImpl((NullableDateVector) vector);
}
},
TIME(Time.INSTANCE) {
TIME(new Time(TimeUnit.MILLISECOND, 32)) {
@Override
public Field getField() {
return TIME_FIELD;
Expand Down Expand Up @@ -639,6 +639,9 @@ public MinorType visit(FloatingPoint type) {
}

@Override public MinorType visit(Time type) {
if (type.getUnit() != TimeUnit.MILLISECOND || type.getBitWidth() != 32) {
throw new IllegalArgumentException("Only milliseconds on 32 bits supported for now: " + type);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you need to do something like what was done with timestamps for multiple unit support?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I was thinking of doing it as a follow up. I think we need to change a little bit the notion of MinorType to avoid generating too many vector classes.

return MinorType.TIME;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testAll() throws IOException {
field("i", new ArrowType.Bool()),
field("j", new ArrowType.Decimal(5, 5)),
field("k", new ArrowType.Date()),
field("l", new ArrowType.Time()),
field("l", new ArrowType.Time(TimeUnit.MILLISECOND, 32)),
field("m", new ArrowType.Timestamp(TimeUnit.MILLISECOND)),
field("n", new ArrowType.Interval(IntervalUnit.DAY_TIME))
));
Expand Down