Questions tagged [collect]

Use this tag for questions related to the act of gathering/collecting/grouping data/results from several nodes/places/computers to one (or main) resource(s).

Use this tag for questions related to the act of gathering/collecting/grouping data/results from several nodes/places/computers to one (or main) resource(s).

For example, in Distributed Computing, the slaves would do their local computation and eventually, one would like the master to collect the (local) results.

354 questions
13
votes
2 answers

PHP Laravel 5.5 collections flatten and keep the integer keys?

I have the following array : $array = [ '2' => ['3' => ['56' => '2'], '6' => ['48' => '2']], '4' => ['4' => ['433' => '2', '140' => '2'], '8' => ['421' => '2', '140' => '2']], '5' => ['5' => ['88' => '4', '87' => '2']] ]; The following…
GTMeteor
  • 807
  • 3
  • 9
  • 17
13
votes
4 answers

Error ExecutorLostFailure when running a task in Spark

when I am trying to run it on this folder it is throwing me ExecutorLostFailure everytime Hi I am a beginner in Spark. I am trying to run a job on Spark 1.4.1 with 8 slave nodes with 11.7 GB memory each 3.2 GB Disk . I am running the Spark task from…
User17
  • 131
  • 1
  • 1
  • 4
13
votes
2 answers

Java 8 stream.collect(Collectors.toMap()) analog in kotlin

Suppose I have a list of persons and would like to have Map, where String is person name. How should I do that in kotlin?
Yurii
  • 827
  • 2
  • 13
  • 23
11
votes
4 answers

Java 8 stream join and return multiple values

I'm porting a piece of code from .NET to Java and stumbled upon a scenario where I want to use stream to map & reduce. class Content { private String propA, propB, propC; Content(String a, String b, String c) { propA = a; propB = b; propC…
Vedanth
  • 275
  • 2
  • 3
  • 7
11
votes
1 answer

Fuzzy join between two large datasets in Spark

I need to do a fuzzy join between two large dataset (assuming 30Gb for each dataset) based on the similarity of two columns of string. For example: Table 1: Key1 |Value1 ------------- 1 |qsdm fkq jmsk fqj msdk Table 2: Key2 …
minh-hieu.pham
  • 1,029
  • 2
  • 12
  • 21
11
votes
2 answers

How to improve code that quotes all array elements with `'` and returns a string containing all those quoted and comma-separated elements?

I am using Rails 3.2.2 and I would like to quote all array elements with ' and return a string containing all those quoted and comma-separated elements. At this time I am using ['a', 'b', 'c'].collect {|x| "'#{x}'"}.join(", ") # => "'a', 'b',…
Backo
  • 18,291
  • 27
  • 103
  • 170
10
votes
1 answer

Pypsark - Retain null values when using collect_list

According to the accepted answer in pyspark collect_set or collect_list with groupby, when you do a collect_list on a certain column, the null values in this column are removed. I have checked and this is true. But in my case, I need to keep the…
8
votes
2 answers

How can I use a named scope in my model against an array of items?

I know that I can do a query for recent books based on an array as in scope :recent_books, lambda {|since_dt| {:conditions=>{:created_at >= since_dt}}} but how can I do a similar query when I have an array of items, e.g. what if I want to know if…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
8
votes
3 answers

Java 8 stream api how to collect List to Object

I have two simple class ImageEntity and ImageList how to collect result list ImageEntity to ImageList ? List files = listFiles(); ImageList imageList = files.stream().map(file -> { return new ImageEntity( …
Atum
  • 1,211
  • 1
  • 12
  • 14
8
votes
9 answers

Scala: Best way to filter & map in one iteration

I'm new to Scala and trying to figure out the best way to filter & map a collection. Here's a toy example to explain my problem. Approach 1: This is pretty bad since I'm iterating through the list twice and calculating the same value in each…
Can Bal
  • 1,533
  • 1
  • 13
  • 26
7
votes
4 answers

I want my memory back! How can I truly dispose a control?

I have an application I am making that creates a large number of windows controls (buttons and labels etc). They are all being made dynamically through functions. The problem I'm having is, when I remove the controls and dispose them, they are not…
user248634
7
votes
4 answers

Appending a collect array with unique values

So I have an array built by collect. @a = Relation.where(part: "v04") @relations = @a.collect {|x| x.car} Builds.. => ["f03", "f04"] @a = Relation.where(part: "v03") @relations = @a.collect {|x| x.car} Builds.. => ["f01", "f03"] What I want…
San Backups
  • 515
  • 9
  • 17
7
votes
1 answer

how to get all images and photos from my android device not from sdcard?

i would like to get all images/photos/wallpapers from my android device with image saved path. I have implemented code for collect the images from sdcard as follows: String[] mProjection = { MediaStore.Images.Media._ID, …
prasad.gai
  • 2,977
  • 10
  • 58
  • 93
6
votes
2 answers

java IntStream cannot use collect(Collectors.toList()), compilation error, why?

As below: IntStream iStream = IntStream.range(1,4); iStream.forEach(System.out::print); List list1 = iStream.collect(Collectors.toList());//error! Java 1.8 compiler gives type deduction error. Similar code could work for String type: …
Hind Forsum
  • 9,717
  • 13
  • 63
  • 119
6
votes
5 answers

How collect / reduce java 8 stream into pojo?

Look at the code: Collection col = ... MyBuilder builder = new MyBuilder(); for (MyDto dto: col) { switch (dto.getType()) { case FIELD1: builder.field1(dto.getValue()); break: case FIELD2: …
Cherry
  • 31,309
  • 66
  • 224
  • 364
1
2
3
23 24