Questions tagged [reducing]

37 questions
98
votes
6 answers

Spark difference between reduceByKey vs. groupByKey vs. aggregateByKey vs. combineByKey

Can anyone explain the difference between reducebykey, groupbykey, aggregatebykey and combinebykey? I have read the documents regarding this, but couldn't understand the exact differences. An explanation with examples would be great.
Arun S
  • 1,363
  • 3
  • 13
  • 17
16
votes
4 answers

How do I reduce frames with blending in ffmpeg

I am trying to convert some files into ProRes. One fairly important part of the conversion is: reducing frames from 60 to 30 blending every 2 frames into one and achieving a more fluent movement. (a simple sort of motion blur) I have tried the…
user3213418
  • 169
  • 1
  • 3
13
votes
1 answer

Java Streams: Replacing groupingBy and reducing by toMap

I've asked a question before about enhancing some code, here. @Holger gives me the right response and he said that: Whenever you find yourself using the reducing collector with groupingBy, you should check whether toMap isn’t more appropriate It…
bubbles
  • 2,597
  • 1
  • 15
  • 40
9
votes
4 answers

Why does Stream.reduce take BinaryOperator rather than BiFunction?

For my specific case I want to use functional composition in a reduction; for example: BiFunction, ImmutableSet, Sets.SetView> f = Sets::intersection; Function, ImmutableSet> g =…
wilmol
  • 1,429
  • 16
  • 22
5
votes
2 answers

Boil down events to time intervals

Scenario: I have a service that logs events like in this CSV example: #TimeStamp, Name, ColorOfPullover TimeStamp01, Peter, Green TimeStamp02, Bob, Blue TimeStamp03, Peter, Green TimeStamp04, Peter, Red TimeStamp05, Peter, Green Events that e.g.…
fex
  • 197
  • 1
  • 13
4
votes
3 answers

Java Stream GroupBy and Reduce

I have an Item class which contains a code, quantity and amount fields, and a list of items which may contain many items (with same code). I want to group the items by code and sum up their quantities and amounts. I was able to achieve half of it…
hakuna matata
  • 3,243
  • 13
  • 56
  • 93
4
votes
1 answer

Reducing algorithm for SHA256 rainbow tables

I am doing a project on cracking sha256 using rainbow tables. I am trying to attack 8 digit alphanumeric sequences. I understand exactly how rainbow tables work and how the chains are supposed to be formed and stored. However, I do not understand…
Rishab Mehra
  • 159
  • 2
  • 9
3
votes
8 answers

Are design patterns something you invent as you go

Are there set design patterns or does each individual sufficiently skilled software developer recognize and reduce their code to develop new patterns. Effectively creating their own "design" patterns. Edit - Thanks for the responses. In reality…
user21826
  • 3,524
  • 5
  • 28
  • 28
3
votes
2 answers

I'm having an issue to use GLshort for representing Vertex, and Normal

As my project gets close to optimization stage, I notice that reducing Vertex Metadata could vastly improve the performance of 3D rendering. Eventually, I've dearly searched around and have found following advices from stackoverflow. Using GL_SHORT…
Xylopia
  • 55
  • 6
2
votes
4 answers

Get specific data from an array of object and convert to object

I have an array of objects. In the each object is also another array. Structure: function getData() { return [ { _id: 1, tags: ["tomato", "butter", "milk"], title: "How to make soup?", category: "Food" }, { …
tomasconnor
  • 121
  • 8
2
votes
2 answers

"Outsource" recurring code into a function with parameters (js)

so i use one js file to load multiple html and js files whenever they are needed. I have a working code for plenty modules. In the example below you can see the first two modules. All of them look exactly the same. Now i want to "outsource"…
SaltyM
  • 93
  • 1
  • 9
2
votes
4 answers

How to reduce large numbers to smallest values keeping relative size differences in C#

Here's my problem. I have potentially large numbers, anywhere from one hundred to one hundred million or even more. I want to feed these numbers to a chart plotter (http://benpickles.github.com/peity/ if you're curious). the problem is, when you…
ijjo
  • 525
  • 9
  • 22
1
vote
1 answer

Reducing array , modifying the accumulator

Is this way of reducing an array (counting occurrences) not recommended? I mean modifying the accumulator is maybe bad? function countOccurrencesReduceOwn(array, searchElement) //seems to work but is maybe not recommended ? { const count =…
Suvi
  • 11
  • 2
1
vote
3 answers

How to change the final type after reduction of a downstream collector in a Java 8 stream?

I got a legacy application using data structures like those in the following toy snippet and I can't easily change these data structures. I use a Java 8 (only) stream to do some stats and I failed to get the wished type using Collectors. package…
Christophe
  • 119
  • 12
1
2 3