Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18855#discussion_r131890389
  
    --- 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 --
    
    shall we just write a test in `DiskStoreSuite`?


---
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