Draft: Query V2 serialization support - #140
Conversation
a046cf5 to
63c6328
Compare
|
В текущем варианте есть проблема с совместимостью между новым 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-байндингом |
63c6328 to
22635bc
Compare
Вроде бы как, поправил. |
22635bc to
d885953
Compare
|
|
||
| private final ScheduledFuture<?> writeTaskFuture; | ||
|
|
||
| private volatile int queryFormatVersion = QUERY_FORMAT_V1; |
There was a problem hiding this comment.
Minor: make this field final.
| } | ||
| } | ||
|
|
||
| private void updateQueryFormatVersion(ReindexerResponse response) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Let's add a todo here, to consider supporting mapping of joined items for execSql.
| } | ||
|
|
||
| if (field != null) { | ||
| if (field.getType() == List.class) { |
There was a problem hiding this comment.
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));
}
}
}
No description provided.