Questions tagged [stream]

11180 questions
0

votes
2

answer
50

Views

Can we improve performance on lists other than java 8 parallel streams

I have to dump data from somewhere by calling rest API which returns List. First i have to get some List object from one rest api. Now used parallel stream and gone through each item with forEach. Now on for each element i have to call some other api to get the data which returns again list and save...
Pavan
0

votes
1

answer
11

Views

How does Spring Kafka/Spring Cloud Stream guarantee the transactionality / atomicity involving a Database and Kafka?

Spring Kafka, and thus Spring Cloud Stream, allow us to create transactional Producers and Processors. We can see that functionality in action in one of the sample projects: https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/transaction-kafka-samples: @Transactional @StreamListe...
codependent
1

votes
1

answer
2k

Views

Converting Map<String,String> to List<Object> in Java8 [duplicate]

This question already has an answer here: Java 8 stream Map to List 1 answer I have API which returns Map which needs convert into DTO. SubjectIdAndNameDTO (id, name constructor args) id name current implementation using traditional for loop and Map.EnterSet. How can i use feature of Java8 to simp...
Lakshman Miani
1

votes
1

answer
77

Views

Dart What does “StreamTransformer<RS, RT> cast<RS, RT>()” do?

I've implemented the stream transformer. Please note that it is only an exercise (in order to learn Dart). This transformer converts integers into strings. I give the code below, and you can also find it on GitHub. // Conceptually, a transformer is simply a function from Stream to Stream that // is...
Denis Beurive
1

votes
2

answer
109

Views

Azure Stream Analytics query to detect missing alive event for a specific deviceId

I do not see a way to analyse a stream for the absence of a specific event with azure stream analytics query language. The stream may contain DeviceAlive and BeaconDetected events containing a DeviceId and in case of BeaconDetected also a BeaconId. Now I want to generate an error event if the Device...
Micha
1

votes
1

answer
74

Views

Can redis key space notifications be pushed to the redis stream instead of pub/sub channel

We have a requirement that we need to get a notification on changes to a Redis data structure. Based on my research I found out that I can use Redis key space notifications for doing the same. However, Redis key space notifications send the events to Redis pub/sub channel which is fire and forget i....
Rishabh
1

votes
1

answer
196

Views

Spring Cloud Stream @SendTo Annotation not working

I'm using Spring Cloud Stream with Spring Boot. My application is very simple: ExampleService.class: @EnableBinding(Processor1.class) @Service public class ExampleService { @StreamListener(Processor1.INPUT) @SendTo(Processor1.OUTPUT) public String dequeue(String message){ System.out.println('New mes...
italktothewind
1

votes
1

answer
35

Views

IntelliJ hint while rounding BigDecimal division stream result

