spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buryat <...@git.apache.org>
Subject [GitHub] spark pull request #19266: [SPARK-22033][CORE] BufferHolder, other size chec...
Date Mon, 18 Sep 2017 17:46:26 GMT
Github user buryat commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19266#discussion_r139492024
  
    --- Diff: core/src/main/scala/org/apache/spark/util/collection/CompactBuffer.scala ---
    @@ -126,22 +126,20 @@ private[spark] class CompactBuffer[T: ClassTag] extends Seq[T] with
Serializable
     
       /** Increase our size to newSize and grow the backing array if needed. */
       private def growToSize(newSize: Int): Unit = {
    -    if (newSize < 0) {
    -      throw new UnsupportedOperationException("Can't grow buffer past Int.MaxValue elements")
    +    val arrayMax = Int.MaxValue - 8
    +    if (newSize < 0 || newSize - 2 > arrayMax) {
    +      throw new UnsupportedOperationException(s"Can't grow buffer past $arrayMax elements")
         }
         val capacity = if (otherElements != null) otherElements.length + 2 else 2
         if (newSize > capacity) {
    -      var newArrayLen = 8
    +      var newArrayLen = 8L
           while (newSize - 2 > newArrayLen) {
    --- End diff --
    
    I think we can remove `- 2` now since `newArrayLen` is a Long


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message