aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/spark/SoftReferenceCache.scala
blob: 3dd0a4b1f9522065bfb8b0b1a809fba23caa8bd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package spark

import com.google.common.collect.MapMaker

/**
 * An implementation of Cache that uses soft references.
 */
private[spark] class SoftReferenceCache extends Cache {
  val map = new MapMaker().softValues().makeMap[Any, Any]()

  override def get(datasetId: Any, partition: Int): Any =
    map.get((datasetId, partition))

  override def put(datasetId: Any, partition: Int, value: Any): CachePutResponse = {
    map.put((datasetId, partition), value)
    return CachePutSuccess(0)
  }
}