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
10697402
Commit
10697402
authored
13 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Added a jarOfObject method to get the JAR of the class that an object
belongs to, which seems like a more common case.
parent
0c965a10
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/main/scala/spark/SparkContext.scala
+7
-5
7 additions, 5 deletions
core/src/main/scala/spark/SparkContext.scala
with
7 additions
and
5 deletions
core/src/main/scala/spark/SparkContext.scala
+
7
−
5
View file @
10697402
...
...
@@ -356,21 +356,23 @@ object SparkContext {
// Find the JAR from which a given class was loaded, to make it easy for users to pass
// their JARs to SparkContext
def
jarOfClass
[
T:
ClassManifest
]
:
Option
[
String
]
=
{
val
cls
=
classManifest
[
T
].
erasure
def
jarOfClass
(
cls
:
Class
[
_
])
:
Seq
[
String
]
=
{
val
uri
=
cls
.
getResource
(
"/"
+
cls
.
getName
.
replace
(
'.'
,
'/'
)
+
".class"
)
if
(
uri
!=
null
)
{
val
uriStr
=
uri
.
toString
if
(
uriStr
.
startsWith
(
"jar:file:"
))
{
// URI will be of the form "jar:file:/path/foo.jar!/package/cls.class", so pull out the /path/foo.jar
Some
(
uriStr
.
substring
(
"jar:file:"
.
length
,
uriStr
.
indexOf
(
'!'
)))
List
(
uriStr
.
substring
(
"jar:file:"
.
length
,
uriStr
.
indexOf
(
'!'
)))
}
else
{
N
one
N
il
}
}
else
{
N
one
N
il
}
}
// Find the JAR that contains the class of a particular object
def
jarOfObject
(
obj
:
AnyRef
)
:
Seq
[
String
]
=
jarOfClass
(
obj
.
getClass
)
}
...
...
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