alex-plekhanov commented on a change in pull request #9118:
URL: https://github.com/apache/ignite/pull/9118#discussion_r660603011



##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryLocalTest.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.List;
+import java.util.Objects;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQueryLocalTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE = "TEST_CACHE";
+
+    /** */
+    private static final int CNT = 10_000;
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        stopAllGrids();
+    }
+
+    /** Should return full data. */
+    @Test
+    public void testServerNodeReplicatedCache() throws Exception {
+        Ignite crd = startGrids(4);
+
+        IgniteCache cache = crd.getOrCreateCache(ccfg(CacheMode.REPLICATED));
+
+        insertData(crd, cache);
+
+        IndexQuery<Long, Person> qry = new IndexQuery<Long, 
Person>(Person.class)
+            .setCriteria(lt("id", CNT / 2));
+
+        for (int i = 0; i < 4; i++) {
+            cache = grid(i).cache(CACHE);
+
+            List result = cache.query(qry.setLocal(true)).getAll();
+
+            assertEquals(CNT / 2, result.size());
+        }
+    }
+
+    /** Should return part of data only. */
+    @Test
+    public void testServerNodePartitionedCache() throws Exception {
+        Ignite crd = startGrids(4);
+
+        IgniteCache cache = crd.getOrCreateCache(ccfg(CacheMode.PARTITIONED));
+
+        insertData(crd, cache);
+
+        IndexQuery<Long, Person> qry = new IndexQuery<Long, 
Person>(Person.class)
+            .setCriteria(lt("id", CNT / 2));
+
+        for (int i = 0; i < 4; i++) {
+            cache = grid(i).cache(CACHE);
+
+            List result = cache.query(qry.setLocal(true)).getAll();
+
+            assertTrue(CNT / 2 > result.size());

Review comment:
       Ok, you are right

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQueryLocalTest.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.List;
+import java.util.Objects;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQueryLocalTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE = "TEST_CACHE";
+
+    /** */
+    private static final int CNT = 10_000;
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        stopAllGrids();
+    }
+
+    /** Should return full data. */
+    @Test
+    public void testServerNodeReplicatedCache() throws Exception {
+        Ignite crd = startGrids(4);
+
+        IgniteCache cache = crd.getOrCreateCache(ccfg(CacheMode.REPLICATED));
+
+        insertData(crd, cache);
+
+        IndexQuery<Long, Person> qry = new IndexQuery<Long, 
Person>(Person.class)
+            .setCriteria(lt("id", CNT / 2));
+
+        for (int i = 0; i < 4; i++) {
+            cache = grid(i).cache(CACHE);
+
+            List result = cache.query(qry.setLocal(true)).getAll();
+
+            assertEquals(CNT / 2, result.size());
+        }
+    }
+
+    /** Should return part of data only. */
+    @Test
+    public void testServerNodePartitionedCache() throws Exception {
+        Ignite crd = startGrids(4);
+
+        IgniteCache cache = crd.getOrCreateCache(ccfg(CacheMode.PARTITIONED));
+
+        insertData(crd, cache);
+
+        IndexQuery<Long, Person> qry = new IndexQuery<Long, 
Person>(Person.class)
+            .setCriteria(lt("id", CNT / 2));
+
+        for (int i = 0; i < 4; i++) {
+            cache = grid(i).cache(CACHE);
+
+            List result = cache.query(qry.setLocal(true)).getAll();
+
+            assertTrue(CNT / 2 > result.size());

Review comment:
       Ok, you are right, let's check that sum equals to `CNT / 2`

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.List;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.LongStream;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQuerySqlIndexTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE = "TEST_CACHE";
+
+    /** */
+    private static final String CACHE_TABLE = "TEST_CACHE_TABLE";
+
+    /** */
+    private static final String TABLE = "TEST_TABLE";
+
+    /** */
+    private static final String DESC_ID_IDX = "DESC_ID_IDX";
+
+    /** */
+    private static final int CNT = 10_000;
+
+    /** */
+    private IgniteCache cache;
+
+    /** */
+    private Ignite crd;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        crd = startGrids(4);
+
+        cache = crd.cache(CACHE);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        CacheConfiguration ccfg = new CacheConfiguration<>()

Review comment:
       I mean you need to use generics (`CacheConfiguration<Object, Object>` 
for example), IDEA shows a lot of warning if you use raw types.

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/cache/query/IndexQuerySqlIndexTest.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.List;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.LongStream;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.lt;
+
+/** */
+public class IndexQuerySqlIndexTest extends GridCommonAbstractTest {
+    /** */
+    private static final String CACHE = "TEST_CACHE";
+
+    /** */
+    private static final String CACHE_TABLE = "TEST_CACHE_TABLE";
+
+    /** */
+    private static final String TABLE = "TEST_TABLE";
+
+    /** */
+    private static final String DESC_ID_IDX = "DESC_ID_IDX";
+
+    /** */
+    private static final int CNT = 10_000;
+
+    /** */
+    private IgniteCache cache;
+
+    /** */
+    private Ignite crd;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        crd = startGrids(4);
+
+        cache = crd.cache(CACHE);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        CacheConfiguration ccfg = new CacheConfiguration<>()

Review comment:
       I mean you need to use generics (`CacheConfiguration<Object, Object>` 
for example), IDEA shows a lot of warnings if you use raw types.




-- 
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]


Reply via email to