TsReaper opened a new pull request #12996:
URL: https://github.com/apache/flink/pull/12996
## What is the purpose of the change
If too many fields of the same type are projected,
`ProjectionCodeGenerator#generateProjectionExpression` currently performs a
"for loop optimization" which, instead of generating code separately for each
field, they'll be squashed into a for loop.
However, if the indices of the fields with the same type are not continuous,
this optimization will not write fields in index ascending order. This is not
acceptable because BinaryWriter expects the users to write fields in index
ascending order (that is to say, we have to first write field 0, then field 1,
then...), otherwise the variable length area of the two binary rows with same
data might be different. Although we can use getXX methods of BinaryRow to get
the fields correctly, states for streaming jobs compare state keys with binary
bits, not with the contents of the keys. So we need to make sure the binary
bits of the binary rows be the same if two rows contain the same data.
What's worse, as the current implementation of
ProjectionCodeGenerator#generateProjectionExpression uses a scala HashMap, the
key order of the map might be different on different workers; Even if the
projection does not meet the condition to be optimized, it will still be
affected by this bug.
This PR simply removes this optimization. Because if we still want this
optimization, we have to make sure that the fields of the same type have
continuous order, which is a very strict and rare condition.
## Brief change log
- Remove for loop optimization in `ProjectionCodeGenerator`.
## Verifying this change
This change added tests and can be verified by running the newly added unit
tests.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]