GithubHelp home page GithubHelp logo

Comments (4)

koertkuipers avatar koertkuipers commented on August 23, 2024

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
690618

But 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.

lvsl-deactivated avatar lvsl-deactivated commented on August 23, 2024

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.

koertkuipers avatar koertkuipers commented on August 23, 2024

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.

lvsl-deactivated avatar lvsl-deactivated commented on August 23, 2024

Thanks!
As mentioned in #5 the matStreamByKey should be named flatMapStreamByKey, that would help to avoid come confusion.

from spark-sorted.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.