Github user eyalfa commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18855#discussion_r131913940
  
    --- Diff: 
core/src/test/scala/org/apache/spark/storage/BlockManagerSuite.scala ---
    @@ -1415,6 +1415,79 @@ class BlockManagerSuite extends SparkFunSuite with 
Matchers with BeforeAndAfterE
           super.fetchBlockSync(host, port, execId, blockId)
         }
       }
    +
    +  def testGetOrElseUpdateForLargeBlock(storageLevel : StorageLevel) {
    +    store = makeBlockManager(6L * 1024 * 1024 * 1024, "exec1")
    +    def mkBlobs() = {
    +      val rng = new java.util.Random(42)
    +      val buff = new Array[Byte](1024 * 1024)
    +      rng.nextBytes(buff)
    +      Iterator.fill(2 * 1024 + 1) {
    +        buff
    +      }
    +    }
    +    val res1 = store.getOrElseUpdate(
    +      RDDBlockId(42, 0),
    +      storageLevel,
    +      implicitly[ClassTag[Array[Byte]]],
    +      mkBlobs _
    +    )
    +    withClue(res1) {
    +      assert(res1.isLeft)
    +      assert(res1.left.get.data.zipAll(mkBlobs(), null, null).forall {
    +        case (a, b) =>
    +          a != null &&
    +            b != null &&
    +            a.asInstanceOf[Array[Byte]].seq == 
b.asInstanceOf[Array[Byte]].seq
    +      })
    +    }
    +    val getResult = store.get(RDDBlockId(42, 0))
    +    withClue(getResult) {
    +      assert(getResult.isDefined)
    +      assert(getResult.get.data.zipAll(mkBlobs(), null, null).forall {
    +        case (a, b) =>
    +          a != null &&
    +            b != null &&
    +            a.asInstanceOf[Array[Byte]].seq == 
b.asInstanceOf[Array[Byte]].seq
    +      })
    +    }
    +    val getBlockRes = store.getBlockData(RDDBlockId(42, 0))
    +    withClue(getBlockRes) {
    +      try {
    +        assert(getBlockRes.size() >= 2 * 1024 * 1024 * 1024)
    +        Utils.tryWithResource(getBlockRes.createInputStream()) { inpStrm =>
    +          val iter = store
    +            .serializerManager
    +            .dataDeserializeStream(RDDBlockId(42, 0)
    +              , inpStrm)(implicitly[ClassTag[Array[Byte]]])
    +          assert(iter.zipAll(mkBlobs(), null, null).forall {
    +            case (a, b) =>
    +              a != null &&
    +                b != null &&
    +                a.asInstanceOf[Array[Byte]].seq == 
b.asInstanceOf[Array[Byte]].seq
    +          })
    +        }
    +      } finally {
    +        getBlockRes.release()
    +      }
    +    }
    +  }
    +
    +  test("getOrElseUpdate > 2gb, storage level = disk only") {
    --- End diff --
    
    these tests cover more than just the `DiskOnly` storage level, they were 
crafted when I had bigger ambitions of solving the entire 2GB issue 
:sunglasses: , that was before seeing some ~100 files pull requests being 
abandoned or rejected.
    aside, these tests also test the entire orchestration done by 
`BlockManager` when an `RDD` requests a cached partition, notice that these 
tests intentionally makes two calls to the BlockManager in order to simulate 
both code paths (cache-hit, cache-miss).


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to