Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
105f4d22
Commit
105f4d22
authored
11 years ago
by
Reynold Xin
Browse files
Options
Downloads
Patches
Plain Diff
Removed Cache and SoftReferenceCache since they are no longer used.
parent
17e62113
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/Cache.scala
+0
-80
0 additions, 80 deletions
core/src/main/scala/spark/Cache.scala
core/src/main/scala/spark/SoftReferenceCache.scala
+0
-35
0 additions, 35 deletions
core/src/main/scala/spark/SoftReferenceCache.scala
with
0 additions
and
115 deletions
core/src/main/scala/spark/Cache.scala
deleted
100644 → 0
+
0
−
80
View file @
17e62113
/*
* 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
spark
import
java.util.concurrent.atomic.AtomicInteger
private
[
spark
]
sealed
trait
CachePutResponse
private
[
spark
]
case
class
CachePutSuccess
(
size
:
Long
)
extends
CachePutResponse
private
[
spark
]
case
class
CachePutFailure
()
extends
CachePutResponse
/**
* An interface for caches in Spark, to allow for multiple implementations. Caches are used to store
* both partitions of cached RDDs and broadcast variables on Spark executors. Caches are also aware
* of which entries are part of the same dataset (for example, partitions in the same RDD). The key
* for each value in a cache is a (datasetID, partition) pair.
*
* A single Cache instance gets created on each machine and is shared by all caches (i.e. both the
* RDD split cache and the broadcast variable cache), to enable global replacement policies.
* However, because these several independent modules all perform caching, it is important to give
* them separate key namespaces, so that an RDD and a broadcast variable (for example) do not use
* the same key. For this purpose, Cache has the notion of KeySpaces. Each client module must first
* ask for a KeySpace, and then call get() and put() on that space using its own keys.
*
* This abstract class handles the creation of key spaces, so that subclasses need only deal with
* keys that are unique across modules.
*/
private
[
spark
]
abstract
class
Cache
{
private
val
nextKeySpaceId
=
new
AtomicInteger
(
0
)
private
def
newKeySpaceId
()
=
nextKeySpaceId
.
getAndIncrement
()
def
newKeySpace
()
=
new
KeySpace
(
this
,
newKeySpaceId
())
/**
* Get the value for a given (datasetId, partition), or null if it is not
* found.
*/
def
get
(
datasetId
:
Any
,
partition
:
Int
)
:
Any
/**
* Attempt to put a value in the cache; returns CachePutFailure if this was
* not successful (e.g. because the cache replacement policy forbids it), and
* CachePutSuccess if successful. If size estimation is available, the cache
* implementation should set the size field in CachePutSuccess.
*/
def
put
(
datasetId
:
Any
,
partition
:
Int
,
value
:
Any
)
:
CachePutResponse
/**
* Report the capacity of the cache partition. By default this just reports
* zero. Specific implementations can choose to provide the capacity number.
*/
def
getCapacity
:
Long
=
0L
}
/**
* A key namespace in a Cache.
*/
private
[
spark
]
class
KeySpace
(
cache
:
Cache
,
val
keySpaceId
:
Int
)
{
def
get
(
datasetId
:
Any
,
partition
:
Int
)
:
Any
=
cache
.
get
((
keySpaceId
,
datasetId
),
partition
)
def
put
(
datasetId
:
Any
,
partition
:
Int
,
value
:
Any
)
:
CachePutResponse
=
cache
.
put
((
keySpaceId
,
datasetId
),
partition
,
value
)
def
getCapacity
:
Long
=
cache
.
getCapacity
}
This diff is collapsed.
Click to expand it.
core/src/main/scala/spark/SoftReferenceCache.scala
deleted
100644 → 0
+
0
−
35
View file @
17e62113
/*
* 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
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
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment