You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "alex-plekhanov (via GitHub)" <gi...@apache.org> on 2024/11/11 17:25:19 UTC
[PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
alex-plekhanov opened a new pull request, #11651:
URL: https://github.com/apache/ignite/pull/11651
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
### The Contribution Checklist
- [ ] There is a single JIRA ticket related to the pull request.
- [ ] The web-link to the pull request is attached to the JIRA ticket.
- [ ] The JIRA ticket has the _Patch Available_ state.
- [ ] The pull request body describes changes that have been made.
The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
- [ ] The pull request title is treated as the final commit message.
The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
- [ ] A reviewer has been mentioned through the JIRA comments
(see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
- [ ] The pull request has been checked by the Teamcity Bot and
the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
### Notes
- [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
- [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
- [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
- [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #11651:
URL: https://github.com/apache/ignite/pull/11651#issuecomment-2468705346
## [](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=11651) **Quality Gate failed**
Failed conditions
 [18 New Code Smells](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=11651) (required ≤ 1)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=11651)
##
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
Posted by "alex-plekhanov (via GitHub)" <gi...@apache.org>.
alex-plekhanov commented on code in PR #11651:
URL: https://github.com/apache/ignite/pull/11651#discussion_r1860806641
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/IndexCountScan.java:
##########
@@ -0,0 +1,198 @@
+/*
+ * 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.calcite.exec;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRow;
+import org.apache.ignite.internal.cache.query.index.sorted.InlineIndexRowHandler;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndex;
+import org.apache.ignite.internal.cache.query.index.sorted.keys.NullIndexKey;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
+import org.apache.ignite.internal.processors.cache.transactions.TransactionChanges;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
+import org.apache.ignite.spi.indexing.IndexingQueryFilterImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** */
+public class IndexCountScan<Row> extends AbstractCacheScan<Row> {
+ /** */
+ private final InlineIndex idx;
+
+ /** */
+ private final RelCollation collation;
+
+ /** */
+ private final boolean notNull;
+
+ /** */
+ public IndexCountScan(
+ ExecutionContext<Row> ectx,
+ GridCacheContext<?, ?> cctx,
+ int[] parts,
+ InlineIndex idx,
+ RelCollation collation,
+ boolean notNull
+ ) {
+ super(ectx, cctx, parts);
+
+ this.idx = idx;
+ this.collation = collation;
+ this.notNull = notNull;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Iterator<Row> createIterator() {
+ boolean[] skipCheck = new boolean[] {false};
+
+ BPlusTree.TreeRowClosure<IndexRow, IndexRow> rowFilter = countRowFilter(skipCheck, notNull, idx);
+
+ long cnt = 0;
+
+ if (!F.isEmpty(ectx.getQryTxEntries())) {
+ TransactionChanges<CacheDataRow> txChanges = ectx.transactionChanges(
+ cctx.cacheId(),
+ parts,
+ Function.identity(),
+ null
+ );
+
+ if (!txChanges.changedKeysEmpty()) {
+ rowFilter = transactionAwareCountRowFilter(rowFilter, txChanges);
+
+ cnt = countTransactionRows(notNull, idx, txChanges.newAndUpdatedEntries());
+ }
+ }
+
+ try {
+ IndexingQueryFilter filter = new IndexingQueryFilterImpl(cctx.kernalContext(), topVer, parts);
+
+ for (int i = 0; i < idx.segmentsCount(); ++i) {
+ cnt += idx.count(i, new IndexQueryContext(filter, rowFilter));
+
+ skipCheck[0] = false;
+ }
+
+ return Collections.singletonList(ectx.rowHandler().factory(long.class).create(cnt)).iterator();
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Unable to count index records.", e);
+ }
+ }
+
+ /** */
+ private @Nullable BPlusTree.TreeRowClosure<IndexRow, IndexRow> countRowFilter(boolean[] skipCheck, boolean notNull, InlineIndex iidx) {
+ boolean checkExpired = !cctx.config().isEagerTtl();
+
+ if (notNull) {
+ boolean nullsFirst = collation.getFieldCollations().get(0).nullDirection == RelFieldCollation.NullDirection.FIRST;
+
+ BPlusTree.TreeRowClosure<IndexRow, IndexRow> notNullRowFilter = IndexScan.createNotNullRowFilter(iidx, checkExpired);
+
+ return new BPlusTree.TreeRowClosure<>() {
+ @Override public boolean apply(
+ BPlusTree<IndexRow, IndexRow> tree,
+ BPlusIO<IndexRow> io,
+ long pageAddr,
+ int idx
+ ) throws IgniteCheckedException {
+ // If we have NULLS-FIRST collation, all values after first not-null value will be not-null,
+ // don't need to check it with notNullRowFilter.
+ // In case of NULL-LAST collation, all values after first null value will be null,
+ // don't need to check it too.
+ if (skipCheck[0] && !checkExpired)
+ return nullsFirst;
+
+ boolean res = notNullRowFilter.apply(tree, io, pageAddr, idx);
+
+ if (res == nullsFirst)
+ skipCheck[0] = true;
+
+ return res;
+ }
+
+ @Override public IndexRow lastRow() {
+ return (skipCheck[0] && !checkExpired)
+ ? null
+ : notNullRowFilter.lastRow();
+ }
+ };
+ }
+
+ return checkExpired ? IndexScan.createNotExpiredRowFilter() : null;
+ }
+
+ /** */
+ private static @NotNull BPlusTree.TreeRowClosure<IndexRow, IndexRow> transactionAwareCountRowFilter(
Review Comment:
Fixed
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
Posted by "alex-plekhanov (via GitHub)" <gi...@apache.org>.
alex-plekhanov commented on code in PR #11651:
URL: https://github.com/apache/ignite/pull/11651#discussion_r1860806976
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.calcite.integration;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import org.apache.ignite.internal.processors.query.calcite.exec.IndexScan;
+import org.apache.ignite.internal.processors.query.calcite.exec.TableScan;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteIndexCount;
+import org.apache.ignite.internal.util.typedef.X;
+import org.junit.Test;
+
+/**
+ * Tests partition reservation/releasing for queries over unstable topology.
+ */
+public class PartitionsReservationIntegrationTest extends AbstractBasicIntegrationTest {
+ /** */
+ private static final int PARTS = 16;
+
+ /** */
+ private static final int KEYS = PARTS * 100_000;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ // No-op. Don't start any grids.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ startGrids(2);
+ client = startClientGrid();
Review Comment:
Fixed
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed pull request #11651: IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring)
URL: https://github.com/apache/ignite/pull/11651
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
Posted by "Vladsz83 (via GitHub)" <gi...@apache.org>.
Vladsz83 commented on code in PR #11651:
URL: https://github.com/apache/ignite/pull/11651#discussion_r1858822430
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/IndexCountScan.java:
##########
@@ -0,0 +1,198 @@
+/*
+ * 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.calcite.exec;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.cache.query.index.sorted.IndexRow;
+import org.apache.ignite.internal.cache.query.index.sorted.InlineIndexRowHandler;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext;
+import org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndex;
+import org.apache.ignite.internal.cache.query.index.sorted.keys.NullIndexKey;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
+import org.apache.ignite.internal.processors.cache.transactions.TransactionChanges;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.spi.indexing.IndexingQueryFilter;
+import org.apache.ignite.spi.indexing.IndexingQueryFilterImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** */
+public class IndexCountScan<Row> extends AbstractCacheScan<Row> {
+ /** */
+ private final InlineIndex idx;
+
+ /** */
+ private final RelCollation collation;
+
+ /** */
+ private final boolean notNull;
+
+ /** */
+ public IndexCountScan(
+ ExecutionContext<Row> ectx,
+ GridCacheContext<?, ?> cctx,
+ int[] parts,
+ InlineIndex idx,
+ RelCollation collation,
+ boolean notNull
+ ) {
+ super(ectx, cctx, parts);
+
+ this.idx = idx;
+ this.collation = collation;
+ this.notNull = notNull;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Iterator<Row> createIterator() {
+ boolean[] skipCheck = new boolean[] {false};
+
+ BPlusTree.TreeRowClosure<IndexRow, IndexRow> rowFilter = countRowFilter(skipCheck, notNull, idx);
+
+ long cnt = 0;
+
+ if (!F.isEmpty(ectx.getQryTxEntries())) {
+ TransactionChanges<CacheDataRow> txChanges = ectx.transactionChanges(
+ cctx.cacheId(),
+ parts,
+ Function.identity(),
+ null
+ );
+
+ if (!txChanges.changedKeysEmpty()) {
+ rowFilter = transactionAwareCountRowFilter(rowFilter, txChanges);
+
+ cnt = countTransactionRows(notNull, idx, txChanges.newAndUpdatedEntries());
+ }
+ }
+
+ try {
+ IndexingQueryFilter filter = new IndexingQueryFilterImpl(cctx.kernalContext(), topVer, parts);
+
+ for (int i = 0; i < idx.segmentsCount(); ++i) {
+ cnt += idx.count(i, new IndexQueryContext(filter, rowFilter));
+
+ skipCheck[0] = false;
+ }
+
+ return Collections.singletonList(ectx.rowHandler().factory(long.class).create(cnt)).iterator();
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Unable to count index records.", e);
+ }
+ }
+
+ /** */
+ private @Nullable BPlusTree.TreeRowClosure<IndexRow, IndexRow> countRowFilter(boolean[] skipCheck, boolean notNull, InlineIndex iidx) {
+ boolean checkExpired = !cctx.config().isEagerTtl();
+
+ if (notNull) {
+ boolean nullsFirst = collation.getFieldCollations().get(0).nullDirection == RelFieldCollation.NullDirection.FIRST;
+
+ BPlusTree.TreeRowClosure<IndexRow, IndexRow> notNullRowFilter = IndexScan.createNotNullRowFilter(iidx, checkExpired);
+
+ return new BPlusTree.TreeRowClosure<>() {
+ @Override public boolean apply(
+ BPlusTree<IndexRow, IndexRow> tree,
+ BPlusIO<IndexRow> io,
+ long pageAddr,
+ int idx
+ ) throws IgniteCheckedException {
+ // If we have NULLS-FIRST collation, all values after first not-null value will be not-null,
+ // don't need to check it with notNullRowFilter.
+ // In case of NULL-LAST collation, all values after first null value will be null,
+ // don't need to check it too.
+ if (skipCheck[0] && !checkExpired)
+ return nullsFirst;
+
+ boolean res = notNullRowFilter.apply(tree, io, pageAddr, idx);
+
+ if (res == nullsFirst)
+ skipCheck[0] = true;
+
+ return res;
+ }
+
+ @Override public IndexRow lastRow() {
+ return (skipCheck[0] && !checkExpired)
+ ? null
+ : notNullRowFilter.lastRow();
+ }
+ };
+ }
+
+ return checkExpired ? IndexScan.createNotExpiredRowFilter() : null;
+ }
+
+ /** */
+ private static @NotNull BPlusTree.TreeRowClosure<IndexRow, IndexRow> transactionAwareCountRowFilter(
Review Comment:
Minor. Suggestion '@NotNull' might be removed with this refactoring.
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.calcite.integration;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import org.apache.ignite.internal.processors.query.calcite.exec.IndexScan;
+import org.apache.ignite.internal.processors.query.calcite.exec.TableScan;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteIndexCount;
+import org.apache.ignite.internal.util.typedef.X;
+import org.junit.Test;
+
+/**
+ * Tests partition reservation/releasing for queries over unstable topology.
+ */
+public class PartitionsReservationIntegrationTest extends AbstractBasicIntegrationTest {
+ /** */
+ private static final int PARTS = 16;
+
+ /** */
+ private static final int KEYS = PARTS * 100_000;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ // No-op. Don't start any grids.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ startGrids(2);
+ client = startClientGrid();
Review Comment:
Minor: new line would look a bit better.
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.calcite.integration;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import org.apache.ignite.internal.processors.query.calcite.exec.IndexScan;
+import org.apache.ignite.internal.processors.query.calcite.exec.TableScan;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteIndexCount;
+import org.apache.ignite.internal.util.typedef.X;
+import org.junit.Test;
+
+/**
+ * Tests partition reservation/releasing for queries over unstable topology.
+ */
+public class PartitionsReservationIntegrationTest extends AbstractBasicIntegrationTest {
+ /** */
+ private static final int PARTS = 16;
+
+ /** */
+ private static final int KEYS = PARTS * 100_000;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ // No-op. Don't start any grids.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ startGrids(2);
+ client = startClientGrid();
+
+ awaitPartitionMapExchange();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setCacheConfiguration(new CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME)
+ .setIndexedTypes(Integer.class, Employer.class)
+ .setSqlSchema(QueryUtils.DFLT_SCHEMA)
+ .setAffinity(new RendezvousAffinityFunction(false, PARTS)));
+
+ return cfg;
+ }
+
+ /** */
+ @Test
+ public void testIndexCount() throws Exception {
+ checkPartitionsReservationRelease(
Review Comment:
I've put `if (true) return createIterator();` in `AbstractCacheScan#iterator()`. This test works. Is it ok?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23562 SQL Calcite: Fix partition reservation for index-count-scan (on top of refactoring) [ignite]
Posted by "alex-plekhanov (via GitHub)" <gi...@apache.org>.
alex-plekhanov commented on code in PR #11651:
URL: https://github.com/apache/ignite/pull/11651#discussion_r1860802366
##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/PartitionsReservationIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.calcite.integration;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.processors.query.QueryUtils;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import org.apache.ignite.internal.processors.query.calcite.exec.IndexScan;
+import org.apache.ignite.internal.processors.query.calcite.exec.TableScan;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteIndexCount;
+import org.apache.ignite.internal.util.typedef.X;
+import org.junit.Test;
+
+/**
+ * Tests partition reservation/releasing for queries over unstable topology.
+ */
+public class PartitionsReservationIntegrationTest extends AbstractBasicIntegrationTest {
+ /** */
+ private static final int PARTS = 16;
+
+ /** */
+ private static final int KEYS = PARTS * 100_000;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ // No-op. Don't start any grids.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ startGrids(2);
+ client = startClientGrid();
+
+ awaitPartitionMapExchange();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setCacheConfiguration(new CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME)
+ .setIndexedTypes(Integer.class, Employer.class)
+ .setSqlSchema(QueryUtils.DFLT_SCHEMA)
+ .setAffinity(new RendezvousAffinityFunction(false, PARTS)));
+
+ return cfg;
+ }
+
+ /** */
+ @Test
+ public void testIndexCount() throws Exception {
+ checkPartitionsReservationRelease(
Review Comment:
If you run it several times it fails with a high failure rate:
```
java.lang.AssertionError: Collections are not equal (position 0):
Expected: [[1600000]]
Actual: [[1599889]]
at org.junit.Assert.fail(Assert.java:88)
at org.apache.ignite.internal.processors.query.calcite.QueryChecker.assertEqualsCollections(QueryChecker.java:479)
at org.apache.ignite.internal.processors.query.calcite.QueryChecker.check(QueryChecker.java:454)
at org.apache.ignite.internal.processors.query.calcite.integration.PartitionsReservationIntegrationTest$1.run(PartitionsReservationIntegrationTest.java:118)
```
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org