-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21046][SQL] simplify the array offset and length in ColumnVector #18260
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d4267b7
simplify the array offset and length in ColumnVector
cloud-fan a61ba71
address comments
cloud-fan 368c346
more comments
cloud-fan 1dae660
minor
cloud-fan e6e60e0
use long array
cloud-fan fdc0870
fix bug
cloud-fan 04790bb
fix test
cloud-fan 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
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
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
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
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 |
|---|---|---|
|
|
@@ -631,7 +631,7 @@ class ColumnarBatchSuite extends SparkFunSuite { | |
| assert(column.arrayData().elementsAppended == 17) | ||
|
|
||
| // Put the same "ll" at offset. This should not allocate more memory in the column. | ||
| column.putArray(idx, offset, 2) | ||
| column.putArrayOffsetAndSize(idx, offset, 2) | ||
| reference += "ll" | ||
| idx += 1 | ||
| assert(column.arrayData().elementsAppended == 17) | ||
|
|
@@ -644,7 +644,7 @@ class ColumnarBatchSuite extends SparkFunSuite { | |
| assert(column.arrayData().elementsAppended == 17 + (s + s).length) | ||
|
|
||
| reference.zipWithIndex.foreach { v => | ||
| assert(v._1.length == column.getArrayLength(v._2), "MemoryMode=" + memMode) | ||
| assert(v._1.length == column.getInt(v._2 * 2 + 1), "MemoryMode=" + memMode) | ||
|
||
| assert(v._1 == column.getUTF8String(v._2).toString, | ||
| "MemoryMode" + memMode) | ||
| } | ||
|
|
@@ -659,18 +659,18 @@ class ColumnarBatchSuite extends SparkFunSuite { | |
| val column = ColumnVector.allocate(10, new ArrayType(IntegerType, true), memMode) | ||
|
|
||
| // Fill the underlying data with all the arrays back to back. | ||
| val data = column.arrayData(); | ||
| val data = column.arrayData() | ||
| var i = 0 | ||
| while (i < 6) { | ||
| data.putInt(i, i) | ||
| i += 1 | ||
| } | ||
|
|
||
| // Populate it with arrays [0], [1, 2], [], [3, 4, 5] | ||
| column.putArray(0, 0, 1) | ||
| column.putArray(1, 1, 2) | ||
| column.putArray(2, 2, 0) | ||
| column.putArray(3, 3, 3) | ||
| column.putArrayOffsetAndSize(0, 0, 1) | ||
| column.putArrayOffsetAndSize(1, 1, 2) | ||
| column.putArrayOffsetAndSize(2, 3, 0) | ||
| column.putArrayOffsetAndSize(3, 3, 3) | ||
|
|
||
| val a1 = ColumnVectorUtils.toPrimitiveJavaArray(column.getArray(0)).asInstanceOf[Array[Int]] | ||
| val a2 = ColumnVectorUtils.toPrimitiveJavaArray(column.getArray(1)).asInstanceOf[Array[Int]] | ||
|
|
@@ -703,7 +703,7 @@ class ColumnarBatchSuite extends SparkFunSuite { | |
| data.reserve(array.length) | ||
| assert(data.capacity == array.length * 2) | ||
| data.putInts(0, array.length, array, 0) | ||
| column.putArray(0, 0, array.length) | ||
| column.putArrayOffsetAndSize(0, 0, array.length) | ||
| assert(ColumnVectorUtils.toPrimitiveJavaArray(column.getArray(0)).asInstanceOf[Array[Int]] | ||
| === array) | ||
| }} | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
One question I just have is, the capacity of
ColumnVectoris bound byMAX_CAPACITY. Previously we store offset and length individually, so we can haveMAX_CAPACITYarrays at most. Now we store offset and length together in data/intData which is bound toMAX_CAPACITY, doesn't it say we can just haveMAX_CAPACITY / 2arrays at most?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.
Good catch. Is it possible to use
longData, which has a pair of 32-bit offset and length, to keepMAX_CAPACITYarray length?Uh oh!
There was an error while loading. Please reload this page.
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.
Oh. I see. We only check the limit ofMAX_CAPACITYbefore actually going intoreserveInternal.Even we pass this check, we still face problem when allocating
intData, see the comment below.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.
@kiszk Do you meant we store a pair of offset/length together as an element in
longData?