[ 
https://issues.apache.org/jira/browse/FLINK-41241?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ramin Gharib reassigned FLINK-41241:
------------------------------------

    Assignee: Ramin Gharib

> Remember the field index in VARIANT key lookups
> -----------------------------------------------
>
>                 Key: FLINK-41241
>                 URL: https://issues.apache.org/jira/browse/FLINK-41241
>             Project: Flink
>          Issue Type: Improvement
>          Components: API / Core, Table SQL / Planner
>            Reporter: Ramin Gharib
>            Assignee: Ramin Gharib
>            Priority: Major
>             Fix For: 2.5.0
>
>
> VARIANT field access by a literal key, and the cast from VARIANT to ROW, look 
> up each object field by name on every row: encode the key to UTF-8, then 
> search the field list. Objects of one stream mostly share their keys, so the 
> field is usually at the same index as in the previous row.
> {code:sql}
> SELECT v['user'], v['ts'], v['kind'], v['z'] FROM events
> {code}
> Add an internal VariantFieldGetter that encodes its key once and checks the 
> index where it found the key in the previous row before it searches. The 
> index is a hint that is always verified, so a getter can be shared between 
> threads. The generated code keeps one getter per field access with a literal 
> key, and the cast to ROW and STRUCTURED keeps one per field.
> JMH, JDK 17. Per row means the 4 lookups of the query above:
> ||Stream of objects||Today, per row||With getters, per row||
> |Same 13 keys in every row|214 ns|44 ns|
> |Same 40 keys in every row|158 ns|44 ns|
> |14 to 20 keys, so the looked-up key moves in most rows|296 ns|242 ns|



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to