Repository: arrow
Updated Branches:
  refs/heads/master 7fdbcc606 -> 86154f0be


ARROW-1340: [Java] Fix NullableMapVector field metadata

Author: Emilio Lahr-Vivaz <elahrvi...@ccri.com>

Closes #953 from elahrvivaz/ARROW-1340 and squashes the following commits:

a307779e [Emilio Lahr-Vivaz] ARROW-1340: [Java] Fix NullableMapVector field 
metadata


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

Branch: refs/heads/master
Commit: 86154f0be3fbafcd27716f3b3f7058c31242a52f
Parents: 7fdbcc6
Author: Emilio Lahr-Vivaz <elahrvi...@ccri.com>
Authored: Wed Aug 9 09:11:52 2017 -0400
Committer: Wes McKinney <wes.mckin...@twosigma.com>
Committed: Wed Aug 9 09:11:52 2017 -0400

----------------------------------------------------------------------
 .../arrow/vector/complex/NullableMapVector.java |  3 +-
 .../org/apache/arrow/vector/TestMapVector.java  | 57 ++++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/86154f0b/java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java
----------------------------------------------------------------------
diff --git 
a/java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java
 
b/java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java
index e70a915..fda9c14 100644
--- 
a/java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java
+++ 
b/java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java
@@ -86,7 +86,8 @@ public class NullableMapVector extends MapVector implements 
FieldVector {
   @Override
   public Field getField() {
     Field f = super.getField();
-    return new Field(f.getName(), true, f.getType(), f.getChildren());
+    FieldType type = new FieldType(true, f.getType(), 
f.getFieldType().getDictionary(), f.getFieldType().getMetadata());
+    return new Field(f.getName(), type, f.getChildren());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/arrow/blob/86154f0b/java/vector/src/test/java/org/apache/arrow/vector/TestMapVector.java
----------------------------------------------------------------------
diff --git 
a/java/vector/src/test/java/org/apache/arrow/vector/TestMapVector.java 
b/java/vector/src/test/java/org/apache/arrow/vector/TestMapVector.java
new file mode 100644
index 0000000..357df96
--- /dev/null
+++ b/java/vector/src/test/java/org/apache/arrow/vector/TestMapVector.java
@@ -0,0 +1,57 @@
+/**
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.NullableMapVector;
+import org.apache.arrow.vector.types.pojo.ArrowType.Struct;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class TestMapVector {
+
+  private BufferAllocator allocator;
+
+  @Before
+  public void init() {
+    allocator = new DirtyRootAllocator(Long.MAX_VALUE, (byte) 100);
+  }
+
+  @After
+  public void terminate() throws Exception {
+    allocator.close();
+  }
+
+  @Test
+  public void testFieldMetadata() throws Exception {
+    Map<String, String> metadata = new HashMap<>();
+    metadata.put("k1", "v1");
+    FieldType type = new FieldType(true, Struct.INSTANCE, null, metadata);
+    try (NullableMapVector vector = new NullableMapVector("map", allocator, 
type, null)) {
+      Assert.assertEquals(vector.getField().getMetadata(), type.getMetadata());
+    }
+  }
+}

Reply via email to