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
38f6bce3
Commit
38f6bce3
authored
14 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Added SerializingCache
parent
6316c797
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/KryoSerialization.scala
+1
-1
1 addition, 1 deletion
core/src/main/scala/spark/KryoSerialization.scala
core/src/main/scala/spark/SerializingCache.scala
+26
-0
26 additions, 0 deletions
core/src/main/scala/spark/SerializingCache.scala
with
27 additions
and
1 deletion
core/src/main/scala/spark/KryoSerialization.scala
+
1
−
1
View file @
38f6bce3
...
...
@@ -117,7 +117,7 @@ class KryoSerialization extends SerializationStrategy with Logging {
val
kryo
=
new
Kryo
()
val
toRegister
:
Seq
[
AnyRef
]
=
Seq
(
// Arrays
Array
(
1
),
Array
(
1.0
),
Array
(
1.0f
),
Array
(
1L
),
Array
(
""
),
Array
(
1
),
Array
(
1.0
),
Array
(
1.0f
),
Array
(
1L
),
Array
(
""
),
Array
((
""
,
""
)),
// Specialized Tuple2s
(
""
,
""
),
(
1
,
1
),
(
1.0
,
1.0
),
(
1L
,
1L
),
(
1
,
1.0
),
(
1.0
,
1
),
(
1L
,
1.0
),
(
1.0
,
1L
),
(
1
,
1L
),
(
1L
,
1
),
...
...
This diff is collapsed.
Click to expand it.
core/src/main/scala/spark/SerializingCache.scala
0 → 100644
+
26
−
0
View file @
38f6bce3
package
spark
import
java.io._
/**
* Wrapper around a BoundedMemoryCache that stores serialized objects as
* byte arrays in order to reduce storage cost and GC overhead
*/
class
SerializingCache
extends
Cache
with
Logging
{
val
bmc
=
new
BoundedMemoryCache
override
def
put
(
key
:
Any
,
value
:
Any
)
{
val
ser
=
Serializer
.
newInstance
()
bmc
.
put
(
key
,
ser
.
serialize
(
value
))
}
override
def
get
(
key
:
Any
)
:
Any
=
{
val
bytes
=
bmc
.
get
(
key
)
if
(
bytes
!=
null
)
{
val
ser
=
Serializer
.
newInstance
()
return
ser
.
deserialize
(
bytes
.
asInstanceOf
[
Array
[
Byte
]])
}
else
{
return
null
}
}
}
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