arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jul...@apache.org
Subject arrow git commit: ARROW-270: Define more generic Interval logical type
Date Tue, 27 Sep 2016 16:45:36 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 45d88328d -> 03134b11f


ARROW-270: Define more generic Interval logical type

Author: Julien Le Dem <julien@dremio.com>

Closes #144 from julienledem/interval and squashes the following commits:

eb76fed [Julien Le Dem] ARROW-270: Define more generic Interval logical type


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/03134b11
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/03134b11
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/03134b11

Branch: refs/heads/master
Commit: 03134b11ffd4f63bda2f3cb448713600df6d8fdb
Parents: 45d8832
Author: Julien Le Dem <julien@dremio.com>
Authored: Tue Sep 27 09:45:32 2016 -0700
Committer: Julien Le Dem <julien@dremio.com>
Committed: Tue Sep 27 09:45:32 2016 -0700

----------------------------------------------------------------------
 format/Message.fbs                              | 10 ++++------
 .../vector/src/main/codegen/data/ArrowTypes.tdd |  8 ++------
 .../codegen/templates/NullableValueVectors.java |  4 ++--
 .../apache/arrow/vector/schema/TypeLayout.java  | 21 +++++++++++---------
 .../org/apache/arrow/vector/types/Types.java    | 14 ++++++-------
 5 files changed, 27 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/03134b11/format/Message.fbs
----------------------------------------------------------------------
diff --git a/format/Message.fbs b/format/Message.fbs
index 657904a..07da862 100644
--- a/format/Message.fbs
+++ b/format/Message.fbs
@@ -63,10 +63,9 @@ table Timestamp {
   timezone: string;
 }
 
-table IntervalDay {
-}
-
-table IntervalYear {
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+table Interval {
+  unit: IntervalUnit;
 }
 
 table JSONScalar {
@@ -88,8 +87,7 @@ union Type {
   Date,
   Time,
   Timestamp,
-  IntervalDay,
-  IntervalYear,
+  Interval,
   List,
   Struct_,
   Union,

http://git-wip-us.apache.org/repos/asf/arrow/blob/03134b11/java/vector/src/main/codegen/data/ArrowTypes.tdd
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/data/ArrowTypes.tdd b/java/vector/src/main/codegen/data/ArrowTypes.tdd
index 5cb43be..9f81f0e 100644
--- a/java/vector/src/main/codegen/data/ArrowTypes.tdd
+++ b/java/vector/src/main/codegen/data/ArrowTypes.tdd
@@ -69,12 +69,8 @@
       fields: [{name: "timezone", type: "String"}]
     },
     {
-      name: "IntervalDay",
-      fields: []
-    },
-    {
-      name: "IntervalYear",
-      fields: []
+      name: "Interval",
+      fields: [{name: "unit", type: short}]
     }
   ]
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/03134b11/java/vector/src/main/codegen/templates/NullableValueVectors.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/NullableValueVectors.java b/java/vector/src/main/codegen/templates/NullableValueVectors.java
index 486cfee..8f325af 100644
--- a/java/vector/src/main/codegen/templates/NullableValueVectors.java
+++ b/java/vector/src/main/codegen/templates/NullableValueVectors.java
@@ -105,9 +105,9 @@ public final class ${className} extends BaseDataValueVector implements
<#if type
   <#elseif minor.class == "TimeStamp">
     field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(""),
null);
   <#elseif minor.class == "IntervalDay">
-    field = new Field(name, true, new IntervalDay(), null);
+    field = new Field(name, true, new Interval(org.apache.arrow.flatbuf.IntervalUnit.DAY_TIME),
null);
   <#elseif minor.class == "IntervalYear">
-    field = new Field(name, true, new IntervalYear(), null);
+    field = new Field(name, true, new Interval(org.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH),
null);
   <#elseif minor.class == "VarChar">
     field = new Field(name, true, new Utf8(), null);
   <#elseif minor.class == "VarBinary">

http://git-wip-us.apache.org/repos/asf/arrow/blob/03134b11/java/vector/src/main/java/org/apache/arrow/vector/schema/TypeLayout.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/schema/TypeLayout.java b/java/vector/src/main/java/org/apache/arrow/vector/schema/TypeLayout.java
index 885ac2a..072385a 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/schema/TypeLayout.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/schema/TypeLayout.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.arrow.flatbuf.IntervalUnit;
 import org.apache.arrow.flatbuf.UnionMode;
 import org.apache.arrow.vector.types.pojo.ArrowType;
 import org.apache.arrow.vector.types.pojo.ArrowType.ArrowTypeVisitor;
@@ -40,12 +41,11 @@ import org.apache.arrow.vector.types.pojo.ArrowType.Date;
 import org.apache.arrow.vector.types.pojo.ArrowType.Decimal;
 import org.apache.arrow.vector.types.pojo.ArrowType.FloatingPoint;
 import org.apache.arrow.vector.types.pojo.ArrowType.Int;
-import org.apache.arrow.vector.types.pojo.ArrowType.IntervalDay;
-import org.apache.arrow.vector.types.pojo.ArrowType.IntervalYear;
+import org.apache.arrow.vector.types.pojo.ArrowType.Interval;
 import org.apache.arrow.vector.types.pojo.ArrowType.Null;
