timoninmaxim commented on code in PR #10767:
URL: https://github.com/apache/ignite/pull/10767#discussion_r1227909206


##########
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryLimitTest.java:
##########
@@ -0,0 +1,238 @@
+/*
+ * 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.cache.query;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.query.QueryCursorEx;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQueryLimitTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE = "TEST_CACHE";
+
+    /** */
+    private static final String IDX = "PERSON_ID_IDX";
+
+    /** */
+    private static final int CNT = 10_000;
+
+    /** */
+    private Ignite crd;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        crd = startGrids(4);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        CacheConfiguration<Long, Person> ccfg = new CacheConfiguration<Long, 
Person>()
+                .setName(CACHE)
+                .setIndexedTypes(Long.class, Person.class)
+                .setAtomicityMode(TRANSACTIONAL)
+                .setCacheMode(REPLICATED);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** */
+    @Test
+    public void testRangeQueriesWithoutDuplicates() throws Exception {
+        checkRangeQueries(1);
+    }
+
+    /** */
+    @Test
+    public void testRangeQueriesWithDuplicates() throws Exception {
+        checkRangeQueries(10);
+    }
+
+    /** */
+    @Test
+    public void testSetLimit() throws Exception {
+        GridTestUtils.assertThrows(log, () -> new IndexQuery<>(Person.class, 
IDX).setLimit(0),
+            IllegalArgumentException.class, "Limit must be positive.");
+
+        int limit = 1 + new Random().nextInt(1000);
+
+        GridTestUtils.assertThrows(log, () -> new IndexQuery<>(Person.class, 
IDX).setLimit(0 - limit),
+            IllegalArgumentException.class, "Limit must be positive.");
+
+        IndexQuery<Long, Person> qry = new IndexQuery<>(Person.class, IDX);
+
+        qry.setLimit(limit);
+
+        assertEquals(limit, qry.getLimit());
+    }
+
+    /** */
+    private void checkRangeQueries(int duplicates) throws Exception {
+        IndexQuery<Long, Person> qry = new IndexQuery<>(Person.class, IDX);
+
+        // Add data
+        insertData(duplicates);
+
+        // All
+        checkLimit(null, 0, CNT, duplicates);
+
+        String fld = "id";
+
+        int pivot = new Random().nextInt(CNT);
+
+        // Lt.
+        checkLimit(lt(fld, pivot), 0, pivot, duplicates);
+

Review Comment:
   Please remove empty line



##########
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryLimitTest.java:
##########
@@ -0,0 +1,238 @@
+/*
+ * 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.cache.query;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.query.QueryCursorEx;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQueryLimitTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE = "TEST_CACHE";
+
+    /** */
+    private static final String IDX = "PERSON_ID_IDX";
+
+    /** */
+    private static final int CNT = 10_000;
+
+    /** */
+    private Ignite crd;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        crd = startGrids(4);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        CacheConfiguration<Long, Person> ccfg = new CacheConfiguration<Long, 
Person>()
+                .setName(CACHE)
+                .setIndexedTypes(Long.class, Person.class)
+                .setAtomicityMode(TRANSACTIONAL)
+                .setCacheMode(REPLICATED);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** */
+    @Test
+    public void testRangeQueriesWithoutDuplicates() throws Exception {
+        checkRangeQueries(1);
+    }
+
+    /** */
+    @Test
+    public void testRangeQueriesWithDuplicates() throws Exception {
+        checkRangeQueries(10);
+    }
+
+    /** */
+    @Test
+    public void testSetLimit() throws Exception {
+        GridTestUtils.assertThrows(log, () -> new IndexQuery<>(Person.class, 
IDX).setLimit(0),
+            IllegalArgumentException.class, "Limit must be positive.");
+
+        int limit = 1 + new Random().nextInt(1000);
+
+        GridTestUtils.assertThrows(log, () -> new IndexQuery<>(Person.class, 
IDX).setLimit(0 - limit),
+            IllegalArgumentException.class, "Limit must be positive.");
+
+        IndexQuery<Long, Person> qry = new IndexQuery<>(Person.class, IDX);
+
+        qry.setLimit(limit);
+
+        assertEquals(limit, qry.getLimit());
+    }
+
+    /** */
+    private void checkRangeQueries(int duplicates) throws Exception {
+        IndexQuery<Long, Person> qry = new IndexQuery<>(Person.class, IDX);
+
+        // Add data
+        insertData(duplicates);
+
+        // All
+        checkLimit(null, 0, CNT, duplicates);
+
+        String fld = "id";

Review Comment:
   Can be inlined



-- 
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-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to