George
06/01/2022, 3:35 PMoverride fun encode(
inputStream: Publisher<out Any>,
bufferFactory: DataBufferFactory,
elementType: ResolvableType,
mimeType: MimeType?,
hints: MutableMap<String, Any>?
): Flux<DataBuffer> {
1) return Flux.from(inputStream).map { bufferFactory.wrap(protobufSerializer.encodeToByteArray(elementType)) }
vs
2) return inputStream
.asFlow()
.map { bufferFactory.wrap(protobufSerializer.encodeToByteArray(elementType)) }
.asFlux()
}
Is it worth it to keep the transformation asFlow -> map -> and then return again the Flux ?Joffrey
06/01/2022, 4:00 PMmap
makes a differenceJoffrey
06/01/2022, 4:01 PMInputStream.asFlow()
?George
06/02/2022, 7:17 AMpublic fun <T : Any> Publisher<T>.asFlow(): Flow<T> =
PublisherAsFlow(this)
The inputStream is a type of Publisher<out Any>.
Lets pretend that the map is not inlined in our case, it doesnt make any difference to use the actual implementation of the flow instead of flux? (Since from my understanding the have different implementation details.) If not, if it's possible can u point me to a reference or doc so i can deep dive on it ? Thanks in advance.