Skip to content

[Pulsar SQL] Some optimized points in PR 8422 #9224

Description

@gaoran10

Motivation

The #8422 made a refactor for the Pulsar SQL, it's a major change. There are some points that could be considered to optimize.

1. PulsarRowDecoderFactory

The various decoder factories could be initialized at the Pulsar SQL beginning, one time is enough and they could be reused.

Refer to the method private PulsarRowDecoderFactory createDecoderFactory(SchemaInfo schemaInfo) of the class PulsarDispatchingRowDecoderFactory.

2. PulsarRowDecoderFactory

It seems that the multi-version schema decoder cache could be added and the decoders could be reused.

Refer to the method PulsarRowDecoder createRowDecoder(TopicName topicName, SchemaInfo schemaInfo, Set<DecoderColumnHandle> columns) in class PulsarRowDecoderFactory.

// PulsarRecordCursor.java
PulsarRowDecoder keyDecoder = decoderFactory.createRowDecoder(topicName,
                    schemaInfo,
                    columnHandles.stream()
                            .filter(col -> !col.isInternal())
                            .filter(col -> PulsarColumnHandle.HandleKeyValueType.KEY
                                    .equals(col.getHandleKeyValueType()))
                            .collect(toImmutableSet()));

3. Internal Column decode optimize

The switch-case is more efficient than if-else and the PulsarInternalColumn could be changed to an enum.

// PulsarRecordCursor.java
for (DecoderColumnHandle columnHandle : columnHandles) {
            if (columnHandle.isInternal()) {
                if (PulsarInternalColumn.PARTITION.getName().equals(columnHandle.getName())) {
                    currentRowValuesMap.put(columnHandle, longValueProvider(this.partition));
                } else if (PulsarInternalColumn.EVENT_TIME.getName().equals(columnHandle.getName())) {
                   ...
            }
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/sqlPulsar SQL related featuresgood first issueGood for newcomershelp wantedtype/enhancementThe enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions