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
[WIP][SPARK-39202][SQL] Introduce a putByteArrays
method for WritableColumnVector
to support setting multiple duplicate byte[]
#36571
Closed
Closed
Conversation
This file contains 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
LuciferYang
commented
May 17, 2022
* Results will be written to "benchmarks/ColumnVectorUtilsBenchmark-results.txt". | ||
* }}} | ||
*/ | ||
object ColumnVectorUtilsBenchmark extends BenchmarkBase { |
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.
Will delete after test
For def testPopulate(valuesPerIteration: Int, length: Int): Unit = {
val batchSize = 4096
val onHeapColumnVector = new OnHeapColumnVector(batchSize, StringType)
val offHeapColumnVector = new OffHeapColumnVector(batchSize, StringType)
val benchmark = new Benchmark(
s"Test ColumnVectorUtils.populate, row length = $length",
valuesPerIteration * batchSize,
output = output)
val builder = new UTF8StringBuilder()
builder.append(RandomStringUtils.random(length))
val row = InternalRow(builder.build())
benchmark.addCase("OnHeapColumnVector") { _: Int =>
for (_ <- 0L until valuesPerIteration) {
onHeapColumnVector.reset()
ColumnVectorUtils.populate(onHeapColumnVector, row, 0)
}
}
benchmark.addCase("OffHeapColumnVector") { _: Int =>
for (_ <- 0L until valuesPerIteration) {
offHeapColumnVector.reset()
ColumnVectorUtils.populate(offHeapColumnVector, row, 0)
}
}
benchmark.run()
}
override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
val valuesPerIteration = 100000
Seq(1, 5, 10, 15, 20).foreach { length =>
testPopulate(valuesPerIteration, length)
}
} Before
After
|
LuciferYang
changed the title
[SPARK-39202][SQL] Introduce a
[SPARK-39202][SQL] Introduce a May 17, 2022
putByteArrays
method to WritableColumnVector
to support setting multiple duplicate byte[]
putByteArrays
method for WritableColumnVector
to support setting multiple duplicate byte[]
LuciferYang
changed the title
[SPARK-39202][SQL] Introduce a
[WIP][SPARK-39202][SQL] Introduce a May 18, 2022
putByteArrays
method for WritableColumnVector
to support setting multiple duplicate byte[]
putByteArrays
method for WritableColumnVector
to support setting multiple duplicate byte[]
Maybe it's better to use a dictionary to store |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
This pr add a
putByteArrays
method forWritableColumnVector
as follows:This method used to support setting multiple duplicate
byte[]
toWritableColumnVector
. Sincebyte[] value
is fixed length, memory can allocated at one time without callingreserve(int requiredCapacity)
method many times.The new method is applicable to
ColumnVectorUtils.populate
method withStringType
and partialDecimalType
scenario, this corresponds to the Vectorized Partition Column filling of Parquet and Orc.Why are the changes needed?
Reduce
reserve(int requiredCapacity)
call times to avoid memory allocation times in setting multiple duplicate fixed lengthbyte[]
toWritableColumnVector
scene.Does this PR introduce any user-facing change?
No.
How was this patch tested?
StringType
partition column test scenario inDataSourceReadBenchmark
.Before
After