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
c02e0649
Commit
c02e0649
authored
12 years ago
by
Tathagata Das
Browse files
Options
Downloads
Patches
Plain Diff
Fixed replication bug in BlockManager
parent
4d480ec5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/storage/MemoryStore.scala
+2
-2
2 additions, 2 deletions
core/src/main/scala/spark/storage/MemoryStore.scala
core/src/test/scala/spark/DistributedSuite.scala
+15
-1
15 additions, 1 deletion
core/src/test/scala/spark/DistributedSuite.scala
with
17 additions
and
3 deletions
core/src/main/scala/spark/storage/MemoryStore.scala
+
2
−
2
View file @
c02e0649
...
@@ -32,8 +32,8 @@ private class MemoryStore(blockManager: BlockManager, maxMemory: Long)
...
@@ -32,8 +32,8 @@ private class MemoryStore(blockManager: BlockManager, maxMemory: Long)
}
}
override
def
putBytes
(
blockId
:
String
,
bytes
:
ByteBuffer
,
level
:
StorageLevel
)
{
override
def
putBytes
(
blockId
:
String
,
bytes
:
ByteBuffer
,
level
:
StorageLevel
)
{
bytes
.
rewind
()
if
(
level
.
deserialized
)
{
if
(
level
.
deserialized
)
{
bytes
.
rewind
()
val
values
=
blockManager
.
dataDeserialize
(
blockId
,
bytes
)
val
values
=
blockManager
.
dataDeserialize
(
blockId
,
bytes
)
val
elements
=
new
ArrayBuffer
[
Any
]
val
elements
=
new
ArrayBuffer
[
Any
]
elements
++=
values
elements
++=
values
...
@@ -58,7 +58,7 @@ private class MemoryStore(blockManager: BlockManager, maxMemory: Long)
...
@@ -58,7 +58,7 @@ private class MemoryStore(blockManager: BlockManager, maxMemory: Long)
}
else
{
}
else
{
val
bytes
=
blockManager
.
dataSerialize
(
blockId
,
values
.
iterator
)
val
bytes
=
blockManager
.
dataSerialize
(
blockId
,
values
.
iterator
)
tryToPut
(
blockId
,
bytes
,
bytes
.
limit
,
false
)
tryToPut
(
blockId
,
bytes
,
bytes
.
limit
,
false
)
PutResult
(
bytes
.
limit
(),
Right
(
bytes
))
PutResult
(
bytes
.
limit
(),
Right
(
bytes
.
duplicate
()
))
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/spark/DistributedSuite.scala
+
15
−
1
View file @
c02e0649
package
spark
package
spark
import
network.ConnectionManagerId
import
org.scalatest.FunSuite
import
org.scalatest.FunSuite
import
org.scalatest.BeforeAndAfter
import
org.scalatest.BeforeAndAfter
import
org.scalatest.matchers.ShouldMatchers
import
org.scalatest.matchers.ShouldMatchers
...
@@ -13,7 +14,7 @@ import com.google.common.io.Files
...
@@ -13,7 +14,7 @@ import com.google.common.io.Files
import
scala.collection.mutable.ArrayBuffer
import
scala.collection.mutable.ArrayBuffer
import
SparkContext._
import
SparkContext._
import
storage.StorageLevel
import
storage.
{
GetBlock
,
BlockManagerWorker
,
StorageLevel
}
class
DistributedSuite
extends
FunSuite
with
ShouldMatchers
with
BeforeAndAfter
with
LocalSparkContext
{
class
DistributedSuite
extends
FunSuite
with
ShouldMatchers
with
BeforeAndAfter
with
LocalSparkContext
{
...
@@ -140,9 +141,22 @@ class DistributedSuite extends FunSuite with ShouldMatchers with BeforeAndAfter
...
@@ -140,9 +141,22 @@ class DistributedSuite extends FunSuite with ShouldMatchers with BeforeAndAfter
test
(
"caching in memory and disk, serialized, replicated"
)
{
test
(
"caching in memory and disk, serialized, replicated"
)
{
sc
=
new
SparkContext
(
clusterUrl
,
"test"
)
sc
=
new
SparkContext
(
clusterUrl
,
"test"
)
val
data
=
sc
.
parallelize
(
1
to
1000
,
10
).
persist
(
StorageLevel
.
MEMORY_AND_DISK_SER_2
)
val
data
=
sc
.
parallelize
(
1
to
1000
,
10
).
persist
(
StorageLevel
.
MEMORY_AND_DISK_SER_2
)
assert
(
data
.
count
()
===
1000
)
assert
(
data
.
count
()
===
1000
)
assert
(
data
.
count
()
===
1000
)
assert
(
data
.
count
()
===
1000
)
assert
(
data
.
count
()
===
1000
)
assert
(
data
.
count
()
===
1000
)
// Get all the locations of the first partition and try to fetch the partitions
// from those locations.
val
blockIds
=
data
.
partitions
.
indices
.
map
(
index
=>
"rdd_%d_%d"
.
format
(
data
.
id
,
index
)).
toArray
val
blockId
=
blockIds
(
0
)
val
blockManager
=
SparkEnv
.
get
.
blockManager
blockManager
.
master
.
getLocations
(
blockId
).
foreach
(
id
=>
{
val
bytes
=
BlockManagerWorker
.
syncGetBlock
(
GetBlock
(
blockId
),
ConnectionManagerId
(
id
.
ip
,
id
.
port
))
val
deserialized
=
blockManager
.
dataDeserialize
(
blockId
,
bytes
).
asInstanceOf
[
Iterator
[
Int
]].
toList
assert
(
deserialized
===
(
1
to
100
).
toList
)
})
}
}
test
(
"compute without caching when no partitions fit in memory"
)
{
test
(
"compute without caching when no partitions fit in memory"
)
{
...
...
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