arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-335: Improve Type apis and toString() by encapsulating flatbuffers better
Date Fri, 02 Dec 2016 16:51:28 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 06be7aed0 -> ebe7dc8f5


ARROW-335: Improve Type apis and toString() by encapsulating flatbuffers better

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

Closes #172 from julienledem/tostring and squashes the following commits:

546aa02 [Julien Le Dem] fix rebase issues
262ae9f [Julien Le Dem] review feedback
41d5627 [Julien Le Dem] ARROW-335: Improve Type apis and toString() by encapsulating flatbuffers better


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

Branch: refs/heads/master
Commit: ebe7dc8f5ff32f5fa86625d4c622b4e075e95ae0
Parents: 06be7ae
Author: Julien Le Dem <julien@dremio.com>
Authored: Fri Dec 2 11:51:22 2016 -0500
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Fri Dec 2 11:51:22 2016 -0500

----------------------------------------------------------------------
 .../vector/src/main/codegen/data/ArrowTypes.tdd |   8 +-
 .../src/main/codegen/templates/ArrowType.java   | 172 ++++---------------
 .../codegen/templates/NullableValueVectors.java |  10 +-
 .../src/main/codegen/templates/UnionVector.java |   4 +-
 .../vector/complex/BaseRepeatedValueVector.java |   5 +-
 .../apache/arrow/vector/complex/MapVector.java  |   4 +-
 .../apache/arrow/vector/schema/TypeLayout.java  |  19 +-
 .../arrow/vector/schema/VectorLayout.java       |   2 +-
 .../vector/types/FloatingPointPrecision.java    |  47 +++++
 .../apache/arrow/vector/types/IntervalUnit.java |  44 +++++
 .../org/apache/arrow/vector/types/TimeUnit.java |  46 +++++
 .../org/apache/arrow/vector/types/Types.java    |  38 ++--
 .../apache/arrow/vector/types/UnionMode.java    |  44 +++++
 .../apache/arrow/vector/types/pojo/Field.java   |  14 +-
 .../apache/arrow/vector/types/pojo/Schema.java  |   3 +-
 .../complex/impl/TestPromotableWriter.java      |   7 +-
 .../complex/writer/TestComplexWriter.java       |  15 +-
 .../apache/arrow/vector/pojo/TestConvert.java   |  14 +-
 .../arrow/vector/types/pojo/TestSchema.java     |  36 +++-
 19 files changed, 318 insertions(+), 214 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/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 c0b942b..01465e5 100644
--- a/java/vector/src/main/codegen/data/ArrowTypes.tdd
+++ b/java/vector/src/main/codegen/data/ArrowTypes.tdd
@@ -26,7 +26,7 @@
     },
     {
       name: "Union",
-      fields: [{name: "mode", type: short}, {name: "typeIds", type: "int[]"}]
+      fields: [{name: "mode", type: short, valueType: UnionMode}, {name: "typeIds", type: "int[]"}]
     },
     {
       name: "Int",
@@ -34,7 +34,7 @@
     },
     {
       name: "FloatingPoint",
-      fields: [{name: precision, type: short}]
+      fields: [{name: precision, type: short, valueType: FloatingPointPrecision}]
     },
     {
       name: "Utf8",
@@ -62,11 +62,11 @@
     },
     {
       name: "Timestamp",
-      fields: [{name: "unit", type: short}]
+      fields: [{name: "unit", type: short, valueType: TimeUnit}]
     },
     {
       name: "Interval",
-      fields: [{name: "unit", type: short}]
+      fields: [{name: "unit", type: short, valueType: IntervalUnit}]
     }
   ]
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/codegen/templates/ArrowType.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/ArrowType.java b/java/vector/src/main/codegen/templates/ArrowType.java
index 4069e60..85ea389 100644
--- a/java/vector/src/main/codegen/templates/ArrowType.java
+++ b/java/vector/src/main/codegen/templates/ArrowType.java
@@ -23,30 +23,18 @@
 package org.apache.arrow.vector.types.pojo;
 
 import com.google.flatbuffers.FlatBufferBuilder;
-import org.apache.arrow.flatbuf.Type;
 
-import java.io.IOException;
 import java.util.Objects;
 