I have a little bit strange problem with IntelliJ hint while dividing result at the end of stream operation. products.stream() .filter( order -> order.getEstimatedRealizationDate().compareTo(begin) > 0 && order.getEstimatedRealizationDate().compareTo(end) < 0) .map(order -> order.getProduct().getP...
Martin
1

votes
3

answer
49

Views

Flatten a nested N-Level nested object in java

I have a java class class Example{ String field1; String field2; List subExamples; } In the above scenario, Example is having subExamples which is again a list of Examples. This nesting can be n-levels. What I want to achieve is to have a list of Examples, i.e to flatten the above object and col...
codeluv
1

votes
2

answer
74

Views

Java 8 expression fill list from list with another list inside

I'm trying to reach a lambda expression avoiding doing this: for (OrderEntity o: onEntryL) { for(GeoFenceEventEntity g: o.getGeoFenceEvent()){ if(null != g.getEndAt() && g.getDynamoGeofenceType().equalsIgnoreCase('WAREHOUSE')){ //all of them, get data } } } And on Lambda trying something like this (...
Elí Giacomelli
1

votes
3

answer
111

Views

How to convert the following code to Java 8 streams and lambdas

I have a complicated requirement where a list records has comments in it. We have a functionality of reporting where each and every change should be logged and reported. Hence as per our design, we create a whole new record even if a single field has been updated. Now we wanted to get history of co...
diwakarb
1

votes
3

answer
54

Views

Java 8 grouping function to return Map<String, Integer> instead of Map<String,Long>

I am using the below mentioned code to find number of Times each word as occurred in a String. Map map = Arrays.asList(text.split('\\s+')).stream().collect(Collectors.groupingBy(Function.identity(),LinkedHashMap::new,Collectors.counting())) this code returns Map I want to transform this code to retu...
Lucie
1

votes
2

answer
62

Views

OCaml Marshal very large data structure

I would like to send a very large (~8GB) datastructure through the network, so I use the Marshal module to transform it into Bytes. My problem is that the memory doubles, because we need to store both representations (initial data and Marshaled data). Is there a simple way to Marshal into a Stream i...
Anthony Scemama
1

votes
1

answer
32

Views

Extract a fields data from a Map<Integer, Object> into a String

I have an Customer Object like below. public class Custoemr { private String Id; Private String Name; Private String Address; Private String Description; Setter/Getter; toString; } This is Contained in Map map, which contains the customerId and Object as key and value respectively. For analysis purp...
Lucie
1

votes
1

answer
90

Views

Proving properties of stream functions in Idris

I'm trying to prove properties about stream functions and Monadic Stream Functions [1] (and ultimately, FRP programs). Idris is happy with my formalization of stream functions: module SF import Data.Vect import Syntax.PreorderReasoning %default total data SF : Type -> Type -> Type where SFG : (a ->...
Ivan Perez
1

votes
1

answer
40

Views

Java Stream grouping and counting occuerences

I have a list of objects representing trades in a market. Each trade has an opening and closing time and a profit. I want to group them by a month and then count a number of trades with profit > 0 and < 0 in each month = create a Map with following structure {'MM' = {'Win' = numberOfWinTrades, 'Loss...
Spasitel
1

votes
2

answer
111

Views

Fibonacci using Stream And BinaryOperator in Java

I'm student and I learning functional Java 8. I got project to do and I don't understand how this function interface work. My teacher told me 'you should know that' and I'm looking for help to understand this problem. It should count Fibonacci series I got this code StreamUtils.generateRest(Stream.o...
anik
1

votes
2

answer
44

Views

Stream IllegalStateException

I am facing this error and have no idea how to debug it. The summary of the question is that I have to get the minimum and maximum of a stream. I cannot use Collections and the stream must be parallelizable. Furthermore, the stream is an argument so it cannot be duplicated. I am not asking for a sol...
Jayson
1

votes
2

answer
21

Views

Is it possible to combine a ZipOutputStream and a DigestOutputstream?

I need to determine the checksum of a .zip file before uploading it somewhere, so that file integrity may be assured. Currently, I have something like the following: for (File file : zipCandidates) { InputStream fileInputStream = new BufferedInputStream(new FileInputStream(file)); ZipUtils.addDataTo...
user991710
1

votes
1

answer
64

Views

Linux much faster than Windows when reading data from .txt file and placing into vector. How would I speed up Windows to do the same?

I have .txt files for data (100MB - 700MB). When reading these files and placing them into vectors, Linux does this 20-30x faster. Is this a system issue, or is there something I can do to speed up Windows? I've ran the same code hundreds of times on each system. Both systems have a 64bit compiler...
Lumbeezl
0

votes
0

answer
4

Views

How to get the values of a mergeWith stream using RxDart?

I have many streams that I would like to combine into one stream. I'm trying to use mergeWith and it seems to be working but I'm not exactly sure how to get the values of the returned Observable. I used combineLatest but that waits for everything to have a value and sometimes not all values are need...
LongTSQLFiles
1

votes
2

answer
998

Views

Spring-MVC : How to stream mp3 file from controller

I am working on a Spring-MVC application in which I am trying to stream mp3 data. Unfortunately, it's directly triggering a download whenever a byte-array of information is sent in response. I found a few other links, but most of them are tied to an user-interface, so not much useful. What are the...
We are Borg
1

votes
2

answer
502

Views

TextField with initial value inside StreamBuilder

We are creating an user's editing data page, so the textfield already comes filled with the user data and users can change and save it... The problem is that when I start to enter character into textfield, the cursor get lost, every character that I enter (from the device keyboard), the cursor goes...
Vinicius Sossella
1

votes
1

answer
328

Views

Get String value if present or null if not present using Java8 Stream

I have a json similar like as shown below. The requirement is to get the key value based on the id. ie. lets say If Id is A1 key value should return 2gAwIBAgIQKGZsKfAUzaJHVantyrwVdzANBgkqhkiG9w0BAQs. The key array will always conatins only one element. { 'keys': [ { 'id': 'A1', 'key': [ '2gAwIBAgIQ...
Alex Man
1

votes
3

answer
80

Views

How to place duplicate elements from a list into an array?

I need to find duplicate items in the collection and put them in an array. I wrote this method: String[] mass = new String[(int) limit]; for (int i = 0; i < duplicates.size(); i++){ for (int j = 1; j < duplicates.size(); j++){ if (i != j && duplicates.get(i).equalsIgnoreCase(duplicates.get(j))){ mas...
Mefisto_Fell
1

votes
2

answer
64

Views

Iterating LinkedList using streams is altering result list due to RaceCondtion

We are iterating the LinkedList using Streams in java8, and creating another list. But due the race condition the result List size got alatered. List InfoList = new LinkedList(); documentList.stream() .parallel() .forEach(document -> { Info descriptiveInfo = objectFactory.createDescriptiveInfo(); Li...
Raghavan
1

votes
2

answer
23

Views

How to use fscanf here to write into variable from file?

I'm trying to read a file 'data.txt' with a single line '00:612:33188' (each number represents a field of data, 'changes:size:permission'), and write that information into a struct. I want to write the code in general for any number of characters in those fields. My question is regarding the use of...
Alberto
1

votes
4

answer
98

Views

group by a field in Java Streams

So, I have an input JSON that looks like this: [{ 'added': '2014-02-01T09:13:00Z', 'author': { 'id': '1', 'name': 'George R R Martin', 'added_on': '2013-02-01T09:13:00Z' }, 'book': { 'id': '12', 'name': 'Game of Thrones', 'genre': 'Fantasy Fiction' } }, { 'added': '2015-02-01T09:13:00Z', 'author':...
nirvair
1

votes
2

answer
99

Views

Java Optional: flatmap and orElseGet [duplicate]

This question already has an answer here: Get value from one Optional or another 4 answers Optional orElse Optional in Java 6 answers I've coded that: Optional.ofNullable(this.cache.get(id)) .orElseGet(this.referenceService.get(id)); The problem is that this.referenceService.get returns an Optiona...
Jordi
1

votes
1

answer
56

Views

Java 8 nested list as singleton list in parent

public class Parent { String name; List children; } public class Child { String childName; } I have these 2 classes by which my data set becomes as below: List parents = new ArrayList(); List _child1 = new ArrayList(); _child1.add(new B('p1c1')); _child1.add(new B('p1c2')); _child1.add(new B('p1c3')...
gaurav arora
1

votes
1

answer
65

Views

Difference between Stream Analytics and Time Series Insights

In the context of Azure IoT hub, when would one use Stream Analytics over Time Series Insights? The product pages and documentation for both indicates they are heavily geared for IoT/data applications. However, I'm not clear on the differences. The use case I have is both real time monitoring as wel...
user9993
1

votes
3

answer
55

Views

Convert List<HashMap<String, Object>> to stream

I have a list of this type List ResultSet that contains the result of a query to a database. I wanted call stream() on the List object. How do I do that ? This code create my list: public class ResultSetToMap { int Columns = 0; List data = new ArrayList(); HashMap row = new HashMap(); public List R...
programmer
1

votes
1

answer
227

Views

Inclusive takeWhile() for Streams

I want to know if there is a way to add the last element of the stream that was tested against the condition of the method takeWhile(). I believe I want to achieve something similar to RxJava's takeUntil() method. I'm guessing there is no direct way to do this (correct me if I am mistaken), but I wo...
HiGuys
1

votes
2

answer
284

Views

Cannot resolve method stream() issue

I am currently learning about streams in java, but when i try to write some simple code like this Map map = new TreeMap(); map.put('Tom', 5); map.put('Andrew', 6); map.put('Kim', 3); map.put('Milo', 2); map.stream(); it gives me java cannot resolve method stream() I am using Inttelij and coding in...
sadurator
1

votes
2

answer
56

Views

Akka: is there a Sink that never pulls?

Need a Sink that never pulls, to use in unit tests. Is there one already available or do I need to code it myself? Please note that Sink.ignore() won't help, because it ALWAYS pulls. I need a Sink that NEVER pulls.
Michael M.
0

votes
1

answer
20

Views

Does Stream#findFirst() (or findAny) shortcircuit a flatmapped stream?

Java 8 Stream#findFirst() is a short-circuiting terminal operation. Meaning it will stop generating the stream once an element is found (usually used with a filter() operation). However, I want to know if it will short circuit on a stream created by flatmap. I.e. will it short circuit the streams c...
wilmol
1

votes
1

answer
393

Views

ffmpeg convert stream to jpg buffer without saving do disk

I have a webrtc video stream coming from the client to the server. I want to convert the stream into jpg images, but not save any image to disk (work from memory only). Currently I'm using this command line function (called from node js): var ops = [ '-i', '-', '-f', 'image2', '-vcodec', 'mjpeg', '-...
scanner
1

votes
0

answer
84

Views

Spring default error handler tries to write error html to output stream used by spring to return file content

Hi I have the following problem I have a Controller that is used to download a file public ResponseEntity downloadFile(String path) { FileContentInformation fileContent = getInputContentFromSomewhere(); //Content-Type, Content-Length, Content-Disposition, etc. final HttpHeaders responseHeaders = cr...
maczikasz
1

votes
1

answer
147

Views

How Racket streams work in this case?

I am currently learning Racket (just for fun) and I stumbled upon this example: (define doubles (stream-cons 1 (stream-map (lambda (x) (begin (display 'map applied to: ') (display x) (newline) (* x 2))) doubles))) It produces 1 2 4 8 16 ... I do not quite understand how it works. So it creates 1 a...
Stefan Dorn

View additional questions