diff options
Diffstat (limited to 'sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java')
-rw-r--r-- | sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java b/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java index 74fa6323cc..ff1f6680a7 100644 --- a/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java +++ b/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java @@ -56,7 +56,7 @@ import org.apache.spark.unsafe.types.UTF8String; * * ColumnVectors are intended to be reused. */ -public abstract class ColumnVector { +public abstract class ColumnVector implements AutoCloseable { /** * Allocates a column to store elements of `type` on or off heap. * Capacity is the initial capacity of the vector and it will grow as necessary. Capacity is @@ -566,6 +566,18 @@ public abstract class ColumnVector { } } + + public final void putDecimal(int rowId, Decimal value, int precision) { + if (precision <= Decimal.MAX_INT_DIGITS()) { + putInt(rowId, value.toInt()); + } else if (precision <= Decimal.MAX_LONG_DIGITS()) { + putLong(rowId, value.toLong()); + } else { + BigInteger bigInteger = value.toJavaBigDecimal().unscaledValue(); + putByteArray(rowId, bigInteger.toByteArray()); + } + } + /** * Returns the UTF8String for rowId. */ @@ -901,6 +913,11 @@ public abstract class ColumnVector { } /** + * Returns true if this column has a dictionary. + */ + public boolean hasDictionary() { return this.dictionary != null; } + + /** * Reserve a integer column for ids of dictionary. */ public ColumnVector reserveDictionaryIds(int capacity) { @@ -915,6 +932,13 @@ public abstract class ColumnVector { } /** + * Returns the underlying integer column for ids of dictionary. + */ + public ColumnVector getDictionaryIds() { + return dictionaryIds; + } + + /** * Sets up the common state and also handles creating the child columns if this is a nested * type. */ |