-import org.apache.arrow.flatbuf.Precision;
-import org.apache.arrow.flatbuf.UnionMode;
-import org.apache.arrow.flatbuf.TimeUnit;
-import org.apache.arrow.flatbuf.IntervalUnit;
+import org.apache.arrow.flatbuf.Type;
+
+import org.apache.arrow.vector.types.*;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonSubTypes;
 import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 
 /**
  * Arrow types
@@ -57,119 +45,31 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
   property = "name")
 @JsonSubTypes({
 <#list arrowTypes.types as type>
-  @JsonSubTypes.Type(value = ArrowType.${type.name}.class, name = "${type.name?remove_ending("_")?lower_case}"),
+  @JsonSubTypes.Type(value = ArrowType.${type.name?remove_ending("_")}.class, name = "${type.name?remove_ending("_")?lower_case}"),
 </#list>
 })
 public abstract class ArrowType {
 
-  private static class FloatingPointPrecisionSerializer extends JsonSerializer<Short> {
-    @Override
-    public void serialize(Short precision,
-        JsonGenerator jsonGenerator,
-        SerializerProvider serializerProvider)
-            throws IOException, JsonProcessingException {
-      jsonGenerator.writeObject(Precision.name(precision));
-    }
-  }
-
-  private static class FloatingPointPrecisionDeserializer extends JsonDeserializer<Short> {
-    @Override
-    public Short deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
-      String name = p.getText();
-      switch(name) {
-        case "HALF":
-          return Precision.HALF;
-        case "SINGLE":
-          return Precision.SINGLE;
-        case "DOUBLE":
-          return Precision.DOUBLE;
-        default:
-          throw new IllegalArgumentException("unknown precision: " + name);
-      }
-    }
-  }
-
-  private static class UnionModeSerializer extends JsonSerializer<Short> {
-    @Override
-    public void serialize(Short mode,
-        JsonGenerator jsonGenerator,
-        SerializerProvider serializerProvider)
-            throws IOException, JsonProcessingException {
-      jsonGenerator.writeObject(UnionMode.name(mode));
-    }
-  }
-
-  private static class UnionModeDeserializer extends JsonDeserializer<Short> {
-    @Override
-    public Short deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
-      String name = p.getText();
-      switch(name) {
-        case "Sparse":
-          return UnionMode.Sparse;
-        case "Dense":
-          return UnionMode.Dense;
-        default:
-          throw new IllegalArgumentException("unknown union mode: " + name);
-      }
-    }
-  }
-
-  private static class TimestampUnitSerializer extends JsonSerializer<Short> {
-    @Override
-    public void serialize(Short unit,
-        JsonGenerator jsonGenerator,
-        SerializerProvider serializerProvider)
-            throws IOException, JsonProcessingException {
-      jsonGenerator.writeObject(TimeUnit.name(unit));
-    }
-  }
-
-  private static class TimestampUnitDeserializer extends JsonDeserializer<Short> {
-    @Override
-    public Short deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
-      String name = p.getText();
-      switch(name) {
-        case "SECOND":
-          return TimeUnit.SECOND;
-        case "MILLISECOND":
-          return TimeUnit.MILLISECOND;
-        case "MICROSECOND":
-          return TimeUnit.MICROSECOND;
-        case "NANOSECOND":
-          return TimeUnit.NANOSECOND;
-        default:
-          throw new IllegalArgumentException("unknown time unit: " + name);
-      }
-    }
-  }
+  public static enum ArrowTypeID {
+    <#list arrowTypes.types as type>
+    <#assign name = type.name>
+    ${name?remove_ending("_")}(Type.${name}),
+    </#list>
+    NONE(Type.NONE);
+  
+    private final byte flatbufType;
 
-  private static class IntervalUnitSerializer extends JsonSerializer<Short> {
-    @Override
-    public void serialize(Short unit,
-        JsonGenerator jsonGenerator,
-        SerializerProvider serializerProvider)
-            throws IOException, JsonProcessingException {
-      jsonGenerator.writeObject(IntervalUnit.name(unit));
+    public byte getFlatbufID() {
+      return this.flatbufType;
     }
-  }
 
-  private static class IntervalUnitDeserializer extends JsonDeserializer<Short> {
-    @Override
-    public Short deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
-      String name = p.getText();
-      switch(name) {
-        case "YEAR_MONTH":
-          return IntervalUnit.YEAR_MONTH;
-        case "DAY_TIME":
-          return IntervalUnit.DAY_TIME;
-        default:
-          throw new IllegalArgumentException("unknown interval unit: " + name);
-      }
+    private ArrowTypeID(byte flatbufType) {
+      this.flatbufType = flatbufType;
     }
   }
 
   @JsonIgnore
-  public abstract byte getTypeType();
+  public abstract ArrowTypeID getTypeID();
   public abstract int getType(FlatBufferBuilder builder);
   public abstract <T> T accept(ArrowTypeVisitor<T> visitor);
 
@@ -183,28 +83,30 @@ public abstract class ArrowType {
    */
   public static interface ArrowTypeVisitor<T> {
   <#list arrowTypes.types as type>
-    T visit(${type.name} type);
+    T visit(${type.name?remove_ending("_")} type);
   </#list>
   }
 
   <#list arrowTypes.types as type>
