You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/04/15 00:14:07 UTC
arrow git commit: ARROW-777: restore getObject behavior on Date and
Time
Repository: arrow
Updated Branches:
refs/heads/master b6033378c -> 794d0204c
ARROW-777: restore getObject behavior on Date and Time
Author: Julien Le Dem <ju...@apache.org>
Closes #542 from julienledem/ARROW-777 and squashes the following commits:
c77f5a0 [Julien Le Dem] ARROW-777: restore getObject behavior on Date and Time
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/794d0204
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/794d0204
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/794d0204
Branch: refs/heads/master
Commit: 794d0204cb33bc98bce418785b4643ee4f1083d8
Parents: b603337
Author: Julien Le Dem <ju...@apache.org>
Authored: Fri Apr 14 20:14:02 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Fri Apr 14 20:14:02 2017 -0400
----------------------------------------------------------------------
.../src/main/codegen/data/ValueVectorTypes.tdd | 4 ++--
.../main/codegen/templates/FixedValueVectors.java | 18 ++++++++++++++++--
.../apache/arrow/vector/file/BaseFileTest.java | 6 ++++--
3 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/794d0204/java/vector/src/main/codegen/data/ValueVectorTypes.tdd
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/data/ValueVectorTypes.tdd b/java/vector/src/main/codegen/data/ValueVectorTypes.tdd
index b08c100..d472b55 100644
--- a/java/vector/src/main/codegen/data/ValueVectorTypes.tdd
+++ b/java/vector/src/main/codegen/data/ValueVectorTypes.tdd
@@ -59,7 +59,7 @@
{ class: "DateDay" },
{ class: "IntervalYear", javaType: "int", friendlyType: "Period" },
{ class: "TimeSec" },
- { class: "TimeMilli" }
+ { class: "TimeMilli", javaType: "int", friendlyType: "DateTime" }
]
},
{
@@ -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" },
http://git-wip-us.apache.org/repos/asf/arrow/blob/794d0204/java/vector/src/main/codegen/templates/FixedValueVectors.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/FixedValueVectors.java b/java/vector/src/main/codegen/templates/FixedValueVectors.java
index 947c82c..5c09e30 100644
--- a/java/vector/src/main/codegen/templates/FixedValueVectors.java
+++ b/java/vector/src/main/codegen/templates/FixedValueVectors.java
@@ -484,9 +484,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements F
</#if>
<#if minor.class == "DateDay" ||
- minor.class == "DateMilli" ||
minor.class == "TimeSec" ||
- minor.class == "TimeMilli" ||
minor.class == "TimeMicro" ||
minor.class == "TimeNano">
@Override
@@ -494,6 +492,22 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements F
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) {
http://git-wip-us.apache.org/repos/asf/arrow/blob/794d0204/java/vector/src/test/java/org/apache/arrow/vector/file/BaseFileTest.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/file/BaseFileTest.java b/java/vector/src/test/java/org/apache/arrow/vector/file/BaseFileTest.java
index 5c68a19..5ca083a 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/file/BaseFileTest.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/file/BaseFileTest.java
@@ -22,6 +22,8 @@ import java.util.List;
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;
@@ -173,11 +175,11 @@ public class BaseFileTest {
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));