-
Notifications
You must be signed in to change notification settings - Fork 29k
Spark 615 map partitions with index callable from java #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
holdenk
wants to merge
25
commits into
apache:master
from
holdenk:spark-615-mapPartitionsWithIndex-callable-from-java
+50
−6
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
215a9bf
Fix Java API for mapPartitionsWithIndex
holdenk e2331ed
Check all the values
holdenk 0d624bf
Add missing class
holdenk 4421ecc
Use fakeClassTag
holdenk 8d849a1
Fix Java API for mapPartitionsWithIndex
holdenk 958efa4
Check all the values
holdenk 6ad1a3c
Add missing class
holdenk e64e1ad
Use fakeClassTag
holdenk 8bfd3f3
It compiles with the Java 8 happy pandas
holdenk b6a613f
merge
holdenk 36c7831
Remove old function
holdenk 79d1bc1
Check all the values
holdenk ec80d7a
Add missing class
holdenk e4962ab
Use fakeClassTag
holdenk f484afc
Fix Java API for mapPartitionsWithIndex
holdenk 4eb9c0f
Add missing class
holdenk 96a86c7
It compiles with the Java 8 happy pandas
holdenk df6922a
Remove old function
holdenk 4fa42b0
Revert "Remove old function (accidently removed a file)"
holdenk 2aa2fc9
Make it work with the new Java API style
holdenk cc4050d
Add Java 8 API test
holdenk ee6ebea
Some CR feedback
holdenk 780120d
Remove MappartitionsWithIndeFunction
holdenk a5cd2fa
Fix Java API
holdenk b231375
Fix the classtag bits
holdenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add Java 8 API test
- Loading branch information
commit cc4050d86032d6da2f9662bb8a2595567a994210
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,6 +245,24 @@ public void mapPartitions() { | |
| Assert.assertEquals("[3, 7]", partitionSums.collect().toString()); | ||
| } | ||
|
|
||
| @Test | ||
| public void mapPartitionsWithIndex() { | ||
| JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 2, 3, 4), 2); | ||
| JavaRDD<Integer> partitionSums = rdd.mapPartitionsWithIndex((start, iter) -> { | ||
| List<Integer> list = new ArrayList<Integer>(); | ||
| int sum = 0; | ||
| int pos = start; | ||
| while (iter.hasNext()) { | ||
| sum += (pos* iter.next()); | ||
| pos += 1; | ||
| } | ||
| return list.iterator(); | ||
| }); | ||
| Assert.assertEquals(0, rddByIndex.first().intValue()); | ||
| Integer[] values = {0, 2, 6, 12, 20}; | ||
| Assert.assertEquals(Arrays.asList(values), rddByIndex.collect()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually this test is just broken as is, there's no |
||
| } | ||
|
|
||
| @Test | ||
| public void sequenceFile() { | ||
| File tempDir = Files.createTempDir(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indents seem messed up here, should both be 2 spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also space before
*