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
55c66d36
Commit
55c66d36
authored
12 years ago
by
Shivaram Venkataraman
Browse files
Options
Downloads
Patches
Plain Diff
Use a dummy string class in Size Estimator tests to make it resistant to jdk
versions
parent
77d75173
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/test/scala/spark/SizeEstimatorSuite.scala
+21
-12
21 additions, 12 deletions
core/src/test/scala/spark/SizeEstimatorSuite.scala
with
21 additions
and
12 deletions
core/src/test/scala/spark/SizeEstimatorSuite.scala
+
21
−
12
View file @
55c66d36
...
@@ -20,6 +20,15 @@ class DummyClass4(val d: DummyClass3) {
...
@@ -20,6 +20,15 @@ class DummyClass4(val d: DummyClass3) {
val
x
:
Int
=
0
val
x
:
Int
=
0
}
}
object
DummyString
{
def
apply
(
str
:
String
)
:
DummyString
=
new
DummyString
(
str
.
toArray
)
}
class
DummyString
(
val
arr
:
Array
[
Char
])
{
override
val
hashCode
:
Int
=
0
// JDK-7 has an extra hash32 field http://hg.openjdk.java.net/jdk7u/jdk7u6/jdk/rev/11987e85555f
@transient
val
hash32
:
Int
=
0
}
class
SizeEstimatorSuite
class
SizeEstimatorSuite
extends
FunSuite
with
BeforeAndAfterAll
with
PrivateMethodTester
with
ShouldMatchers
{
extends
FunSuite
with
BeforeAndAfterAll
with
PrivateMethodTester
with
ShouldMatchers
{
...
@@ -50,10 +59,10 @@ class SizeEstimatorSuite
...
@@ -50,10 +59,10 @@ class SizeEstimatorSuite
// http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
// http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
// Work around to check for either.
// Work around to check for either.
test
(
"strings"
)
{
test
(
"strings"
)
{
SizeEstimator
.
estimate
(
""
)
should
(
equal
(
48
)
or
equal
(
40
))
SizeEstimator
.
estimate
(
DummyString
(
""
)
)
should
(
equal
(
48
)
or
equal
(
40
))
SizeEstimator
.
estimate
(
"a"
)
should
(
equal
(
56
)
or
equal
(
48
))
SizeEstimator
.
estimate
(
DummyString
(
"a"
)
)
should
(
equal
(
56
)
or
equal
(
48
))
SizeEstimator
.
estimate
(
"ab"
)
should
(
equal
(
56
)
or
equal
(
48
))
SizeEstimator
.
estimate
(
DummyString
(
"ab"
)
)
should
(
equal
(
56
)
or
equal
(
48
))
SizeEstimator
.
estimate
(
"abcdefgh"
)
should
(
equal
(
64
)
or
equal
(
56
))
SizeEstimator
.
estimate
(
DummyString
(
"abcdefgh"
)
)
should
(
equal
(
64
)
or
equal
(
56
))
}
}
test
(
"primitive arrays"
)
{
test
(
"primitive arrays"
)
{
...
@@ -105,10 +114,10 @@ class SizeEstimatorSuite
...
@@ -105,10 +114,10 @@ class SizeEstimatorSuite
val
initialize
=
PrivateMethod
[
Unit
](
'initialize
)
val
initialize
=
PrivateMethod
[
Unit
](
'initialize
)
SizeEstimator
invokePrivate
initialize
()
SizeEstimator
invokePrivate
initialize
()
expect
(
40
)(
SizeEstimator
.
estimate
(
""
))
expect
(
40
)(
SizeEstimator
.
estimate
(
DummyString
(
""
))
)
expect
(
48
)(
SizeEstimator
.
estimate
(
"a"
))
expect
(
48
)(
SizeEstimator
.
estimate
(
DummyString
(
"a"
))
)
expect
(
48
)(
SizeEstimator
.
estimate
(
"ab"
))
expect
(
48
)(
SizeEstimator
.
estimate
(
DummyString
(
"ab"
))
)
expect
(
56
)(
SizeEstimator
.
estimate
(
"abcdefgh"
))
expect
(
56
)(
SizeEstimator
.
estimate
(
DummyString
(
"abcdefgh"
))
)
resetOrClear
(
"os.arch"
,
arch
)
resetOrClear
(
"os.arch"
,
arch
)
}
}
...
@@ -124,10 +133,10 @@ class SizeEstimatorSuite
...
@@ -124,10 +133,10 @@ class SizeEstimatorSuite
val
initialize
=
PrivateMethod
[
Unit
](
'initialize
)
val
initialize
=
PrivateMethod
[
Unit
](
'initialize
)
SizeEstimator
invokePrivate
initialize
()
SizeEstimator
invokePrivate
initialize
()
SizeEstimator
.
estimate
(
""
)
should
(
equal
(
64
)
or
equal
(
56
))
SizeEstimator
.
estimate
(
DummyString
(
""
)
)
should
(
equal
(
64
)
or
equal
(
56
))
SizeEstimator
.
estimate
(
"a"
)
should
(
equal
(
72
)
or
equal
(
64
))
SizeEstimator
.
estimate
(
DummyString
(
"a"
)
)
should
(
equal
(
72
)
or
equal
(
64
))
SizeEstimator
.
estimate
(
"ab"
)
should
(
equal
(
72
)
or
equal
(
64
))
SizeEstimator
.
estimate
(
DummyString
(
"ab"
)
)
should
(
equal
(
72
)
or
equal
(
64
))
SizeEstimator
.
estimate
(
"abcdefgh"
)
should
(
equal
(
80
)
or
equal
(
72
))
SizeEstimator
.
estimate
(
DummyString
(
"abcdefgh"
)
)
should
(
equal
(
80
)
or
equal
(
72
))
resetOrClear
(
"os.arch"
,
arch
)
resetOrClear
(
"os.arch"
,
arch
)
resetOrClear
(
"spark.test.useCompressedOops"
,
oops
)
resetOrClear
(
"spark.test.useCompressedOops"
,
oops
)
...
...
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