It would be nice not to do any heap allocations during serialization. It's a fixed pipeline so it shouldn't be necessary since you know exactly how many streams there will be and how they are configured.

For ret positions you could declare a pair of arrays on the stack, and pass those in as parameters, say size to 16, and then limit to 16. Or you could allocate the memory as part TupleOutputStreamProcessor and return a pointer to that.