is it worth calling the asSequence funtion like th...
# announcements
h
is it worth calling the asSequence funtion like this
kinesisEvent.records.asSequence()
before calling foreach in this example:
Copy code
// event: List<KinesisEvent.KinesisEventRecord>

 event.records.forEach {
            try {
                val putRecordsRequest = PutRecordsRequest()
                putRecordsRequest.streamName = "test-stream" 
                val putRecordsRequestEntryList = ArrayList<PutRecordsRequestEntry>()
                for (i in 0..499) {
                    val putRecordsRequestEntry = PutRecordsRequestEntry()
                    putRecordsRequestEntry.data = it.kinesis.data
                    putRecordsRequestEntry.partitionKey = it.kinesis.partitionKey
                    putRecordsRequestEntryList.add(putRecordsRequestEntry)
                }
                putRecordsRequest.setRecords(putRecordsRequestEntryList)
                val putRecordsResult = kinesisClient.putRecords(putRecordsRequest)

            } catch (e: InterruptedException) {
                //log error here
            }
s
No. I don't think so since foreach is just getting an Iterator and calling next() so no transform like when mapping etc..
👍 2
a
Afaik asSequence will only be beneficial when doing multiple processing steps in between
m
Or dealing with an infinite stream.