diff --git a/common/src/main/java/org/apache/comet/parquet/ColumnReader.java b/common/src/main/java/org/apache/comet/parquet/ColumnReader.java index f32f7dc2f..46fd87f6b 100644 --- a/common/src/main/java/org/apache/comet/parquet/ColumnReader.java +++ b/common/src/main/java/org/apache/comet/parquet/ColumnReader.java @@ -170,7 +170,6 @@ public void close() { /** Returns a decoded {@link CometDecodedVector Comet vector}. */ public CometDecodedVector loadVector() { - // Only re-use Comet vector iff: // 1. if we're not using dictionary encoding, since with dictionary encoding, the native // side may fallback to plain encoding and the underlying memory address for the vector @@ -213,8 +212,7 @@ public CometDecodedVector loadVector() { FieldVector vector = Data.importVector(ALLOCATOR, array, schema, dictionaryProvider); DictionaryEncoding dictionaryEncoding = vector.getField().getDictionary(); - CometPlainVector cometVector = new CometPlainVector(vector, useDecimal128); - cometVector.setIsUuid(isUuid); + CometPlainVector cometVector = new CometPlainVector(vector, useDecimal128, isUuid); // Update whether the current vector contains any null values. This is used in the following // batch(s) to determine whether we can skip loading the native vector. @@ -237,14 +235,13 @@ public CometDecodedVector loadVector() { // initialized yet. Dictionary arrowDictionary = dictionaryProvider.lookup(dictionaryEncoding.getId()); CometPlainVector dictionaryVector = - new CometPlainVector(arrowDictionary.getVector(), useDecimal128); - dictionaryVector.setIsUuid(isUuid); + new CometPlainVector(arrowDictionary.getVector(), useDecimal128, isUuid); dictionary = new CometDictionary(dictionaryVector); } currentVector = - new CometDictionaryVector(cometVector, dictionary, dictionaryProvider, useDecimal128); - cometVector.setIsUuid(isUuid); + new CometDictionaryVector( + cometVector, dictionary, dictionaryProvider, useDecimal128, false, isUuid); return currentVector; } diff --git a/common/src/main/java/org/apache/comet/vector/CometDecodedVector.java b/common/src/main/java/org/apache/comet/vector/CometDecodedVector.java index e63c65a1d..f699134f8 100644 --- a/common/src/main/java/org/apache/comet/vector/CometDecodedVector.java +++ b/common/src/main/java/org/apache/comet/vector/CometDecodedVector.java @@ -41,14 +41,16 @@ public abstract class CometDecodedVector extends CometVector { protected boolean isUuid; protected CometDecodedVector(ValueVector vector, Field valueField, boolean useDecimal128) { + this(vector, valueField, useDecimal128, false); + } + + protected CometDecodedVector( + ValueVector vector, Field valueField, boolean useDecimal128, boolean isUuid) { super(Utils.fromArrowField(valueField), useDecimal128); this.valueVector = vector; this.numNulls = valueVector.getNullCount(); this.numValues = valueVector.getValueCount(); this.hasNull = numNulls != 0; - } - - public void setIsUuid(boolean isUuid) { this.isUuid = isUuid; } diff --git a/common/src/main/java/org/apache/comet/vector/CometDictionaryVector.java b/common/src/main/java/org/apache/comet/vector/CometDictionaryVector.java index 2cd9c5d18..a74f4ff6b 100644 --- a/common/src/main/java/org/apache/comet/vector/CometDictionaryVector.java +++ b/common/src/main/java/org/apache/comet/vector/CometDictionaryVector.java @@ -39,7 +39,7 @@ public CometDictionaryVector( CometDictionary values, DictionaryProvider provider, boolean useDecimal128) { - this(indices, values, provider, useDecimal128, false); + this(indices, values, provider, useDecimal128, false, false); } public CometDictionaryVector( @@ -47,8 +47,9 @@ public CometDictionaryVector( CometDictionary values, DictionaryProvider provider, boolean useDecimal128, - boolean isAlias) { - super(indices.valueVector, values.getValueVector().getField(), useDecimal128); + boolean isAlias, + boolean isUuid) { + super(indices.valueVector, values.getValueVector().getField(), useDecimal128, isUuid); Preconditions.checkArgument( indices.valueVector instanceof IntVector, "'indices' should be a IntVector"); this.values = values; @@ -130,6 +131,6 @@ public CometVector slice(int offset, int length) { // Set the alias flag to true so that the sliced vector will not close the dictionary vector. // Otherwise, if the dictionary is closed, the sliced vector will not be able to access the // dictionary. - return new CometDictionaryVector(sliced, values, provider, useDecimal128, true); + return new CometDictionaryVector(sliced, values, provider, useDecimal128, true, isUuid); } } diff --git a/common/src/main/java/org/apache/comet/vector/CometPlainVector.java b/common/src/main/java/org/apache/comet/vector/CometPlainVector.java index 7bc0ac64e..e2a625f01 100644 --- a/common/src/main/java/org/apache/comet/vector/CometPlainVector.java +++ b/common/src/main/java/org/apache/comet/vector/CometPlainVector.java @@ -39,7 +39,11 @@ public class CometPlainVector extends CometDecodedVector { private int booleanByteCacheIndex = -1; public CometPlainVector(ValueVector vector, boolean useDecimal128) { - super(vector, vector.getField(), useDecimal128); + this(vector, useDecimal128, false); + } + + public CometPlainVector(ValueVector vector, boolean useDecimal128, boolean isUuid) { + super(vector, vector.getField(), useDecimal128, isUuid); // NullType doesn't have data buffer. if (vector instanceof NullVector) { this.valueBufferAddress = -1;