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

    https://github.com/apache/spark/pull/50#discussion_r10201080
  
    --- Diff: 
core/src/test/scala/org/apache/spark/storage/FlatmapIteratorSuite.scala ---
    @@ -0,0 +1,83 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.spark.storage
    +
    +import org.scalatest.FunSuite
    +import org.apache.spark.{SharedSparkContext, SparkConf, LocalSparkContext, 
SparkContext}
    +
    +
    +class FlatmapIteratorSuite extends FunSuite with LocalSparkContext {
    +  /* Tests the ability of Spark to deal with user provided iterators from 
flatMap
    +   * calls, that may generate more data then available memory. In any
    +   * memory based persistance Spark will unroll the iterator into an 
ArrayBuffer
    +   * for caching, however in the case that the use defines DISK_ONLY 
persistance,
    +   * the iterator will be fed directly to the serializer and written to 
disk.
    +   *
    +   * This also tests the ObjectOutputStream reset rate. When serializing 
using the
    +   * Java serialization system, the serializer caches objects to prevent 
writing redundant
    +   * data, however that stops GC of those objects. By calling 'reset' you 
flush that
    +   * info from the serializer, and allow old objects to be GC'd
    +   */
    +  test("Flatmap Iterator to Disk") {
    +    val sconf = new SparkConf().setMaster("local-cluster[1,1,512]")
    +      .setAppName("iterator_to_disk_test")
    +    sc = new SparkContext(sconf)
    +    try {
    +      val expand_size = 100
    +      val data = sc.parallelize( (1 to 5).toSeq ).
    +        flatMap( x => Stream.range(0, expand_size) )
    +      var persisted = data.persist(StorageLevel.DISK_ONLY)
    +      println(persisted.count())
    +      assert( persisted.count() == 500)
    +      assert( persisted.filter( _==1 ).count() == 5 )
    --- End diff --
    
    Also in ScalaTest, you can use `===` instead of `==` to get nicer error 
messages (e.g. "expected 5 but got 4" instead of "assertion failed: false").


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

Reply via email to