+import org.apache.arrow.vector.types.pojo.ArrowType.Struct_;
 import org.apache.arrow.vector.types.pojo.ArrowType.Time;
 import org.apache.arrow.vector.types.pojo.ArrowType.Timestamp;
-import org.apache.arrow.vector.types.pojo.ArrowType.Struct_;
 import org.apache.arrow.vector.types.pojo.ArrowType.Union;
 import org.apache.arrow.vector.types.pojo.ArrowType.Utf8;
 
@@ -167,14 +167,17 @@ public class TypeLayout {
       }
 
       @Override
-      public TypeLayout visit(IntervalDay type) { // TODO: check size
-        return newFixedWidthTypeLayout(dataVector(64));
+      public TypeLayout visit(Interval type) { // TODO: check size
+        switch (type.getUnit()) {
+        case IntervalUnit.DAY_TIME:
+          return newFixedWidthTypeLayout(dataVector(64));
+        case IntervalUnit.YEAR_MONTH:
+          return newFixedWidthTypeLayout(dataVector(64));
+        default:
+          throw new UnsupportedOperationException("Unknown unit " + type.getUnit());
+        }
       }
 
-      @Override
-      public TypeLayout visit(IntervalYear type) { // TODO: check size
-        return newFixedWidthTypeLayout(dataVector(64));
-      }
     });
     return layout;
   }

http://git-wip-us.apache.org/repos/asf/arrow/blob/03134b11/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java b/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java
index 66ef756..181d835 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java
@@ -20,6 +20,7 @@ package org.apache.arrow.vector.types;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.arrow.flatbuf.IntervalUnit;
 import org.apache.arrow.flatbuf.Precision;
 import org.apache.arrow.flatbuf.Type;
 import org.apache.arrow.flatbuf.UnionMode;
@@ -78,13 +79,12 @@ import org.apache.arrow.vector.types.pojo.ArrowType.Bool;
 import org.apache.arrow.vector.types.pojo.ArrowType.Date;
 import org.apache.arrow.vector.types.pojo.ArrowType.FloatingPoint;
 import org.apache.arrow.vector.types.pojo.ArrowType.Int;
-import org.apache.arrow.vector.types.pojo.ArrowType.IntervalDay;
-import org.apache.arrow.vector.types.pojo.ArrowType.IntervalYear;
+import org.apache.arrow.vector.types.pojo.ArrowType.Interval;
 import org.apache.arrow.vector.types.pojo.ArrowType.List;
 import org.apache.arrow.vector.types.pojo.ArrowType.Null;
+import org.apache.arrow.vector.types.pojo.ArrowType.Struct_;
 import org.apache.arrow.vector.types.pojo.ArrowType.Time;
 import org.apache.arrow.vector.types.pojo.ArrowType.Timestamp;
-import org.apache.arrow.vector.types.pojo.ArrowType.Struct_;
 import org.apache.arrow.vector.types.pojo.ArrowType.Union;
 import org.apache.arrow.vector.types.pojo.ArrowType.Utf8;
 import org.apache.arrow.vector.types.pojo.Field;
@@ -104,8 +104,8 @@ public class Types {
   public static final Field DATE_FIELD = new Field("", true, Date.INSTANCE, null);
   public static final Field TIME_FIELD = new Field("", true, Time.INSTANCE, null);
   public static final Field TIMESTAMP_FIELD = new Field("", true, new Timestamp(""), null);
-  public static final Field INTERVALDAY_FIELD = new Field("", true, IntervalDay.INSTANCE,
null);
-  public static final Field INTERVALYEAR_FIELD = new Field("", true, IntervalYear.INSTANCE,
null);
+  public static final Field INTERVALDAY_FIELD = new Field("", true, new Interval(IntervalUnit.DAY_TIME),
null);
+  public static final Field INTERVALYEAR_FIELD = new Field("", true, new Interval(IntervalUnit.YEAR_MONTH),
null);
   public static final Field FLOAT4_FIELD = new Field("", true, new FloatingPoint(Precision.SINGLE),
null);
   public static final Field FLOAT8_FIELD = new Field("", true, new FloatingPoint(Precision.DOUBLE),
null);
   public static final Field LIST_FIELD = new Field("", true, List.INSTANCE, null);
@@ -260,7 +260,7 @@ public class Types {
         return new TimeStampWriterImpl((NullableTimeStampVector) vector);
       }
     },
-    INTERVALDAY(IntervalDay.INSTANCE) {
+    INTERVALDAY(new Interval(IntervalUnit.DAY_TIME)) {
       @Override
       public Field getField() {
         return INTERVALDAY_FIELD;
@@ -276,7 +276,7 @@ public class Types {
         return new IntervalDayWriterImpl((NullableIntervalDayVector) vector);
       }
     },
-    INTERVALYEAR(IntervalYear.INSTANCE) {
+    INTERVALYEAR(new Interval(IntervalUnit.YEAR_MONTH)) {
       @Override
       public Field getField() {
         return INTERVALYEAR_FIELD;


Mime
View raw message