Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/10335#discussion_r47952489
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/basicOperators.scala ---
@@ -126,6 +127,69 @@ case class Sample(
}
}
+case class Range(
+ start: Long,
+ step: Long,
+ numSlices: Int,
+ numElements: BigInt,
+ output: Seq[Attribute])
+ extends LeafNode {
+
+ override def outputsUnsafeRows: Boolean = true
+
+ protected override def doExecute(): RDD[InternalRow] = {
+ sqlContext
+ .sparkContext
+ .parallelize(0 until numSlices, numSlices)
+ .mapPartitionsWithIndex((i, _) => {
+ val partitionStart = (i * numElements) / numSlices * step + start
+ val partitionEnd = (((i + 1) * numElements) / numSlices) * step +
start
+ def getSafeMargin(bi: BigInt): Long =
+ if (bi.isValidLong) {
+ bi.toLong
+ } else if (bi > 0) {
+ Long.MaxValue
+ } else {
+ Long.MinValue
+ }
+ val safePartitionStart = getSafeMargin(partitionStart)
+ val safePartitionEnd = getSafeMargin(partitionEnd)
+ val bufferHolder = new BufferHolder(LongType.defaultSize)
--- End diff --
So I am not confident that this works. You are allocating 8-bytes by
calling this constructor. Without a growing the buffer, you allocate a byte
array of 8 bytes to the ```UnsafeRow```, which is happening here. You would
need at least 16 bytes for ```UnsafeRow``` to work (8 for the bitset and 8 for
the long).
```BufferHolder``` is meant to be used with ```Unsafe*Writer``` classes. I
don't think it adds much value here. I think we should just use a 16 byte array
instead.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]