-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-21472][SQL] Introduce ArrowColumnVector as a reader for Arrow vectors. #18680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
689f86f
Import ArrowUtils and use it.
ueshin 73899b2
Introduce ArrowColumnVector as a reader for Arrow vectors.
ueshin c912e78
Extract ReadOnlyColumnVector.
ueshin 2215922
Refactor ArrowColumnVector.
ueshin ddfcf36
Add tests to check getting multiple values.
ueshin 91b94ef
Modify ReadOnlyColumnVector to accept dataType for the constructor ar…
ueshin afdaf5a
Fix a comment.
ueshin 2d1dad9
Add boundary check.
ueshin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
590 changes: 590 additions & 0 deletions
590
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ArrowColumnVector.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
251 changes: 251 additions & 0 deletions
251
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ReadOnlyColumnVector.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,251 @@ | ||
| /* | ||
| * 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.spark.sql.execution.vectorized; | ||
|
|
||
| import org.apache.spark.memory.MemoryMode; | ||
| import org.apache.spark.sql.types.*; | ||
|
|
||
| /** | ||
| * An abstract class for read-only column vector. | ||
| */ | ||
| public abstract class ReadOnlyColumnVector extends ColumnVector { | ||
|
|
||
| protected ReadOnlyColumnVector(int capacity, DataType type, MemoryMode memMode) { | ||
| super(capacity, DataTypes.NullType, memMode); | ||
| this.type = type; | ||
| isConstant = true; | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with nulls | ||
| // | ||
|
|
||
| @Override | ||
| public final void putNotNull(int rowId) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putNull(int rowId) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putNulls(int rowId, int count) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putNotNulls(int rowId, int count) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Booleans | ||
| // | ||
|
|
||
| @Override | ||
| public final void putBoolean(int rowId, boolean value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putBooleans(int rowId, int count, boolean value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Bytes | ||
| // | ||
|
|
||
| @Override | ||
| public final void putByte(int rowId, byte value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putBytes(int rowId, int count, byte value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putBytes(int rowId, int count, byte[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Shorts | ||
| // | ||
|
|
||
| @Override | ||
| public final void putShort(int rowId, short value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putShorts(int rowId, int count, short value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putShorts(int rowId, int count, short[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Ints | ||
| // | ||
|
|
||
| @Override | ||
| public final void putInt(int rowId, int value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putInts(int rowId, int count, int value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putInts(int rowId, int count, int[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putIntsLittleEndian(int rowId, int count, byte[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Longs | ||
| // | ||
|
|
||
| @Override | ||
| public final void putLong(int rowId, long value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putLongs(int rowId, int count, long value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putLongs(int rowId, int count, long[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putLongsLittleEndian(int rowId, int count, byte[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with floats | ||
| // | ||
|
|
||
| @Override | ||
| public final void putFloat(int rowId, float value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putFloats(int rowId, int count, float value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putFloats(int rowId, int count, float[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putFloats(int rowId, int count, byte[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with doubles | ||
| // | ||
|
|
||
| @Override | ||
| public final void putDouble(int rowId, double value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putDoubles(int rowId, int count, double value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putDoubles(int rowId, int count, double[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final void putDoubles(int rowId, int count, byte[] src, int srcIndex) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Arrays | ||
| // | ||
|
|
||
| @Override | ||
| public final void putArray(int rowId, int offset, int length) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Byte Arrays | ||
| // | ||
|
|
||
| @Override | ||
| public final int putByteArray(int rowId, byte[] value, int offset, int count) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // APIs dealing with Decimals | ||
| // | ||
|
|
||
| @Override | ||
| public final void putDecimal(int rowId, Decimal value, int precision) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| // | ||
| // Other APIs | ||
| // | ||
|
|
||
| @Override | ||
| public final void setDictionary(Dictionary dictionary) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public final ColumnVector reserveDictionaryIds(int capacity) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| protected final void reserveInternal(int newCapacity) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to refactor
ColumnVectorinto classes that separate reading/writing so you could just extend the read portion instead of making this class that throws exceptions on writes? e.g.ColumnVector -> ColumnVectorWritable -> ColumnVectorReadable
ArrowColumnVector -> ColumnVectorReadable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it'd be better to refactor
ColumnVector, but I thinkColumnVectoris related toColumnarBatchor other classes, so we should do it, and also refactorColumnarBatchat the same time, in the future PRs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on separating the read/write, we should definitely do this before we publish the
ColumnVectorinterfaces.