Comments (4)
hey leonid,
mapStreamByKey takes in an Iterator[V] of values per key, and returns a
TraversableOnce[W]. it should process every key exactly once, but it has no
guarantee that it produces one result per key.
Can you provide some more detail on aggregateSomeCaseClass? if
aggregateSomeCaseClass returns at most one element per key then you should
not have duplicates in the output and this could be a bug indeed.
On Tue, Aug 4, 2015 at 4:40 AM, Leonid [email protected] wrote:
Hi, in the following example mapStreamByKey produces duplicate keys:
val binRDD = sc.binaryFile('file://...')
val pairs: RDD[(String, SomeCaseClass)] = binRDD.flatMap(parseBinaryStream)
val sorted: GroupSorted[(String, SomeCaseClass)] = pairs.groupSort(Some(implicitly[Ordering[SomeCaseClass]]))
val mapped: RDD[(String, AggValues)] = sorted.mapStreamByKey(aggregateSomeCaseClass)
mapper.collect.foreach(o => { /*write o._1 to a text file */ })When I check the text file I got the following:
$ gzcat /tmp/all.txt.gz | wc -l
729109
$ gzcat /tmp/all.txt.gz | sort | uniq | wc -l
690618But as far as I understand, mapStreamByKey should process one key exactly
once.
Am I missing something?—
Reply to this email directly or view it on GitHub
#4.
from spark-sorted.
Hi, thanks for quick response!
The aggregateSomeCaseClass, returns an Iterator[AggregateCaseClass], the function looks something like this:
def aggregateSomeCaseClass(items: Iterator[SomeCaseClass]): Iterator[AggregateCaseClass] = {
val aggItems: SortedMap[String, AggregateCaseClass] = ...
aggItems.valuesIterator
}
from spark-sorted.
it looks like you return multiple values per key that way.
in your example the number of returned values per key is the size of
aggItems, which can be bigger than 1. each returned value becomes a
separate line in the output.
for example if for a given key aggItems has size 5 then you will find 5
lines in the output for that same key.
On Tue, Aug 4, 2015 at 9:55 AM, Leonid [email protected] wrote:
Hi, thanks for quick response!
The aggregateSomeCaseClass, returns an Iterator[AggregateCaseClass], the
function looks something like this:def aggregateSomeCaseClass(items: Iterator[SomeCaseClass]): Iterator[AggregateCaseClass] = {
val aggItems: SortedMap[String, AggregateCaseClass] = ...aggItems.valuesIterator
}—
Reply to this email directly or view it on GitHub
#4 (comment).
from spark-sorted.
Thanks!
As mentioned in #5 the matStreamByKey should be named flatMapStreamByKey, that would help to avoid come confusion.
from spark-sorted.
Related Issues (9)
- sbt-spark-package integration and Spark Packages release HOT 1
- Java api for GroupSorted HOT 3
- mapStreamByKey fails silent if treated as flatMap HOT 7
- Need help find out why spilling is so slow HOT 2
- Getting a strange exception... HOT 5
- Is there a artifact in Maven so I can use in project? HOT 1
- Question: Memory Performance HOT 9
- Still Up ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spark-sorted.