anton-vinogradov commented on code in PR #13236: URL: https://github.com/apache/ignite/pull/13236#discussion_r3476109573
########## modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityExMessage.java: ########## @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.query.schema.message; + +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.query.QueryEntityEx; + +/** + * Message for {@link QueryEntityEx} transfer. + */ +public class QueryEntityExMessage extends QueryEntityMessage { + /** Whether to preserve order specified by 'keyFields' or not. */ + @Order(0) + boolean preserveKeysOrder; + + /** Whether a primary key should be autocreated or not. */ + @Order(1) + boolean implicitPk; + + /** Whether absent PK parts should be filled with defaults or not. */ + @Order(2) + boolean fillAbsentPKsWithDefaults; + + /** INLINE_SIZE for PK index. */ + @Order(3) + int pkInlineSize; + + /** INLINE_SIZE for affinity field index. */ + @Order(4) + int affKeyInlineSize; + + /** Whether query entity was created by SQL. */ + @Order(5) + boolean sql; + + /** */ + public QueryEntityExMessage() { } + + /** + * @param qryEntity Original {@link QueryEntity}. + */ + public QueryEntityExMessage(QueryEntityEx qryEntity) { + super(qryEntity); + + preserveKeysOrder = qryEntity.isPreserveKeysOrder(); + implicitPk = qryEntity.implicitPk(); + fillAbsentPKsWithDefaults = qryEntity.fillAbsentPKsWithDefaults(); + + pkInlineSize = qryEntity.getPrimaryKeyInlineSize() != null ? qryEntity.getPrimaryKeyInlineSize() : -1; + + affKeyInlineSize = qryEntity.getAffinityKeyInlineSize() != null ? qryEntity.getAffinityKeyInlineSize() : -1; + + sql = qryEntity.sql(); + } + + /** {@inheritDoc} */ + @Override public QueryEntity toEntity() { + QueryEntityEx qryEntity = new QueryEntityEx(super.toEntity()); + + qryEntity.setNotNullFields(notNullFields); Review Comment: Concrete fix for the `_notNullFields` round-trip asymmetry I flagged. `QueryEntityEx` keeps `notNullFields` in its own field and leaves the inherited `QueryEntity._notNullFields` as a null shadow. `super.toEntity()` populates that base shadow, so a deserialized Ex ends up with `base._notNullFields == ex.notNullFields`, while a normally-built one has `base._notNullFields == null` — hence the two aren't `.equals()`. Nulling the base copy makes a deserialized entity structurally identical to a freshly-built one. Verified: with this change a round-trip test on a naturally-built `QueryEntityEx` (notNullFields set only via the Ex setter) passes `assertEquals(orig, roundTripped)`; without it, it fails. ```suggestion QueryEntity base = super.toEntity(); // QueryEntityEx keeps notNullFields in its own field; null the shadowed base copy so a // deserialized entity equals a normally-built one (where base _notNullFields is null). base.setNotNullFields(null); QueryEntityEx qryEntity = new QueryEntityEx(base); qryEntity.setNotNullFields(notNullFields); ``` ########## modules/core/src/main/java/org/apache/ignite/internal/CoreMessagesProvider.java: ########## @@ -636,7 +640,7 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C withNoSchema(UserAuthenticateRequestMessage.class); withNoSchema(UserAuthenticateResponseMessage.class); withNoSchema(TcpDiscoveryAuthFailedMessage.class); - withSchema(AuthentificationDataBagItem.class); + withNoSchema(AuthentificationDataBagItem.class); Review Comment: This `withSchema`→`withNoSchema` change is unrelated to QueryEntity (it's auth/users) and is a no-op anyway — `AuthentificationDataBagItem` is a plain `Message`, so its registered marshaller is never used. Suggest reverting it to keep the PR focused (if the flip is intentional cleanup, a separate commit would be clearer). ```suggestion withSchema(AuthentificationDataBagItem.class); ``` ########## modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityMessage.java: ########## @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.query.schema.message; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.internal.MarshallableMessage; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.cache.query.QueryIndexMessage; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.Marshaller; + +/** + * Message for {@link QueryEntity} transfer. + */ +public class QueryEntityMessage implements MarshallableMessage { + /** Key type. */ + @Order(0) + String keyType; + + /** Value type. */ + @Order(1) + String valType; + + /** Key name. Can be used in field list to denote the key as a whole. */ + @Order(2) + String keyFieldName; + + /** Value name. Can be used in field list to denote the entire value. */ + @Order(3) + String valFieldName; + + /** Fields available for query. A map from field name to type name. */ + @Order(4) + LinkedHashMap<String, String> fields; + + /** Set of field names that belong to the key. */ + @Order(5) + String[] keyFields; + + /** Aliases. */ + @Order(6) + Map<String, String> aliases; + + /** Collection of query indexes. */ + @Order(7) + Collection<QueryIndexMessage> idxs; + + /** Table name. */ + @Order(8) + String tableName; + + /** Fields that must have non-null value. NB: DO NOT remove underscore to avoid clashes with QueryEntityEx. */ Review Comment: Nit: this comment was copied from `QueryEntity` (where the field is `_notNullFields`); here the field is `notNullFields` and `QueryEntityExMessage` doesn't redeclare it, so the "DO NOT remove underscore" note no longer applies. ```suggestion /** Fields that must have non-null value. */ ``` -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
