[query] fix bug in new dict decoder#13939
Conversation
a869537 to
e78c2e2
Compare
|
It still seems like a foot gun that I can’t use two staged code builders at once. Like, if I was implementing a “partition” function that produced two arrays from one, I might naively try to use two staged array builders. Are you saying they’ll actually be the same array builder? |
|
Using multiple staged array builders is fine. It's using a staged array builder in a function (or loop) which is called multiple times that's the issue. Calling The fix here is for the |
|
@patrick-schultz OK, I understand now. Can you ping Ed or find someone else to review? Let's get this in post-haste. |
|
I'm a little puzzled by this solution. I feel that we shouldn't be modifying class composition in method calls; the structure of our code seems somewhat upside down. If anything the StagedArrayBuilder should only take a class builder. |
The decoder uses a
StagedArrayBuilderto hold elements while being sorted. The array builder is stored in a class field. When the same decoder function is called more than once, that array builder is reused.Before this fix, the array builder was never cleared, so if the decoder function was called more than once, the array builder would still contain the elements from previously decoded dicts.
Since it's highly non-obvious that you need to call
clearimmediately afternew StagedCodeBuilder, this PR makes the constructor take a CodeBuilder, and always inserts a clear at the call site. I also took the opportunity to CodeBuilderify the rest of the interface.