From ced1705cbb0d1e0ade951a2c369580a9103566f2 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Mon, 4 Dec 2017 10:43:45 -0800 Subject: [PATCH 1/3] renamed MapVector to NullableMapVector --- .../vector/complex/{MapVector.java => NullableMapVector.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename java/vector/src/main/java/org/apache/arrow/vector/complex/{MapVector.java => NullableMapVector.java} (100%) 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/NullableMapVector.java similarity index 100% rename from java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java rename to java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java From 3d818f0ed9821b1b73670251399560a0217966c2 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Mon, 4 Dec 2017 10:44:36 -0800 Subject: [PATCH 2/3] renamed NonNullableMapVector to MapVector --- .../vector/complex/{NonNullableMapVector.java => MapVector.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename java/vector/src/main/java/org/apache/arrow/vector/complex/{NonNullableMapVector.java => MapVector.java} (100%) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableMapVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java similarity index 100% rename from java/vector/src/main/java/org/apache/arrow/vector/complex/NonNullableMapVector.java rename to java/vector/src/main/java/org/apache/arrow/vector/complex/MapVector.java From 9ff503ab5f73b8de77ef05ff7991090e5859406e Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Mon, 4 Dec 2017 12:02:46 -0800 Subject: [PATCH 3/3] restore MapVector class names --- .../templates/CaseSensitiveMapWriters.java | 2 +- .../main/codegen/templates/MapWriters.java | 8 ++--- .../main/codegen/templates/UnionVector.java | 10 +++---- .../arrow/vector/BaseVariableWidthVector.java | 2 +- .../complex/AbstractContainerVector.java | 4 +-- .../arrow/vector/complex/MapVector.java | 30 +++++++++---------- .../vector/complex/NullableMapVector.java | 26 ++++++++-------- .../complex/impl/ComplexWriterImpl.java | 6 ++-- .../complex/impl/NullableMapReaderImpl.java | 8 ++--- .../impl/NullableMapWriterFactory.java | 4 +-- .../vector/complex/impl/PromotableWriter.java | 4 +-- .../complex/impl/SingleMapReaderImpl.java | 5 ++-- .../org/apache/arrow/vector/types/Types.java | 6 ++-- .../apache/arrow/vector/TestMapVector.java | 4 +-- .../arrow/vector/TestVectorReAlloc.java | 4 +-- .../complex/impl/TestPromotableWriter.java | 4 +-- .../complex/writer/TestComplexWriter.java | 6 ++-- .../apache/arrow/vector/ipc/BaseFileTest.java | 12 ++++---- .../arrow/vector/ipc/TestArrowFile.java | 21 +++++++------ .../apache/arrow/vector/ipc/TestJSONFile.java | 15 +++++----- 20 files changed, 89 insertions(+), 92 deletions(-) diff --git a/java/vector/src/main/codegen/templates/CaseSensitiveMapWriters.java b/java/vector/src/main/codegen/templates/CaseSensitiveMapWriters.java index 7c652902eb8..5357f9b8a9d 100644 --- a/java/vector/src/main/codegen/templates/CaseSensitiveMapWriters.java +++ b/java/vector/src/main/codegen/templates/CaseSensitiveMapWriters.java @@ -23,7 +23,7 @@ <#if mode == "Single"> <#assign containerClass = "MapVector" /> <#else> -<#assign containerClass = "MapVector" /> +<#assign containerClass = "NullableMapVector" /> <#include "/@includes/license.ftl" /> diff --git a/java/vector/src/main/codegen/templates/MapWriters.java b/java/vector/src/main/codegen/templates/MapWriters.java index a5ac1b71704..ac59e59b308 100644 --- a/java/vector/src/main/codegen/templates/MapWriters.java +++ b/java/vector/src/main/codegen/templates/MapWriters.java @@ -21,9 +21,9 @@ <@pp.changeOutputFile name="/org/apache/arrow/vector/complex/impl/${mode}MapWriter.java" /> <#assign index = "idx()"> <#if mode == "Single"> -<#assign containerClass = "NonNullableMapVector" /> -<#else> <#assign containerClass = "MapVector" /> +<#else> +<#assign containerClass = "NullableMapVector" /> <#include "/@includes/license.ftl" /> @@ -51,7 +51,7 @@ public class ${mode}MapWriter extends AbstractFieldWriter { private final Map fields = Maps.newHashMap(); public ${mode}MapWriter(${containerClass} container) { <#if mode == "Single"> - if (container instanceof MapVector) { + if (container instanceof NullableMapVector) { throw new IllegalArgumentException("Invalid container: " + container); } @@ -124,7 +124,7 @@ public MapWriter map(String name) { FieldWriter writer = fields.get(finalName); if(writer == null){ int vectorCount=container.size(); - MapVector vector = container.addOrGet(name, FieldType.nullable(MinorType.MAP.getType()), MapVector.class); + NullableMapVector vector = container.addOrGet(name, FieldType.nullable(MinorType.MAP.getType()), NullableMapVector.class); writer = new PromotableWriter(vector, container, getNullableMapWriterFactory()); if(vectorCount != container.size()) { writer.allocate(); diff --git a/java/vector/src/main/codegen/templates/UnionVector.java b/java/vector/src/main/codegen/templates/UnionVector.java index 60cd24dcc44..9377bd0da21 100644 --- a/java/vector/src/main/codegen/templates/UnionVector.java +++ b/java/vector/src/main/codegen/templates/UnionVector.java @@ -48,8 +48,8 @@ /** - * A vector which can hold values of different types. It does so by using a MapVector which contains a vector for each - * primitive type that is stored. MapVector is used in order to take advantage of its serialization/deserialization methods, + * A vector which can hold values of different types. It does so by using a NullableMapVector which contains a vector for each + * primitive type that is stored. NullableMapVector is used in order to take advantage of its serialization/deserialization methods, * as well as the addOrGet method. * * For performance reasons, UnionVector stores a cached reference to each subtype vector, to avoid having to do the map lookup @@ -65,7 +65,7 @@ public class UnionVector implements FieldVector { MapVector internalMap; protected ArrowBuf typeBuffer; - private MapVector mapVector; + private NullableMapVector mapVector; private ListVector listVector; private FieldReader reader; @@ -174,10 +174,10 @@ public long getOffsetBufferAddress() { @Override public ArrowBuf getOffsetBuffer() { throw new UnsupportedOperationException(); } - public MapVector getMap() { + public NullableMapVector getMap() { if (mapVector == null) { int vectorCount = internalMap.size(); - mapVector = addOrGet(MinorType.MAP, MapVector.class); + mapVector = addOrGet(MinorType.MAP, NullableMapVector.class); if (internalMap.size() > vectorCount) { mapVector.allocateNew(); if (callBack != null) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java b/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java index 98820a2367b..fbadb35d755 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java @@ -24,7 +24,7 @@ import org.apache.arrow.memory.OutOfMemoryException; import org.apache.arrow.memory.BaseAllocator; import org.apache.arrow.memory.BufferAllocator; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.ipc.message.ArrowFieldNode; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.FieldType; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java index 5ded1cc6f87..db0ff86df47 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java @@ -100,8 +100,8 @@ protected boolean supportsDirectRead() { // return the child vector's ordinal in the composite container public abstract VectorWithOrdinal getChildVectorWithOrdinal(String name); - public MapVector addOrGetMap(String name) { - return addOrGet(name, FieldType.nullable(new Struct()), MapVector.class); + public NullableMapVector addOrGetMap(String name) { + return addOrGet(name, FieldType.nullable(new Struct()), NullableMapVector.class); } public ListVector addOrGetList(String name) { 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 1cd7b70d7bf..e13084588ce 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 @@ -47,12 +47,12 @@ import org.apache.arrow.vector.util.JsonStringHashMap; import org.apache.arrow.vector.util.TransferPair; -public class NonNullableMapVector extends AbstractMapVector { - //private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(NonNullableMapVector.class); +public class MapVector extends AbstractMapVector { + //private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MapVector.class); - public static NonNullableMapVector empty(String name, BufferAllocator allocator) { + public static MapVector empty(String name, BufferAllocator allocator) { FieldType fieldType = new FieldType(false, ArrowType.Struct.INSTANCE, null, null); - return new NonNullableMapVector(name, allocator, fieldType, null); + return new MapVector(name, allocator, fieldType, null); } private final SingleMapReaderImpl reader = new SingleMapReaderImpl(this); @@ -61,11 +61,11 @@ public static NonNullableMapVector empty(String name, BufferAllocator allocator) // deprecated, use FieldType or static constructor instead @Deprecated - public NonNullableMapVector(String name, BufferAllocator allocator, CallBack callBack) { + public MapVector(String name, BufferAllocator allocator, CallBack callBack) { this(name, allocator, new FieldType(false, ArrowType.Struct.INSTANCE, null, null), callBack); } - public NonNullableMapVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { + public MapVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { super(name, allocator, callBack); this.fieldType = checkNotNull(fieldType); this.valueCount = 0; @@ -78,7 +78,7 @@ public FieldReader getReader() { transient private MapTransferPair ephPair; - public void copyFromSafe(int fromIndex, int thisIndex, NonNullableMapVector from) { + public void copyFromSafe(int fromIndex, int thisIndex, MapVector from) { if (ephPair == null || ephPair.from != from) { ephPair = (MapTransferPair) from.makeTransferPair(this); } @@ -150,29 +150,29 @@ public TransferPair getTransferPair(BufferAllocator allocator) { @Override public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack) { - return new MapTransferPair(this, new NonNullableMapVector(name, allocator, fieldType, callBack), false); + return new MapTransferPair(this, new MapVector(name, allocator, fieldType, callBack), false); } @Override public TransferPair makeTransferPair(ValueVector to) { - return new MapTransferPair(this, (NonNullableMapVector) to); + return new MapTransferPair(this, (MapVector) to); } @Override public TransferPair getTransferPair(String ref, BufferAllocator allocator) { - return new MapTransferPair(this, new NonNullableMapVector(ref, allocator, fieldType, callBack), false); + return new MapTransferPair(this, new MapVector(ref, allocator, fieldType, callBack), false); } protected static class MapTransferPair implements TransferPair { private final TransferPair[] pairs; - private final NonNullableMapVector from; - private final NonNullableMapVector to; + private final MapVector from; + private final MapVector to; - public MapTransferPair(NonNullableMapVector from, NonNullableMapVector to) { + public MapTransferPair(MapVector from, MapVector to) { this(from, to, true); } - protected MapTransferPair(NonNullableMapVector from, NonNullableMapVector to, boolean allocate) { + protected MapTransferPair(MapVector from, MapVector to, boolean allocate) { this.from = from; this.to = to; this.pairs = new TransferPair[from.size()]; @@ -291,7 +291,7 @@ public void setValueCount(int valueCount) { for (final ValueVector v : getChildren()) { v.setValueCount(valueCount); } - NonNullableMapVector.this.valueCount = valueCount; + MapVector.this.valueCount = valueCount; } @Override 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 72cc29f30ca..d887b730646 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 @@ -44,11 +44,11 @@ import org.apache.arrow.vector.util.OversizedAllocationException; import org.apache.arrow.vector.util.TransferPair; -public class MapVector extends NonNullableMapVector implements FieldVector { +public class NullableMapVector extends MapVector implements FieldVector { - public static MapVector empty(String name, BufferAllocator allocator) { + public static NullableMapVector empty(String name, BufferAllocator allocator) { FieldType fieldType = FieldType.nullable(Struct.INSTANCE); - return new MapVector(name, allocator, fieldType, null); + return new NullableMapVector(name, allocator, fieldType, null); } private final NullableMapReaderImpl reader = new NullableMapReaderImpl(this); @@ -59,17 +59,17 @@ public static MapVector empty(String name, BufferAllocator allocator) { // deprecated, use FieldType or static constructor instead @Deprecated - public MapVector(String name, BufferAllocator allocator, CallBack callBack) { + public NullableMapVector(String name, BufferAllocator allocator, CallBack callBack) { this(name, allocator, FieldType.nullable(ArrowType.Struct.INSTANCE), callBack); } // deprecated, use FieldType or static constructor instead @Deprecated - public MapVector(String name, BufferAllocator allocator, DictionaryEncoding dictionary, CallBack callBack) { + public NullableMapVector(String name, BufferAllocator allocator, DictionaryEncoding dictionary, CallBack callBack) { this(name, allocator, new FieldType(true, ArrowType.Struct.INSTANCE, dictionary, null), callBack); } - public MapVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { + public NullableMapVector(String name, BufferAllocator allocator, FieldType fieldType, CallBack callBack) { super(name, checkNotNull(allocator), fieldType, callBack); this.validityBuffer = allocator.getEmpty(); this.validityAllocationSizeInBytes = BitVectorHelper.getValidityBufferSize(BaseValueVector.INITIAL_VALUE_ALLOCATION); @@ -127,29 +127,29 @@ public NullableMapWriter getWriter() { @Override public TransferPair getTransferPair(BufferAllocator allocator) { - return new NullableMapTransferPair(this, new MapVector(name, allocator, fieldType, null), false); + return new NullableMapTransferPair(this, new NullableMapVector(name, allocator, fieldType, null), false); } @Override public TransferPair makeTransferPair(ValueVector to) { - return new NullableMapTransferPair(this, (MapVector) to, true); + return new NullableMapTransferPair(this, (NullableMapVector) to, true); } @Override public TransferPair getTransferPair(String ref, BufferAllocator allocator) { - return new NullableMapTransferPair(this, new MapVector(ref, allocator, fieldType, null), false); + return new NullableMapTransferPair(this, new NullableMapVector(ref, allocator, fieldType, null), false); } @Override public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack) { - return new NullableMapTransferPair(this, new MapVector(ref, allocator, fieldType, callBack), false); + return new NullableMapTransferPair(this, new NullableMapVector(ref, allocator, fieldType, callBack), false); } protected class NullableMapTransferPair extends MapTransferPair { - private MapVector target; + private NullableMapVector target; - protected NullableMapTransferPair(MapVector from, MapVector to, boolean allocate) { + protected NullableMapTransferPair(NullableMapVector from, NullableMapVector to, boolean allocate) { super(from, to, allocate); this.target = to; } @@ -182,7 +182,7 @@ public void splitAndTransfer(int startIndex, int length) { /* * transfer the validity. */ - private void splitAndTransferValidityBuffer(int startIndex, int length, MapVector target) { + private void splitAndTransferValidityBuffer(int startIndex, int length, NullableMapVector target) { assert startIndex + length <= valueCount; int firstByteSource = BitVectorHelper.byteIndex(startIndex); int lastByteSource = BitVectorHelper.byteIndex(valueCount - 1); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java index 970b90ef510..a6960238b91 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/ComplexWriterImpl.java @@ -20,7 +20,7 @@ import org.apache.arrow.vector.complex.ListVector; import org.apache.arrow.vector.complex.MapVector; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.complex.StateTool; import org.apache.arrow.vector.complex.writer.BaseWriter.ComplexWriter; import org.apache.arrow.vector.types.pojo.Field; @@ -131,7 +131,7 @@ public MapWriter directMap() { switch (mode) { case INIT: - mapRoot = nullableMapWriterFactory.build((MapVector) container); + mapRoot = nullableMapWriterFactory.build((NullableMapVector) container); mapRoot.setPosition(idx()); mode = Mode.MAP; break; @@ -152,7 +152,7 @@ public MapWriter rootAsMap() { case INIT: // TODO allow dictionaries in complex types - MapVector map = container.addOrGetMap(name); + NullableMapVector map = container.addOrGetMap(name); mapRoot = nullableMapWriterFactory.build(map); mapRoot.setPosition(idx()); mode = Mode.MAP; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapReaderImpl.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapReaderImpl.java index acf155af71d..06b0f4d4327 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapReaderImpl.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapReaderImpl.java @@ -20,17 +20,17 @@ package org.apache.arrow.vector.complex.impl; import org.apache.arrow.vector.complex.MapVector; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.complex.writer.BaseWriter.MapWriter; import org.apache.arrow.vector.types.pojo.Field; public class NullableMapReaderImpl extends SingleMapReaderImpl { - private MapVector nullableMapVector; + private NullableMapVector nullableMapVector; public NullableMapReaderImpl(MapVector vector) { - super((MapVector) vector); - this.nullableMapVector = (MapVector) vector; + super((NullableMapVector) vector); + this.nullableMapVector = (NullableMapVector) vector; } @Override diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapWriterFactory.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapWriterFactory.java index 06dbf784be0..d2dcb2374d0 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapWriterFactory.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapWriterFactory.java @@ -18,7 +18,7 @@ package org.apache.arrow.vector.complex.impl; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; public class NullableMapWriterFactory { private final boolean caseSensitive; @@ -29,7 +29,7 @@ public NullableMapWriterFactory(boolean caseSensitive) { this.caseSensitive = caseSensitive; } - public NullableMapWriter build(MapVector container) { + public NullableMapWriter build(NullableMapVector container) { return this.caseSensitive ? new NullableCaseSensitiveMapWriter(container) : new NullableMapWriter(container); } diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java index 9abd38d20ac..5bd439cac42 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/PromotableWriter.java @@ -23,7 +23,7 @@ import org.apache.arrow.vector.ZeroVector; import org.apache.arrow.vector.complex.AbstractMapVector; import org.apache.arrow.vector.complex.ListVector; -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.FieldWriter; import org.apache.arrow.vector.types.Types.MinorType; @@ -94,7 +94,7 @@ private void setWriter(ValueVector v) { type = v.getMinorType(); switch (type) { case MAP: - writer = nullableMapWriterFactory.build((MapVector) vector); + writer = nullableMapWriterFactory.build((NullableMapVector) vector); break; case LIST: writer = new UnionListWriter((ListVector) vector, nullableMapWriterFactory); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/SingleMapReaderImpl.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/SingleMapReaderImpl.java index 0341b622e0d..c77ca4e8f23 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/SingleMapReaderImpl.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/SingleMapReaderImpl.java @@ -24,7 +24,6 @@ import org.apache.arrow.vector.ValueVector; import org.apache.arrow.vector.complex.MapVector; -import org.apache.arrow.vector.complex.NonNullableMapVector; import org.apache.arrow.vector.complex.reader.FieldReader; import org.apache.arrow.vector.complex.writer.BaseWriter.MapWriter; import org.apache.arrow.vector.types.Types.MinorType; @@ -35,10 +34,10 @@ @SuppressWarnings("unused") public class SingleMapReaderImpl extends AbstractFieldReader { - private final NonNullableMapVector vector; + private final MapVector vector; private final Map fields = Maps.newHashMap(); - public SingleMapReaderImpl(NonNullableMapVector vector) { + public SingleMapReaderImpl(MapVector vector) { this.vector = vector; } 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 7834845aad8..3c5fd81d572 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 @@ -58,7 +58,7 @@ import org.apache.arrow.vector.ZeroVector; import org.apache.arrow.vector.complex.FixedSizeListVector; import org.apache.arrow.vector.complex.ListVector; -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.impl.BigIntWriterImpl; import org.apache.arrow.vector.complex.impl.BitWriterImpl; @@ -131,12 +131,12 @@ public FieldWriter getNewFieldWriter(ValueVector vector) { MAP(Struct.INSTANCE) { @Override public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { - return new MapVector(name, allocator, fieldType, schemaChangeCallback); + return new NullableMapVector(name, allocator, fieldType, schemaChangeCallback); } @Override public FieldWriter getNewFieldWriter(ValueVector vector) { - return new NullableMapWriter((MapVector) vector); + return new NullableMapWriter((NullableMapVector) vector); } }, TINYINT(new Int(8, true)) { 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 index e5682955bad..357df96aa2e 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestMapVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestMapVector.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.arrow.memory.BufferAllocator; -import org.apache.arrow.vector.complex.MapVector; +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; @@ -50,7 +50,7 @@ public void testFieldMetadata() throws Exception { Map metadata = new HashMap<>(); metadata.put("k1", "v1"); FieldType type = new FieldType(true, Struct.INSTANCE, null, metadata); - try (MapVector vector = new MapVector("map", allocator, type, null)) { + try (NullableMapVector vector = new NullableMapVector("map", allocator, type, null)) { Assert.assertEquals(vector.getField().getMetadata(), type.getMetadata()); } } diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReAlloc.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReAlloc.java index 1b13c2ed919..f8edf8904c5 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReAlloc.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReAlloc.java @@ -26,7 +26,7 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.vector.complex.ListVector; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.types.Types.MinorType; import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.FieldType; @@ -121,7 +121,7 @@ public void testListType() { @Test public void testMapType() { - try (final MapVector vector = MapVector.empty("", allocator)) { + try (final NullableMapVector vector = NullableMapVector.empty("", allocator)) { vector.addOrGet("", FieldType.nullable(MinorType.INT.getType()), IntVector.class); vector.setInitialCapacity(512); 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 38b78424dcc..b0d6cf555e9 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 @@ -25,7 +25,7 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.vector.DirtyRootAllocator; import org.apache.arrow.vector.complex.MapVector; -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.pojo.ArrowType; @@ -55,7 +55,7 @@ public void terminate() throws Exception { public void testPromoteToUnion() throws Exception { try (final MapVector container = MapVector.empty(EMPTY_SCHEMA_PATH, allocator); - final MapVector v = container.addOrGetMap("test"); + final NullableMapVector v = container.addOrGetMap("test"); final PromotableWriter writer = new PromotableWriter(v, container)) { container.allocateNew(); 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 bd8489eb20f..29d39aabe6b 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 @@ -34,7 +34,7 @@ import org.apache.arrow.vector.IntVector; import org.apache.arrow.vector.complex.ListVector; import org.apache.arrow.vector.complex.MapVector; -import org.apache.arrow.vector.complex.NonNullableMapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.complex.UnionVector; import org.apache.arrow.vector.complex.impl.ComplexWriterImpl; import org.apache.arrow.vector.complex.impl.SingleMapReaderImpl; @@ -830,7 +830,7 @@ public void complexCopierWithList() { rootWriter.end(); writer.setValueCount(1); - MapVector mapVector = (MapVector) parent.getChild("root"); + NullableMapVector mapVector = (NullableMapVector) parent.getChild("root"); TransferPair tp = mapVector.getTransferPair(allocator); tp.splitAndTransfer(0, 1); MapVector toMapVector = (MapVector) tp.getTo(); @@ -849,7 +849,7 @@ public void testSingleMapWriter1() { /* initialize a SingleMapWriter with empty MapVector and then lazily * create all vectors with expected initialCapacity. */ - NonNullableMapVector parent = NonNullableMapVector.empty("parent", allocator); + MapVector parent = MapVector.empty("parent", allocator); SingleMapWriter singleMapWriter = new SingleMapWriter(parent); int initialCapacity = 1024; diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java index 1a7f71c72b4..9eb55c9bbda 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/BaseFileTest.java @@ -36,7 +36,7 @@ import org.apache.arrow.vector.VarCharVector; import org.apache.arrow.vector.VectorSchemaRoot; import org.apache.arrow.vector.complex.ListVector; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.complex.impl.ComplexWriterImpl; import org.apache.arrow.vector.complex.impl.UnionListWriter; import org.apache.arrow.vector.complex.reader.FieldReader; @@ -94,7 +94,7 @@ public void tearDown() { DateTimeZone.setDefault(defaultTimezone); } - protected void writeData(int count, MapVector parent) { + protected void writeData(int count, NullableMapVector parent) { ComplexWriter writer = new ComplexWriterImpl("root", parent); MapWriter rootWriter = writer.rootAsMap(); IntWriter intWriter = rootWriter.integer("int"); @@ -119,7 +119,7 @@ protected void validateContent(int count, VectorSchemaRoot root) { } } - protected void writeComplexData(int count, MapVector parent) { + protected void writeComplexData(int count, NullableMapVector parent) { ArrowBuf varchar = allocator.buffer(3); varchar.readerIndex(0); varchar.setByte(0, 'a'); @@ -189,7 +189,7 @@ private LocalDateTime makeDateTimeFromCount(int i) { return new LocalDateTime(2000 + i, 1 + i, 1 + i, i, i, i, i); } - protected void writeDateTimeData(int count, MapVector parent) { + protected void writeDateTimeData(int count, NullableMapVector parent) { Assert.assertTrue(count < 100); ComplexWriter writer = new ComplexWriterImpl("root", parent); MapWriter rootWriter = writer.rootAsMap(); @@ -494,7 +494,7 @@ public void validateUnionData(int count, VectorSchemaRoot root) { } } - public void writeUnionData(int count, MapVector parent) { + public void writeUnionData(int count, NullableMapVector parent) { ArrowBuf varchar = allocator.buffer(3); varchar.readerIndex(0); varchar.setByte(0, 'a'); @@ -537,7 +537,7 @@ public void writeUnionData(int count, MapVector parent) { varchar.release(); } - protected void writeVarBinaryData(int count, MapVector parent) { + protected void writeVarBinaryData(int count, NullableMapVector parent) { Assert.assertTrue(count < 100); ComplexWriter writer = new ComplexWriterImpl("root", parent); MapWriter rootWriter = writer.rootAsMap(); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java index 0cfc9ba919d..055c34e7010 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestArrowFile.java @@ -42,8 +42,7 @@ import org.apache.arrow.vector.VectorSchemaRoot; import org.apache.arrow.vector.VectorUnloader; import org.apache.arrow.vector.complex.FixedSizeListVector; -import org.apache.arrow.vector.complex.MapVector; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.dictionary.DictionaryProvider.MapDictionaryProvider; import org.apache.arrow.vector.ipc.message.ArrowBlock; import org.apache.arrow.vector.ipc.message.ArrowBuffer; @@ -70,7 +69,7 @@ public void testWrite() throws IOException { int count = COUNT; try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeData(count, parent); write(parent.getChild("root"), file, new ByteArrayOutputStream()); } @@ -82,7 +81,7 @@ public void testWriteComplex() throws IOException { int count = COUNT; try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeComplexData(count, parent); FieldVector root = parent.getChild("root"); validateComplexContent(count, new VectorSchemaRoot(root)); @@ -98,7 +97,7 @@ public void testWriteRead() throws IOException { // write try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", originalVectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", originalVectorAllocator)) { writeData(count, parent); write(parent.getChild("root"), file, stream); } @@ -154,7 +153,7 @@ public void testWriteReadComplex() throws IOException { // write try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", originalVectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", originalVectorAllocator)) { writeComplexData(count, parent); write(parent.getChild("root"), file, stream); } @@ -195,7 +194,7 @@ public void testWriteReadMultipleRBs() throws IOException { // write try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", originalVectorAllocator); + NullableMapVector parent = NullableMapVector.empty("parent", originalVectorAllocator); FileOutputStream fileOutputStream = new FileOutputStream(file)) { writeData(counts[0], parent); VectorSchemaRoot root = new VectorSchemaRoot(parent.getChild("root")); @@ -268,7 +267,7 @@ public void testWriteReadUnion() throws IOException { // write try (BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeUnionData(count, parent); validateUnionData(count, new VectorSchemaRoot(parent.getChild("root"))); write(parent.getChild("root"), file, stream); @@ -382,7 +381,7 @@ public void testWriteReadMetadata() throws IOException { // write try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector vector = (MapVector) field.createVector(originalVectorAllocator)) { + NullableMapVector vector = (NullableMapVector) field.createVector(originalVectorAllocator)) { vector.allocateNewSafe(); vector.setValueCount(0); @@ -558,7 +557,7 @@ public void testWriteReadFixedSizeList() throws IOException { // write try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", originalVectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", originalVectorAllocator)) { FixedSizeListVector tuples = parent.addOrGet("float-pairs", FieldType.nullable(new FixedSizeList(2)), FixedSizeListVector.class); Float4Vector floats = (Float4Vector) tuples.addOrGetVector(FieldType.nullable(MinorType.FLOAT4.getType())).getVector(); IntVector ints = parent.addOrGet("ints", FieldType.nullable(new Int(32, true)), IntVector.class); @@ -618,7 +617,7 @@ public void testWriteReadVarBin() throws IOException { // write try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeVarBinaryData(count, parent); VectorSchemaRoot root = new VectorSchemaRoot(parent.getChild("root")); validateVarBinary(count, root); diff --git a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java index 4f9093b8c02..6a23a8438de 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/ipc/TestJSONFile.java @@ -24,8 +24,7 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.vector.FieldVector; import org.apache.arrow.vector.VectorSchemaRoot; -import org.apache.arrow.vector.complex.MapVector; -import org.apache.arrow.vector.complex.MapVector; +import org.apache.arrow.vector.complex.NullableMapVector; import org.apache.arrow.vector.dictionary.DictionaryProvider; import org.apache.arrow.vector.dictionary.DictionaryProvider.MapDictionaryProvider; import org.apache.arrow.vector.types.pojo.Schema; @@ -45,7 +44,7 @@ public void testWriteRead() throws IOException { // write try (BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", originalVectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", originalVectorAllocator)) { writeData(count, parent); writeJSON(file, new VectorSchemaRoot(parent.getChild("root")), null); } @@ -73,7 +72,7 @@ public void testWriteReadComplexJSON() throws IOException { // write try ( BufferAllocator originalVectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", originalVectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", originalVectorAllocator)) { writeComplexData(count, parent); writeJSON(file, new VectorSchemaRoot(parent.getChild("root")), null); } @@ -100,7 +99,7 @@ public void testWriteComplexJSON() throws IOException { int count = COUNT; try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeComplexData(count, parent); VectorSchemaRoot root = new VectorSchemaRoot(parent.getChild("root")); validateComplexContent(root.getRowCount(), root); @@ -122,7 +121,7 @@ public void testWriteReadUnionJSON() throws IOException { int count = COUNT; try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeUnionData(count, parent); printVectors(parent.getChildrenFromFields()); @@ -154,7 +153,7 @@ public void testWriteReadDateTimeJSON() throws IOException { // write try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeDateTimeData(count, parent); @@ -319,7 +318,7 @@ public void testWriteReadVarBinJSON() throws IOException { // write try ( BufferAllocator vectorAllocator = allocator.newChildAllocator("original vectors", 0, Integer.MAX_VALUE); - MapVector parent = MapVector.empty("parent", vectorAllocator)) { + NullableMapVector parent = NullableMapVector.empty("parent", vectorAllocator)) { writeVarBinaryData(count, parent); VectorSchemaRoot root = new VectorSchemaRoot(parent.getChild("root")); validateVarBinary(count, root);