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
4 changes: 2 additions & 2 deletions java/vector/src/main/codegen/data/ValueVectorTypes.tdd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
{ class: "DateDay" },
{ class: "IntervalYear", javaType: "int", friendlyType: "Period" },
{ class: "TimeSec" },
{ class: "TimeMilli" }
{ class: "TimeMilli", javaType: "int", friendlyType: "DateTime" }
]
},
{
Expand All @@ -72,7 +72,7 @@
{ class: "BigInt"},
{ class: "UInt8" },
{ class: "Float8", javaType: "double" , boxedType: "Double", fields: [{name: "value", type: "double"}], },
{ class: "DateMilli" },
{ class: "DateMilli", javaType: "long", friendlyType: "DateTime" },
{ class: "TimeStampSec", javaType: "long", boxedType: "Long", friendlyType: "DateTime" },
{ class: "TimeStampMilli", javaType: "long", boxedType: "Long", friendlyType: "DateTime" },
{ class: "TimeStampMicro", javaType: "long", boxedType: "Long", friendlyType: "DateTime" },
Expand Down
18 changes: 16 additions & 2 deletions java/vector/src/main/codegen/templates/FixedValueVectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,30 @@ public long getTwoAsLong(int index) {
</#if>

<#if minor.class == "DateDay" ||
minor.class == "DateMilli" ||
minor.class == "TimeSec" ||
minor.class == "TimeMilli" ||
minor.class == "TimeMicro" ||
minor.class == "TimeNano">
@Override
public ${friendlyType} getObject(int index) {
return get(index);
}

<#elseif minor.class == "DateMilli">
@Override
public ${friendlyType} getObject(int index) {
org.joda.time.DateTime date = new org.joda.time.DateTime(get(index), org.joda.time.DateTimeZone.UTC);
date = date.withZoneRetainFields(org.joda.time.DateTimeZone.getDefault());
return date;
}

<#elseif minor.class == "TimeMilli">
@Override
public ${friendlyType} getObject(int index) {
org.joda.time.DateTime time = new org.joda.time.DateTime(get(index), org.joda.time.DateTimeZone.UTC);
time = time.withZoneRetainFields(org.joda.time.DateTimeZone.getDefault());
return time;
}

<#elseif minor.class == "TimeStampSec">
@Override
public ${friendlyType} getObject(int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.FieldVector;
import org.apache.arrow.vector.NullableDateMilliVector;
import org.apache.arrow.vector.NullableTimeMilliVector;
import org.apache.arrow.vector.ValueVector.Accessor;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.complex.MapVector;
Expand Down Expand Up @@ -173,11 +175,11 @@ protected void validateDateTimeContent(int count, VectorSchemaRoot root) {
Assert.assertEquals(count, root.getRowCount());
printVectors(root.getFieldVectors());
for (int i = 0; i < count; i++) {
Object dateVal = root.getVector("date").getAccessor().getObject(i);
long dateVal = ((NullableDateMilliVector)root.getVector("date")).getAccessor().get(i);
DateTime dt = makeDateTimeFromCount(i);
DateTime dateExpected = dt.minusMillis(dt.getMillisOfDay());
Assert.assertEquals(dateExpected.getMillis(), dateVal);
Object timeVal = root.getVector("time").getAccessor().getObject(i);
long timeVal = ((NullableTimeMilliVector)root.getVector("time")).getAccessor().get(i);
Assert.assertEquals(dt.getMillisOfDay(), timeVal);
Object timestampMilliVal = root.getVector("timestamp-milli").getAccessor().getObject(i);
Assert.assertTrue(dt.withZoneRetainFields(DateTimeZone.getDefault()).equals(timestampMilliVal));
Expand Down