-  <#assign name = type.name>
+  <#assign name = type.name?remove_ending("_")>
   <#assign fields = type.fields>
   public static class ${name} extends ArrowType {
-    public static final byte TYPE_TYPE = Type.${name};
+    public static final ArrowTypeID TYPE_TYPE = ArrowTypeID.${name};
     <#if type.fields?size == 0>
     public static final ${name} INSTANCE = new ${name}();
     </#if>
 
     <#list fields as field>
-    ${field.type} ${field.name};
+    <#assign fieldType = field.valueType!field.type>
+    ${fieldType} ${field.name};
     </#list>
 
     <#if type.fields?size != 0>
     @JsonCreator
     public ${type.name}(
     <#list type.fields as field>
-      <#if field.type == "short"> @JsonDeserialize(using = ${type.name}${field.name?cap_first}Deserializer.class) </#if>@JsonProperty("${field.name}") ${field.type} ${field.name}<#if field_has_next>, </#if>
+    <#assign fieldType = field.valueType!field.type>
+      @JsonProperty("${field.name}") ${fieldType} ${field.name}<#if field_has_next>, </#if>
     </#list>
     ) {
       <#list type.fields as field>
@@ -214,7 +116,7 @@ public abstract class ArrowType {
     </#if>
 
     @Override
-    public byte getTypeType() {
+    public ArrowTypeID getTypeID() {
       return TYPE_TYPE;
     }
 
@@ -235,27 +137,29 @@ public abstract class ArrowType {
         org.apache.arrow.flatbuf.${type.name}.add${field.name?cap_first}(builder, ${field.name});
       }
       <#else>
-      org.apache.arrow.flatbuf.${type.name}.add${field.name?cap_first}(builder, this.${field.name});
+      org.apache.arrow.flatbuf.${type.name}.add${field.name?cap_first}(builder, this.${field.name}<#if field.valueType??>.getFlatbufID()</#if>);
       </#if>
       </#list>
       return org.apache.arrow.flatbuf.${type.name}.end${type.name}(builder);
     }
 
     <#list fields as field>
-      <#if field.type == "short">
-    @JsonSerialize(using = ${type.name}${field.name?cap_first}Serializer.class)
-      </#if>
-    public ${field.type} get${field.name?cap_first}() {
+    <#assign fieldType = field.valueType!field.type>
+    public ${fieldType} get${field.name?cap_first}() {
       return ${field.name};
     }
     </#list>
 
     public String toString() {
-      return "${name}{"
+      return "${name}"
+      <#if fields?size != 0>
+        + "("
       <#list fields as field>
-        + <#if field.type == "int[]">java.util.Arrays.toString(${field.name})<#else>${field.name}</#if><#if field_has_next> + ", " </#if>
+        +   <#if field.type == "int[]">java.util.Arrays.toString(${field.name})<#else>${field.name}</#if><#if field_has_next> + ", " </#if>
       </#list>
-      + "}";
+        + ")"
+      </#if>
+      ;
     }
 
     @Override
@@ -265,7 +169,7 @@ public abstract class ArrowType {
 
     @Override
     public boolean equals(Object obj) {
-      if (!(obj instanceof ${type.name})) {
+      if (!(obj instanceof ${name})) {
         return false;
       }
       <#if type.fields?size == 0>
@@ -287,7 +191,7 @@ public abstract class ArrowType {
   public static org.apache.arrow.vector.types.pojo.ArrowType getTypeForField(org.apache.arrow.flatbuf.Field field) {
     switch(field.typeType()) {
     <#list arrowTypes.types as type>
-    <#assign name = type.name>
+    <#assign name = type.name?remove_ending("_")>
     <#assign nameLower = type.name?lower_case>
     <#assign fields = type.fields>
     case Type.${type.name}: {
@@ -302,7 +206,7 @@ public abstract class ArrowType {
       ${field.type} ${field.name} = ${nameLower}Type.${field.name}();
       </#if>
       </#list>
-      return new ${type.name}(<#list type.fields as field>${field.name}<#if field_has_next>, </#if></#list>);
+      return new ${name}(<#list type.fields as field><#if field.valueType??>${field.valueType}.fromFlatbufID(${field.name})<#else>${field.name}</#if><#if field_has_next>, </#if></#list>);
     }
     </#list>
     default:

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/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 716fedc..2c4274c 100644
--- a/java/vector/src/main/codegen/templates/NullableValueVectors.java
+++ b/java/vector/src/main/codegen/templates/NullableValueVectors.java
@@ -99,15 +99,15 @@ public final class ${className} extends BaseDataValueVector implements <#if type
   <#elseif minor.class == "Time">
     field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Time(), null);
   <#elseif minor.class == "Float4">
-    field = new Field(name, true, new FloatingPoint(Precision.SINGLE), null);
+    field = new Field(name, true, new FloatingPoint(org.apache.arrow.vector.types.FloatingPointPrecision.SINGLE), null);
   <#elseif minor.class == "Float8">
-    field = new Field(name, true, new FloatingPoint(Precision.DOUBLE), null);
+    field = new Field(name, true, new FloatingPoint(org.apache.arrow.vector.types.FloatingPointPrecision.DOUBLE), null);
   <#elseif minor.class == "TimeStamp">
-    field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.flatbuf.TimeUnit.MILLISECOND), null);
+    field = new Field(name, true, new org.apache.arrow.vector.types.pojo.ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.MILLISECOND), null);
   <#elseif minor.class == "IntervalDay">
-    field = new Field(name, true, new Interval(org.apache.arrow.flatbuf.IntervalUnit.DAY_TIME), null);
+    field = new Field(name, true, new Interval(org.apache.arrow.vector.types.IntervalUnit.DAY_TIME), null);
   <#elseif minor.class == "IntervalYear">
-    field = new Field(name, true, new Interval(org.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH), null);
+    field = new Field(name, true, new Interval(org.apache.arrow.vector.types.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/ebe7dc8f/java/vector/src/main/codegen/templates/UnionVector.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/codegen/templates/UnionVector.java b/java/vector/src/main/codegen/templates/UnionVector.java
index 9608b3c..ea1fdf6 100644
--- a/java/vector/src/main/codegen/templates/UnionVector.java
+++ b/java/vector/src/main/codegen/templates/UnionVector.java
@@ -15,8 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import java.util.List;
-
 <@pp.dropOutputFile />
 <@pp.changeOutputFile name="/org/apache/arrow/vector/complex/UnionVector.java" />
 
@@ -35,7 +33,7 @@ import org.apache.arrow.vector.complex.impl.ComplexCopier;
 import org.apache.arrow.vector.util.CallBack;
 import org.apache.arrow.vector.schema.ArrowFieldNode;
 
-import static org.apache.arrow.flatbuf.UnionMode.Sparse;
+import static org.apache.arrow.vector.types.UnionMode.Sparse;
 
 
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java
index 517d20c..7424df4 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java
@@ -20,7 +20,6 @@ package org.apache.arrow.vector.complex;
 import java.util.Collections;
 import java.util.Iterator;
 
-import org.apache.arrow.flatbuf.Type;
 import org.apache.arrow.memory.BufferAllocator;
 import org.apache.arrow.vector.AddOrGetResult;
 import org.apache.arrow.vector.BaseValueVector;
@@ -159,9 +158,9 @@ public abstract class BaseRepeatedValueVector extends BaseValueVector implements
       created = true;
     }
 
-    if (vector.getField().getType().getTypeType() != minorType.getType().getTypeType()) {
+    if (vector.getField().getType().getTypeID() != minorType.getType().getTypeID()) {
       final String msg = String.format("Inner vector type mismatch. Requested type: [%s], actual type: [%s]",
-          Type.name(minorType.getType().getTypeType()), Type.name(vector.getField().getType().getTypeType()));
+          minorType.getType().getTypeID(), vector.getField().getType().getTypeID());
       throw new SchemaChangeRuntimeException(msg);
     }
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java
index aaecb95..c2f216b 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java
@@ -34,7 +34,7 @@ import org.apache.arrow.vector.complex.reader.FieldReader;
 import org.apache.arrow.vector.holders.ComplexHolder;
 import org.apache.arrow.vector.types.Types;
 import org.apache.arrow.vector.types.Types.MinorType;
-import org.apache.arrow.vector.types.pojo.ArrowType.Struct_;
+import org.apache.arrow.vector.types.pojo.ArrowType.Struct;
 import org.apache.arrow.vector.types.pojo.Field;
 import org.apache.arrow.vector.util.CallBack;
 import org.apache.arrow.vector.util.JsonStringHashMap;
@@ -290,7 +290,7 @@ public class MapVector extends AbstractMapVector {
     for (ValueVector child : getChildren()) {
       children.add(child.getField());
     }
-    return new Field(name, false, Struct_.INSTANCE, children);
+    return new Field(name, false, Struct.INSTANCE, children);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/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 c5f53fe..0b58691 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
@@ -18,9 +18,6 @@
 package org.apache.arrow.vector.schema;
 
 import static java.util.Arrays.asList;
-import static org.apache.arrow.flatbuf.Precision.DOUBLE;
-import static org.apache.arrow.flatbuf.Precision.HALF;
-import static org.apache.arrow.flatbuf.Precision.SINGLE;
 import static org.apache.arrow.vector.schema.VectorLayout.booleanVector;
 import static org.apache.arrow.vector.schema.VectorLayout.byteVector;
 import static org.apache.arrow.vector.schema.VectorLayout.dataVector;
@@ -32,8 +29,6 @@ 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;
 import org.apache.arrow.vector.types.pojo.ArrowType.Binary;
@@ -44,7 +39,7 @@ 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.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.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.Union;
@@ -72,7 +67,7 @@ public class TypeLayout {
       @Override public TypeLayout visit(Union type) {
         List<VectorLayout> vectors;
         switch (type.getMode()) {
-          case UnionMode.Dense:
+          case Dense:
             vectors = asList(
                 // TODO: validate this
                 validityVector(),
@@ -80,7 +75,7 @@ public class TypeLayout {
                 offsetVector() // offset to find the vector
                 );
             break;
-          case UnionMode.Sparse:
+          case Sparse:
             vectors = asList(
                 typeVector() // type of the value at the index or 0 if null
                 );
@@ -91,7 +86,7 @@ public class TypeLayout {
         return new TypeLayout(vectors);
       }
 
-      @Override public TypeLayout visit(Struct_ type) {
+      @Override public TypeLayout visit(Struct type) {
         List<VectorLayout> vectors = asList(
             validityVector()
             );
@@ -175,9 +170,9 @@ public class TypeLayout {
       @Override
       public TypeLayout visit(Interval type) { // TODO: check size
         switch (type.getUnit()) {
-        case IntervalUnit.DAY_TIME:
+        case DAY_TIME:
           return newFixedWidthTypeLayout(dataVector(64));
-        case IntervalUnit.YEAR_MONTH:
+        case YEAR_MONTH:
           return newFixedWidthTypeLayout(dataVector(64));
         default:
           throw new UnsupportedOperationException("Unknown unit " + type.getUnit());
@@ -215,7 +210,7 @@ public class TypeLayout {
   }
 
   public String toString() {
-    return "TypeLayout{" + vectors + "}";
+    return vectors.toString();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/schema/VectorLayout.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/schema/VectorLayout.java b/java/vector/src/main/java/org/apache/arrow/vector/schema/VectorLayout.java
index 931c00a..2073795 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/schema/VectorLayout.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/schema/VectorLayout.java
@@ -101,7 +101,7 @@ public class VectorLayout implements FBSerializable {
 
   @Override
   public String toString() {
-    return String.format("{width=%s,type=%s}", typeBitWidth, type);
+    return String.format("%s(%s)", type, typeBitWidth);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java b/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java
new file mode 100644
index 0000000..3206969
--- /dev/null
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/FloatingPointPrecision.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.arrow.vector.types;
+
+import org.apache.arrow.flatbuf.Precision;
+
+public enum FloatingPointPrecision {
+  HALF(Precision.HALF),
+  SINGLE(Precision.SINGLE),
+  DOUBLE(Precision.DOUBLE);
+
+  private static final FloatingPointPrecision[] valuesByFlatbufId = new FloatingPointPrecision[FloatingPointPrecision.values().length];
+  static {
+    for (FloatingPointPrecision v : FloatingPointPrecision.values()) {
+      valuesByFlatbufId[v.flatbufID] = v;
+    }
+  }
+
+  private short flatbufID;
+
+  private FloatingPointPrecision(short flatbufID) {
+    this.flatbufID = flatbufID;
+  }
+
+  public short getFlatbufID() {
+    return flatbufID;
+  }
+
+  public static FloatingPointPrecision fromFlatbufID(short id) {
+    return valuesByFlatbufId[id];
+  }
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/types/IntervalUnit.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/IntervalUnit.java b/java/vector/src/main/java/org/apache/arrow/vector/types/IntervalUnit.java
new file mode 100644
index 0000000..b3ddf1f
--- /dev/null
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/IntervalUnit.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.arrow.vector.types;
+
+public enum IntervalUnit {
+  YEAR_MONTH(org.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH),
+  DAY_TIME(org.apache.arrow.flatbuf.IntervalUnit.DAY_TIME);
+
+  private static final IntervalUnit[] valuesByFlatbufId = new IntervalUnit[IntervalUnit.values().length];
+  static {
+    for (IntervalUnit v : IntervalUnit.values()) {
+      valuesByFlatbufId[v.flatbufID] = v;
+    }
+  }
+
+  private short flatbufID;
+
+  private IntervalUnit(short flatbufID) {
+    this.flatbufID = flatbufID;
+  }
+
+  public short getFlatbufID() {
+    return flatbufID;
+  }
+
+  public static IntervalUnit fromFlatbufID(short id) {
+    return valuesByFlatbufId[id];
+  }
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/types/TimeUnit.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/TimeUnit.java b/java/vector/src/main/java/org/apache/arrow/vector/types/TimeUnit.java
new file mode 100644
index 0000000..cea9866
--- /dev/null
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/TimeUnit.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.arrow.vector.types;
+
+public enum TimeUnit {
+  SECOND(org.apache.arrow.flatbuf.TimeUnit.SECOND),
+  MILLISECOND(org.apache.arrow.flatbuf.TimeUnit.MILLISECOND),
+  MICROSECOND(org.apache.arrow.flatbuf.TimeUnit.MICROSECOND),
+  NANOSECOND(org.apache.arrow.flatbuf.TimeUnit.NANOSECOND);
+
+  private static final TimeUnit[] valuesByFlatbufId = new TimeUnit[TimeUnit.values().length];
+  static {
+    for (TimeUnit v : TimeUnit.values()) {
+      valuesByFlatbufId[v.flatbufID] = v;
+    }
+  }
+
+  private final short flatbufID;
+
+  TimeUnit(short flatbufID) {
+    this.flatbufID = flatbufID;
+  }
+
+  public short getFlatbufID() {
+    return flatbufID;
+  }
+
+  public static TimeUnit fromFlatbufID(short id) {
+    return valuesByFlatbufId[id];
+  }
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/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 d959367..2a2fb74 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
@@ -17,10 +17,10 @@
  */
 package org.apache.arrow.vector.types;
 
-import org.apache.arrow.flatbuf.IntervalUnit;
-import org.apache.arrow.flatbuf.Precision;
-import org.apache.arrow.flatbuf.TimeUnit;
-import org.apache.arrow.flatbuf.UnionMode;
+import static org.apache.arrow.vector.types.FloatingPointPrecision.DOUBLE;
+import static org.apache.arrow.vector.types.FloatingPointPrecision.SINGLE;
+import static org.apache.arrow.vector.types.UnionMode.Sparse;
+
 import org.apache.arrow.memory.BufferAllocator;
 import org.apache.arrow.vector.FieldVector;
 import org.apache.arrow.vector.NullableBigIntVector;
@@ -81,7 +81,7 @@ import org.apache.arrow.vector.types.pojo.ArrowType.Int;
 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.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.Union;
@@ -102,11 +102,11 @@ public class Types {
   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 TIMESTAMP_FIELD = new Field("", true, new Timestamp(org.apache.arrow.flatbuf.TimeUnit.MILLISECOND), null);
+  private static final Field TIMESTAMP_FIELD = new Field("", true, new Timestamp(TimeUnit.MILLISECOND), null);
   private static final Field INTERVALDAY_FIELD = new Field("", true, new Interval(IntervalUnit.DAY_TIME), null);
   private static final Field INTERVALYEAR_FIELD = new Field("", true, new Interval(IntervalUnit.YEAR_MONTH), null);
-  private static final Field FLOAT4_FIELD = new Field("", true, new FloatingPoint(Precision.SINGLE), null);
-  private static final Field FLOAT8_FIELD = new Field("", true, new FloatingPoint(Precision.DOUBLE), null);
+  private static final Field FLOAT4_FIELD = new Field("", true, new FloatingPoint(FloatingPointPrecision.SINGLE), null);
+  private static final Field FLOAT8_FIELD = new Field("", true, new FloatingPoint(FloatingPointPrecision.DOUBLE), null);
   private static final Field VARCHAR_FIELD = new Field("", true, Utf8.INSTANCE, null);
   private static final Field VARBINARY_FIELD = new Field("", true, Binary.INSTANCE, null);
   private static final Field BIT_FIELD = new Field("", true, Bool.INSTANCE, null);
@@ -129,7 +129,7 @@ public class Types {
         return null;
       }
     },
-    MAP(Struct_.INSTANCE) {
+    MAP(Struct.INSTANCE) {
       @Override
       public Field getField() {
         throw new UnsupportedOperationException("Cannot get simple field for Map type");
@@ -242,7 +242,7 @@ public class Types {
       }
     },
     // time in millis from the Unix epoch, 00:00:00.000 on 1 January 1970, UTC.
-    TIMESTAMP(new Timestamp(org.apache.arrow.flatbuf.TimeUnit.MILLISECOND)) {
+    TIMESTAMP(new Timestamp(org.apache.arrow.vector.types.TimeUnit.MILLISECOND)) {
       @Override
       public Field getField() {
         return TIMESTAMP_FIELD;
@@ -291,7 +291,7 @@ public class Types {
       }
     },
     //  4 byte ieee 754
-    FLOAT4(new FloatingPoint(Precision.SINGLE)) {
+    FLOAT4(new FloatingPoint(SINGLE)) {
       @Override
       public Field getField() {
         return FLOAT4_FIELD;
@@ -308,7 +308,7 @@ public class Types {
       }
     },
     //  8 byte ieee 754
-    FLOAT8(new FloatingPoint(Precision.DOUBLE)) {
+    FLOAT8(new FloatingPoint(DOUBLE)) {
       @Override
       public Field getField() {
         return FLOAT8_FIELD;
@@ -472,7 +472,7 @@ public class Types {
         return new UnionListWriter((ListVector) vector);
       }
     },
-    UNION(new Union(UnionMode.Sparse, null)) {
+    UNION(new Union(Sparse, null)) {
       @Override
       public Field getField() {
         throw new UnsupportedOperationException("Cannot get simple field for Union type");
@@ -512,7 +512,7 @@ public class Types {
         return MinorType.NULL;
       }
 
-      @Override public MinorType visit(Struct_ type) {
+      @Override public MinorType visit(Struct type) {
         return MinorType.MAP;
       }
 
@@ -543,11 +543,11 @@ public class Types {
       @Override
       public MinorType visit(FloatingPoint type) {
         switch (type.getPrecision()) {
-        case Precision.HALF:
+        case HALF:
           throw new UnsupportedOperationException("NYI: " + type);
-        case Precision.SINGLE:
+        case SINGLE:
           return MinorType.FLOAT4;
-        case Precision.DOUBLE:
+        case DOUBLE:
           return MinorType.FLOAT8;
         default:
           throw new IllegalArgumentException("unknown precision: " + type);
@@ -588,9 +588,9 @@ public class Types {
       @Override
       public MinorType visit(Interval type) {
         switch (type.getUnit()) {
-        case IntervalUnit.DAY_TIME:
+        case DAY_TIME:
           return MinorType.INTERVALDAY;
-        case IntervalUnit.YEAR_MONTH:
+        case YEAR_MONTH:
           return MinorType.INTERVALYEAR;
         default:
           throw new IllegalArgumentException("unknown unit: " + type);

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/types/UnionMode.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/UnionMode.java b/java/vector/src/main/java/org/apache/arrow/vector/types/UnionMode.java
new file mode 100644
index 0000000..8e957bc
--- /dev/null
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/UnionMode.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.arrow.vector.types;
+
+public enum UnionMode {
+  Sparse(org.apache.arrow.flatbuf.UnionMode.Sparse),
+  Dense(org.apache.arrow.flatbuf.UnionMode.Dense);
+
+  private static final UnionMode[] valuesByFlatbufId = new UnionMode[UnionMode.values().length];
+  static {
+    for (UnionMode v : UnionMode.values()) {
+      valuesByFlatbufId[v.flatbufID] = v;
+    }
+  }
+
+  private final short flatbufID;
+
+  private UnionMode(short flatbufID) {
+    this.flatbufID = flatbufID;
+  }
+
+  public short getFlatbufID() {
+    return flatbufID;
+  }
+
+  public static UnionMode fromFlatbufID(short id) {
+    return valuesByFlatbufId[id];
+  }
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java b/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java
index 49ba524..412fc54 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Field.java
@@ -29,6 +29,7 @@ import org.apache.arrow.vector.schema.VectorLayout;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.flatbuffers.FlatBufferBuilder;
 
@@ -104,7 +105,7 @@ public class Field {
       org.apache.arrow.flatbuf.Field.addName(builder, nameOffset);
     }
     org.apache.arrow.flatbuf.Field.addNullable(builder, nullable);
-    org.apache.arrow.flatbuf.Field.addTypeType(builder, type.getTypeType());
+    org.apache.arrow.flatbuf.Field.addTypeType(builder, type.getTypeID().getFlatbufID());
     org.apache.arrow.flatbuf.Field.addType(builder, typeOffset);
     org.apache.arrow.flatbuf.Field.addChildren(builder, childrenOffset);
     org.apache.arrow.flatbuf.Field.addLayout(builder, layoutOffset);
@@ -143,11 +144,18 @@ public class Field {
             (Objects.equals(this.children, that.children) ||
                     (this.children == null && that.children.size() == 0) ||
                     (this.children.size() == 0 && that.children == null));
-
   }
 
   @Override
   public String toString() {
-    return String.format("Field{name=%s, type=%s, children=%s, layout=%s}", name, type, children, typeLayout);
+    StringBuilder sb = new StringBuilder();
+    if (name != null) {
+      sb.append(name).append(": ");
+    }
+    sb.append(type);
+    if (!children.isEmpty()) {
+      sb.append("<").append(Joiner.on(", ").join(children)).append(">");
+    }
+    return sb.toString();
   }
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Schema.java
----------------------------------------------------------------------
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Schema.java b/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Schema.java
index 44b877e..5ca8ade 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Schema.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/types/pojo/Schema.java
@@ -33,6 +33,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectReader;
 import com.fasterxml.jackson.databind.ObjectWriter;
+import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.flatbuffers.FlatBufferBuilder;
 
@@ -132,6 +133,6 @@ public class Schema {
 
   @Override
   public String toString() {
-    return "Schema" + fields;
+    return "Schema<" + Joiner.on(", ").join(fields) + ">";
   }
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java
index 176ad51..58312b3 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/impl/TestPromotableWriter.java
@@ -21,15 +21,14 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.arrow.flatbuf.Type;
 import org.apache.arrow.memory.BufferAllocator;
 import org.apache.arrow.vector.DirtyRootAllocator;
-import org.apache.arrow.vector.complex.AbstractMapVector;
 import org.apache.arrow.vector.complex.MapVector;
 import org.apache.arrow.vector.complex.NullableMapVector;
 import org.apache.arrow.vector.complex.UnionVector;
 import org.apache.arrow.vector.complex.writer.BaseWriter.MapWriter;
 import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.ArrowType.ArrowTypeID;
 import org.apache.arrow.vector.types.pojo.Field;
 import org.junit.After;
 import org.junit.Before;
@@ -112,8 +111,8 @@ public class TestPromotableWriter {
 
       Field childField1 = container.getField().getChildren().get(0).getChildren().get(0);
       Field childField2 = container.getField().getChildren().get(0).getChildren().get(1);
-      assertEquals("Child field should be union type: " + childField1.getName(), Type.Union, childField1.getType().getTypeType());
-      assertEquals("Child field should be decimal type: " + childField2.getName(), Type.Decimal, childField2.getType().getTypeType());
+      assertEquals("Child field should be union type: " + childField1.getName(), ArrowTypeID.Union, childField1.getType().getTypeID());
+      assertEquals("Child field should be decimal type: " + childField2.getName(), ArrowTypeID.Decimal, childField2.getType().getTypeID());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java b/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java
index 6e0e617..caa438a 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/complex/writer/TestComplexWriter.java
@@ -41,6 +41,7 @@ import org.apache.arrow.vector.complex.reader.FieldReader;
 import org.apache.arrow.vector.complex.writer.BaseWriter.ComplexWriter;
 import org.apache.arrow.vector.complex.writer.BaseWriter.ListWriter;
 import org.apache.arrow.vector.complex.writer.BaseWriter.MapWriter;
+import org.apache.arrow.vector.types.pojo.ArrowType.ArrowTypeID;
 import org.apache.arrow.vector.types.pojo.ArrowType.Int;
 import org.apache.arrow.vector.types.pojo.ArrowType.Union;
 import org.apache.arrow.vector.types.pojo.ArrowType.Utf8;
@@ -429,7 +430,7 @@ public class TestComplexWriter {
     }
     Field field = parent.getField().getChildren().get(0).getChildren().get(0);
     Assert.assertEquals("a", field.getName());
-    Assert.assertEquals(Int.TYPE_TYPE, field.getType().getTypeType());
+    Assert.assertEquals(Int.TYPE_TYPE, field.getType().getTypeID());
     Int intType = (Int) field.getType();
 
     Assert.assertEquals(64, intType.getBitWidth());
@@ -444,9 +445,9 @@ public class TestComplexWriter {
     }
     field = parent.getField().getChildren().get(0).getChildren().get(0);
     Assert.assertEquals("a", field.getName());
-    Assert.assertEquals(Union.TYPE_TYPE, field.getType().getTypeType());
-    Assert.assertEquals(Int.TYPE_TYPE, field.getChildren().get(0).getType().getTypeType());
-    Assert.assertEquals(Utf8.TYPE_TYPE, field.getChildren().get(1).getType().getTypeType());
+    Assert.assertEquals(Union.TYPE_TYPE, field.getType().getTypeID());
+    Assert.assertEquals(Int.TYPE_TYPE, field.getChildren().get(0).getType().getTypeID());
+    Assert.assertEquals(Utf8.TYPE_TYPE, field.getChildren().get(1).getType().getTypeID());
     MapReader rootReader = new SingleMapReaderImpl(parent).reader("root");
     for (int i = 0; i < 100; i++) {
       rootReader.setPosition(i);
@@ -476,12 +477,12 @@ public class TestComplexWriter {
 
     Field field = parent.getField().getChildren().get(0).getChildren().get(0);
     Assert.assertEquals("a", field.getName());
-    Assert.assertEquals(Union.TYPE_TYPE, field.getType().getTypeType());
+    Assert.assertEquals(ArrowTypeID.Union, field.getType().getTypeID());
 
-    Assert.assertEquals(Int.TYPE_TYPE, field.getChildren().get(0).getType().getTypeType());
+    Assert.assertEquals(ArrowTypeID.Int, field.getChildren().get(0).getType().getTypeID());
     Int intType = (Int) field.getChildren().get(0).getType();
     Assert.assertEquals(64, intType.getBitWidth());
     Assert.assertTrue(intType.getIsSigned());
-    Assert.assertEquals(Utf8.TYPE_TYPE, field.getChildren().get(1).getType().getTypeType());
+    Assert.assertEquals(ArrowTypeID.Utf8, field.getChildren().get(1).getType().getTypeID());
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java b/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java
index 3da8db2..5a238bc 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/pojo/TestConvert.java
@@ -17,17 +17,17 @@
  */
 package org.apache.arrow.vector.pojo;
 
-import static org.apache.arrow.flatbuf.Precision.DOUBLE;
-import static org.apache.arrow.flatbuf.Precision.SINGLE;
+import static org.apache.arrow.vector.types.FloatingPointPrecision.DOUBLE;
+import static org.apache.arrow.vector.types.FloatingPointPrecision.SINGLE;
 import static org.junit.Assert.assertEquals;
 
-import org.apache.arrow.flatbuf.TimeUnit;
-import org.apache.arrow.flatbuf.UnionMode;
+import org.apache.arrow.vector.types.TimeUnit;
 import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.UnionMode;
 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.List;
-import org.apache.arrow.vector.types.pojo.ArrowType.Struct_;
+import org.apache.arrow.vector.types.pojo.ArrowType.Struct;
 import org.apache.arrow.vector.types.pojo.ArrowType.Timestamp;
 import org.apache.arrow.vector.types.pojo.ArrowType.Union;
 import org.apache.arrow.vector.types.pojo.ArrowType.Utf8;
@@ -55,7 +55,7 @@ public class TestConvert {
     childrenBuilder.add(new Field("child1", true, Utf8.INSTANCE, null));
     childrenBuilder.add(new Field("child2", true, new FloatingPoint(SINGLE), ImmutableList.<Field>of()));
 
-    Field initialField = new Field("a", true, Struct_.INSTANCE, childrenBuilder.build());
+    Field initialField = new Field("a", true, Struct.INSTANCE, childrenBuilder.build());
     run(initialField);
   }
 
@@ -73,7 +73,7 @@ public class TestConvert {
     ImmutableList.Builder<Field> childrenBuilder = ImmutableList.builder();
     childrenBuilder.add(new Field("child1", true, Utf8.INSTANCE, null));
     childrenBuilder.add(new Field("child2", true, new FloatingPoint(SINGLE), ImmutableList.<Field>of()));
-    childrenBuilder.add(new Field("child3", true, new Struct_(), ImmutableList.<Field>of(
+    childrenBuilder.add(new Field("child3", true, new Struct(), ImmutableList.<Field>of(
         new Field("child3.1", true, Utf8.INSTANCE, null),
         new Field("child3.2", true, new FloatingPoint(DOUBLE), ImmutableList.<Field>of())
         )));

http://git-wip-us.apache.org/repos/asf/arrow/blob/ebe7dc8f/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java b/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java
index 0ef8be7..d60d17e 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/types/pojo/TestSchema.java
@@ -23,10 +23,10 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
-import org.apache.arrow.flatbuf.IntervalUnit;
-import org.apache.arrow.flatbuf.Precision;
-import org.apache.arrow.flatbuf.TimeUnit;
-import org.apache.arrow.flatbuf.UnionMode;
+import org.apache.arrow.vector.types.FloatingPointPrecision;
+import org.apache.arrow.vector.types.IntervalUnit;
+import org.apache.arrow.vector.types.TimeUnit;
+import org.apache.arrow.vector.types.UnionMode;
 import org.junit.Test;
 
 public class TestSchema {
@@ -40,14 +40,32 @@ public class TestSchema {
   }
 
   @Test
+  public void testComplex() throws IOException {
+    Schema schema = new Schema(asList(
+        field("a", false, new ArrowType.Int(8, true)),
+        field("b", new ArrowType.Struct(),
+            field("c", new ArrowType.Int(16, true)),
+            field("d", new ArrowType.Utf8())),
+        field("e", new ArrowType.List(), field(null, new ArrowType.Date())),
+        field("f", new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)),
+        field("g", new ArrowType.Timestamp(TimeUnit.MILLISECOND)),
+        field("h", new ArrowType.Interval(IntervalUnit.DAY_TIME))
+        ));
+    roundTrip(schema);
+    assertEquals(
+        "Schema<a: Int(8, true), b: Struct<c: Int(16, true), d: Utf8>, e: List<Date>, f: FloatingPoint(SINGLE), g: Timestamp(MILLISECOND), h: Interval(DAY_TIME)>",
+        schema.toString());
+  }
+
+  @Test
   public void testAll() throws IOException {
     Schema schema = new Schema(asList(
         field("a", false, new ArrowType.Null()),
-        field("b", new ArrowType.Struct_(), field("ba", new ArrowType.Null())),
+        field("b", new ArrowType.Struct(), field("ba", new ArrowType.Null())),
         field("c", new ArrowType.List(), field("ca", new ArrowType.Null())),
         field("d", new ArrowType.Union(UnionMode.Sparse, new int[] {1, 2, 3}), field("da", new ArrowType.Null())),
         field("e", new ArrowType.Int(8, true)),
-        field("f", new ArrowType.FloatingPoint(Precision.SINGLE)),
+        field("f", new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)),
         field("g", new ArrowType.Utf8()),
         field("h", new ArrowType.Binary()),
         field("i", new ArrowType.Bool()),
@@ -94,9 +112,9 @@ public class TestSchema {
   @Test
   public void testFP() throws IOException {
     Schema schema = new Schema(asList(
-        field("a", new ArrowType.FloatingPoint(Precision.HALF)),
-        field("b", new ArrowType.FloatingPoint(Precision.SINGLE)),
-        field("c", new ArrowType.FloatingPoint(Precision.DOUBLE))
+        field("a", new ArrowType.FloatingPoint(FloatingPointPrecision.HALF)),
+        field("b", new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)),
+        field("c", new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE))
         ));
     roundTrip(schema);
     contains(schema, "HALF", "SINGLE", "DOUBLE");


Mime
View raw message