arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [1/2] arrow git commit: ARROW-676: move from MinorType to FieldType in ValueVectors to carry all the relevant type bits
Date Mon, 03 Apr 2017 22:01:29 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 96f3d6176 -> 7232e5b5d


http://git-wip-us.apache.org/repos/asf/arrow/blob/7232e5b5/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowFile.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowFile.java b/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowFile.java
index 75e5d2d..a1104ff 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowFile.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowFile.java
@@ -17,6 +17,8 @@
  */
 package org.apache.arrow.vector.file;
 
+import static org.apache.arrow.vector.TestUtils.newNullableVarCharVector;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -28,8 +30,6 @@ import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 
-import com.google.common.collect.ImmutableList;
-
 import org.apache.arrow.memory.BufferAllocator;
 import org.apache.arrow.vector.FieldVector;
 import org.apache.arrow.vector.NullableTinyIntVector;
@@ -40,19 +40,19 @@ import org.apache.arrow.vector.complex.MapVector;
 import org.apache.arrow.vector.complex.NullableMapVector;
 import org.apache.arrow.vector.complex.impl.UnionListWriter;
 import org.apache.arrow.vector.dictionary.Dictionary;
+import org.apache.arrow.vector.dictionary.DictionaryEncoder;
 import org.apache.arrow.vector.dictionary.DictionaryProvider;
 import org.apache.arrow.vector.dictionary.DictionaryProvider.MapDictionaryProvider;
-import org.apache.arrow.vector.dictionary.DictionaryEncoder;
 import org.apache.arrow.vector.schema.ArrowBuffer;
 import org.apache.arrow.vector.schema.ArrowMessage;
 import org.apache.arrow.vector.schema.ArrowRecordBatch;
 import org.apache.arrow.vector.stream.ArrowStreamReader;
 import org.apache.arrow.vector.stream.ArrowStreamWriter;
 import org.apache.arrow.vector.stream.MessageSerializerTest;
-import org.apache.arrow.vector.types.Types.MinorType;
 import org.apache.arrow.vector.types.pojo.ArrowType.Int;
 import org.apache.arrow.vector.types.pojo.DictionaryEncoding;
 import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
 import org.apache.arrow.vector.types.pojo.Schema;
 import org.apache.arrow.vector.util.Text;
 import org.junit.Assert;
@@ -60,6 +60,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.ImmutableList;
+
 public class TestArrowFile extends BaseFileTest {
   private static final Logger LOGGER = LoggerFactory.getLogger(TestArrowFile.class);
 
@@ -380,8 +382,8 @@ public class TestArrowFile extends BaseFileTest {
 
     // write
     try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original
vectors", 0, Integer.MAX_VALUE);
-         NullableVarCharVector vector = new NullableVarCharVector("varchar", originalVectorAllocator,
null);
-         NullableVarCharVector dictionaryVector = new NullableVarCharVector("dict", originalVectorAllocator,
null)) {
+         NullableVarCharVector vector = newNullableVarCharVector("varchar", originalVectorAllocator);
+         NullableVarCharVector dictionaryVector = newNullableVarCharVector("dict", originalVectorAllocator))
{
       vector.allocateNewSafe();
       NullableVarCharVector.Mutator mutator = vector.getMutator();
       mutator.set(0, "foo".getBytes(StandardCharsets.UTF_8));
@@ -483,7 +485,7 @@ public class TestArrowFile extends BaseFileTest {
     // [['foo', 'bar'], ['foo'], ['bar']] -> [[0, 1], [0], [1]]
 
     // write
-    try (NullableVarCharVector dictionaryVector = new NullableVarCharVector("dictionary",
allocator, null);
+    try (NullableVarCharVector dictionaryVector = newNullableVarCharVector("dictionary",
allocator);
          ListVector listVector = new ListVector("list", allocator, null, null)) {
 
       Dictionary dictionary = new Dictionary(dictionaryVector, encoding);
@@ -495,7 +497,7 @@ public class TestArrowFile extends BaseFileTest {
       dictionaryVector.getMutator().set(1, "bar".getBytes(StandardCharsets.UTF_8));
       dictionaryVector.getMutator().setValueCount(2);
 
-      listVector.addOrGetVector(MinorType.INT, encoding);
+      listVector.addOrGetVector(new FieldType(true, new Int(32, true), encoding));
       listVector.allocateNew();
       UnionListWriter listWriter = new UnionListWriter(listVector);
       listWriter.startList();
@@ -511,7 +513,7 @@ public class TestArrowFile extends BaseFileTest {
       listWriter.setValueCount(3);
 
       List<Field> fields = ImmutableList.of(listVector.getField());
-      List<FieldVector> vectors = ImmutableList.of((FieldVector) listVector);
+      List<FieldVector> vectors = ImmutableList.<FieldVector>of(listVector);
       VectorSchemaRoot root = new VectorSchemaRoot(fields, vectors, 3);
 
       try (

http://git-wip-us.apache.org/repos/asf/arrow/blob/7232e5b5/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowReaderWriter.java
----------------------------------------------------------------------
diff --git a/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowReaderWriter.java
b/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowReaderWriter.java
index 914dfe4..d00cb0f 100644
--- a/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowReaderWriter.java
+++ b/java/vector/src/test/java/org/apache/arrow/vector/file/TestArrowReaderWriter.java
@@ -24,11 +24,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
 import java.util.Collections;
 import java.util.List;
 
@@ -38,13 +35,10 @@ import org.apache.arrow.flatbuf.RecordBatch;
 import org.apache.arrow.memory.BufferAllocator;
 import org.apache.arrow.memory.RootAllocator;
 import org.apache.arrow.vector.FieldVector;
-import org.apache.arrow.vector.NullableIntVector;
-import org.apache.arrow.vector.NullableTinyIntVector;
+import org.apache.arrow.vector.TestUtils;
 import org.apache.arrow.vector.VectorSchemaRoot;
 import org.apache.arrow.vector.schema.ArrowFieldNode;
 import org.apache.arrow.vector.schema.ArrowRecordBatch;
-import org.apache.arrow.vector.types.Types;
-import org.apache.arrow.vector.types.Types.MinorType;
 import org.apache.arrow.vector.types.pojo.ArrowType;
 import org.apache.arrow.vector.types.pojo.Field;
 import org.apache.arrow.vector.types.pojo.Schema;
@@ -78,8 +72,8 @@ public class TestArrowReaderWriter {
   @Test
   public void test() throws IOException {
     Schema schema = new Schema(asList(new Field("testField", true, new ArrowType.Int(8, true),
Collections.<Field>emptyList())));
-    MinorType minorType = Types.getMinorTypeForArrowType(schema.getFields().get(0).getType());
-    FieldVector vector = minorType.getNewVector("testField", allocator, null,null);
+    ArrowType type = schema.getFields().get(0).getType();
+    FieldVector vector = TestUtils.newVector(FieldVector.class, "testField", type, allocator);
     vector.initializeChildrenFromFields(schema.getFields().get(0).getChildren());
 
     byte[] validity = new byte[] { (byte) 255, 0};


Mime
View raw message