Skip to content

Draft: Query V2 serialization support - #140

Open
slowcheetahzzz wants to merge 1 commit into
masterfrom
nested_joins_compatibility
Open

Draft: Query V2 serialization support#140
slowcheetahzzz wants to merge 1 commit into
masterfrom
nested_joins_compatibility

Conversation

@slowcheetahzzz

Copy link
Copy Markdown
Collaborator

No description provided.

@slowcheetahzzz slowcheetahzzz changed the title Query V2 serialization support Draft: Query V2 serialization support Jul 15, 2026
@MadSchemas MadSchemas changed the title Draft: Query V2 serialization support Draft: Query V2 serialization support #141 Jul 21, 2026
@MadSchemas MadSchemas changed the title Draft: Query V2 serialization support #141 Draft: Query V2 serialization support Jul 21, 2026
Comment thread src/main/java/ru/rt/restream/reindexer/Query.java Outdated
@MadSchemas

Copy link
Copy Markdown
Contributor

В текущем варианте есть проблема с совместимостью между новым java-клиентом и старым сервером. Вот здесь https://github.com/Restream/reindexer-java/blob/nested_joins_compatibility/src/main/java/ru/rt/restream/reindexer/binding/cproto/PhysicalConnection.java#L487 у java-клиента сейчас строгая проверка (в отличие от Go/C++ нет min compatible version). Из-за этого, когда старый сервер пришлёт пакет с другой версией cproto (у него там будет 0x104), клиент дропнет коннект.

Нужно добавить логику с min compatible version по аналогии с Go-байндингом

@slowcheetahzzz
slowcheetahzzz force-pushed the nested_joins_compatibility branch from 63c6328 to 22635bc Compare August 6, 2026 10:40
@slowcheetahzzz

Copy link
Copy Markdown
Collaborator Author

В текущем варианте есть проблема с совместимостью между новым java-клиентом и старым сервером. Вот здесь https://github.com/Restream/reindexer-java/blob/nested_joins_compatibility/src/main/java/ru/rt/restream/reindexer/binding/cproto/PhysicalConnection.java#L487 у java-клиента сейчас строгая проверка (в отличие от Go/C++ нет min compatible version). Из-за этого, когда старый сервер пришлёт пакет с другой версией cproto (у него там будет 0x104), клиент дропнет коннект.

Нужно добавить логику с min compatible version по аналогии с Go-байндингом

Вроде бы как, поправил.

Comment thread src/main/java/ru/rt/restream/reindexer/QueryResultIterator.java
@slowcheetahzzz
slowcheetahzzz force-pushed the nested_joins_compatibility branch from 22635bc to d885953 Compare August 11, 2026 15:00

private final ScheduledFuture<?> writeTaskFuture;

private volatile int queryFormatVersion = QUERY_FORMAT_V1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: make this field final.

}
}

private void updateQueryFormatVersion(ReindexerResponse response) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: make this method return a version as an int to assign to the queryFormatVersion in the constructor.

readSubItems(nsIndexOffset, subItemsMap, nsIndex);
for (int joinedField = 0; joinedField < joinedFields; joinedField++) {
int itemsCount = (int) buffer.getVarUInt();
if (queryContext == null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a todo here, to consider supporting mapping of joined items for execSql.

}

if (field != null) {
if (field.getType() == List.class) {

@evgeniycheban evgeniycheban Aug 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's consider supporting also Collection and arrays for joined results, this aligns with how we treat fields of such types for regular fields:

        if (field != null) {
            ResolvableType resolvableType = ConversionUtils.resolveFieldType(field);
            if (resolvableType.isCollectionLike()) {
                if (resolvableType.getType().isArray()) {
                    Object array = Array.newInstance(resolvableType.getComponentType(), subItems.size());
                    for (int i = 0; i < subItems.size(); i++) {
                        Array.set(array, i, subItems.get(i));
                    }
                    BeanPropertyUtils.setProperty(item, fieldName, array);
                } else {
                    Collection<Object> collection = CollectionUtils
                            .createCollection(resolvableType.getType(), resolvableType.getComponentType(), subItems.size());
                    collection.addAll(subItems);
                    BeanPropertyUtils.setProperty(item, fieldName, collection);
                }
            } else {
                if (subItems.size() > 1) {
                    throw new RuntimeException("Multiple join result found: " + fieldName);
                } else if (subItems.size() == 0) {
                    BeanPropertyUtils.setProperty(item, fieldName, null);
                } else {
                    BeanPropertyUtils.setProperty(item, fieldName, subItems.get(0));
                }
            }
        }

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Поддержать формат сериализации QueryV2/QueryResultsV2

3 participants