-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-28767 Use Message DTO to transfer QueryEntity #13236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shishkovilja
wants to merge
6
commits into
apache:master
Choose a base branch
from
shishkovilja:ignite-28767
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+476
−68
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a69b45f
IGNITE-28767 Use Message DTO to transfer QueryEntity
shishkovilja 5a07fec
IGNITE-28767 Add test to serde round trip.
shishkovilja e091d45
Merge branch 'master' into ignite-28767
shishkovilja 4ec680f
Merge branch 'master' into ignite-28767
shishkovilja 4db6e21
Code review fixes.
shishkovilja fa30363
Code-review fixes.
shishkovilja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityExMessage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * 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(entityBase()); | ||
|
|
||
| qryEntity.setNotNullFields(notNullFields); | ||
| qryEntity.setPreserveKeysOrder(preserveKeysOrder); | ||
| qryEntity.implicitPk(implicitPk); | ||
| qryEntity.fillAbsentPKsWithDefaults(fillAbsentPKsWithDefaults); | ||
| qryEntity.sql(sql); | ||
|
|
||
| if (pkInlineSize != -1) | ||
| qryEntity.setPrimaryKeyInlineSize(pkInlineSize); | ||
|
|
||
| if (affKeyInlineSize != -1) | ||
| qryEntity.setAffinityKeyInlineSize(affKeyInlineSize); | ||
|
|
||
| return qryEntity; | ||
| } | ||
| } |
158 changes: 158 additions & 0 deletions
158
...n/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityMessage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| /* | ||
| * 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 { | ||
|
shishkovilja marked this conversation as resolved.
|
||
| /** Key type. */ | ||
| @Order(0) | ||
| String keyType; | ||
|
|
||
| /** Value type. */ | ||
| @Order(1) | ||
| String valType; | ||
|
|
||
| /** Key name. */ | ||
| @Order(2) | ||
| String keyFieldName; | ||
|
|
||
| /** Value name. */ | ||
| @Order(3) | ||
| String valFieldName; | ||
|
|
||
| /** Fields available for query. */ | ||
| @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: Used in serde of both QueryEntity and QueryEntityEx in order to avoid duplication. | ||
| */ | ||
| @Order(9) | ||
| Set<String> notNullFields; | ||
|
|
||
| /** Fields default values. */ | ||
| Map<String, Object> dfltFieldValues; | ||
|
|
||
| /** Serialized form of {@link #dfltFieldValues}. */ | ||
| @Order(10) | ||
| byte[] dfltFieldValuesBytes; | ||
|
|
||
| /** Precision(Maximum length) for fields. */ | ||
| @Order(11) | ||
| Map<String, Integer> fieldsPrecision; | ||
|
|
||
| /** Scale for fields. */ | ||
| @Order(12) | ||
| Map<String, Integer> fieldsScale; | ||
|
|
||
| /** */ | ||
| public QueryEntityMessage() { } | ||
|
|
||
| /** @param qryEntity Original {@link QueryEntity}. */ | ||
| public QueryEntityMessage(QueryEntity qryEntity) { | ||
|
shishkovilja marked this conversation as resolved.
|
||
| keyType = qryEntity.getKeyType(); | ||
| valType = qryEntity.getValueType(); | ||
|
|
||
| keyFieldName = qryEntity.getKeyFieldName(); | ||
| valFieldName = qryEntity.getValueFieldName(); | ||
|
|
||
| fields = qryEntity.getFields(); | ||
| aliases = qryEntity.getAliases(); | ||
|
|
||
| if (!F.isEmpty(qryEntity.getKeyFields())) | ||
| keyFields = qryEntity.getKeyFields().toArray(U.EMPTY_STRS); | ||
|
|
||
| if (!F.isEmpty(qryEntity.getIndexes())) | ||
| idxs = F.viewReadOnly(qryEntity.getIndexes(), QueryIndexMessage::new); | ||
|
anton-vinogradov marked this conversation as resolved.
|
||
|
|
||
| tableName = qryEntity.getTableName(); | ||
|
|
||
| notNullFields = qryEntity.getNotNullFields(); | ||
| dfltFieldValues = qryEntity.getDefaultFieldValues(); | ||
| fieldsPrecision = qryEntity.getFieldsPrecision(); | ||
| fieldsScale = qryEntity.getFieldsScale(); | ||
| } | ||
|
|
||
| /** @return Original {@link QueryEntity}. */ | ||
| public QueryEntity toEntity() { | ||
| return entityBase().setNotNullFields(notNullFields); | ||
| } | ||
|
|
||
| /** @return Entity without 'notNullFields.' */ | ||
| protected QueryEntity entityBase() { | ||
| return new QueryEntity() | ||
| .setKeyType(keyType) | ||
| .setValueType(valType) | ||
| .setKeyFieldName(keyFieldName) | ||
| .setValueFieldName(valFieldName) | ||
| .setFields(fields) | ||
| .setKeyFields(!F.isEmpty(keyFields) ? new LinkedHashSet<>(List.of(keyFields)) : null) | ||
|
shishkovilja marked this conversation as resolved.
|
||
| .setAliases(aliases) | ||
| .setIndexes(!F.isEmpty(idxs) ? F.transform(idxs, QueryIndexMessage::queryIndex) : null) | ||
| .setTableName(tableName) | ||
| .setDefaultFieldValues(dfltFieldValues) | ||
| .setFieldsPrecision(fieldsPrecision) | ||
| .setFieldsScale(fieldsScale); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException { | ||
| if (!F.isEmpty(dfltFieldValues)) | ||
| dfltFieldValuesBytes = U.marshal(marsh, dfltFieldValues); | ||
|
shishkovilja marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException { | ||
| if (!F.isEmpty(dfltFieldValuesBytes)) | ||
| dfltFieldValues = U.unmarshal(marsh, dfltFieldValuesBytes, clsLdr); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.