Re: ScanQuery with predicate always returns empty result.
Then you have one more mistake in your code. Here is the example, which using Scan query with predicate: https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java If you want the community to help you, please share full reproducer. Evgenii 2018-01-29 11:48 GMT+03:00 Thomas Isaksen <thomas.isak...@sysco.no>: > Actually it didn’t help to get the cache with the correct types: > > > > Ignition.*setClientMode*(true); > Ignite ignite = Ignition.*start*("/config/gatekeeper-token-config.xml"); > ignite.active(true); > > IgniteCache<Long, BinaryObject> skipCache = ignite.cache("skipCache"). > withKeepBinary(); > ScanQuery<Long, BinaryObject> scan2 = new ScanQuery<>((key, value) -> { > *LOG*.debug("Key: {} - Value: {}", () -> key, () -> value); > return true; > }); > List<Cache.Entry<Long, BinaryObject>> result2 = > skipCache.query(scan2).getAll(); > *LOG*.debug("result2: {}", () -> result2); > > > > Now gives all rows in cache but lambda is ignored. > > > > 2018-01-29 09:43:22,274 DEBUG [no.toyota.gatekeeper.test.ApplicationTest] > result2: [{1=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 > [idHash=846274760, hash=2107026056, EXPRESSION=/gatekeeper/credentials]}, > {2=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 > [idHash=1928312257, hash=677512603, EXPRESSION=/swagger]}, > {3=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 > [idHash=1092619788, hash=-422574611, EXPRESSION=/gatekeeper/test]}, > {4=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 > [idHash=1337835760, hash=-57658554, EXPRESSION=/foo/index.html]}, > {5=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 > [idHash=1807911555, hash=-340982938, EXPRESSION=/rainbow.zul]}, > {6=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 > [idHash=324507700, hash=-341590176, EXPRESSION=/swagger.json]}] > > > > The same happens for static class as predicate but now the result is empty. > > > > static class Predicate implements IgniteBiPredicate<Long, BinaryObject> > { > @Override > public boolean apply(Long aLong, BinaryObject binaryObject) > { > *LOG*.debug("apply {} {}", aLong, binaryObject); > return true; > } > } > > > > ScanQuery<Long, BinaryObject> scan3 = new ScanQuery<>(new Predicate()); > List<Cache.Entry<Long, BinaryObject>> result3 = > skipCache.query(scan3).getAll(); > *LOG*.debug("result3 : {}", () -> result3); > > > > 2018-01-29 09:43:22,331 DEBUG [no.toyota.gatekeeper.test.ApplicationTest] > result3 : [] > > > > > > *From:* Thomas Isaksen [mailto:thomas.isak...@sysco.no] > *Sent:* fredag 26. januar 2018 21.12 > *To:* user@ignite.apache.org; user@ignite.apache.org > *Subject:* Re: ScanQuery with predicate always returns empty result. > > > > Ah! I make silly mistakes too often. I will give it a try. I will also > make a separate class instead of an inner class. Thanks! > > > > -- > > Thomas Isaksen > -- > > *From:* ezhuravlev <e.zhuravlev...@gmail.com> > *Sent:* Friday, January 26, 2018 3:48:56 PM > *To:* user@ignite.apache.org > *Subject:* Re: ScanQuery with predicate always returns empty result. > > > > Hi, in case when you use: > ScanQuery<Long, BinaryObject> scan = new ScanQuery<>((key, value) -> { > > System.out.println(key + “ = “ + value); > > return true; > > }) > I think the problem is that you created ScanQuery<Long, BinaryObject> while > your cache is IgniteCache<String, String>. Scan query should be <String, > String> too. > > In case of Inner class, it's trying to serialize your outer class, but it > faces some problems in this process. Here you can create separate class > instead of inner, it will help > > Evgenii > > > > -- > Sent from: http://apache-ignite-users.70518.x6.nabble.com/ >
RE: ScanQuery with predicate always returns empty result.
Actually it didn't help to get the cache with the correct types: Ignition.setClientMode(true); Ignite ignite = Ignition.start("/config/gatekeeper-token-config.xml"); ignite.active(true); IgniteCache<Long, BinaryObject> skipCache = ignite.cache("skipCache").withKeepBinary(); ScanQuery<Long, BinaryObject> scan2 = new ScanQuery<>((key, value) -> { LOG.debug("Key: {} - Value: {}", () -> key, () -> value); return true; }); List<Cache.Entry<Long, BinaryObject>> result2 = skipCache.query(scan2).getAll(); LOG.debug("result2: {}", () -> result2); Now gives all rows in cache but lambda is ignored. 2018-01-29 09:43:22,274 DEBUG [no.toyota.gatekeeper.test.ApplicationTest] result2: [{1=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 [idHash=846274760, hash=2107026056, EXPRESSION=/gatekeeper/credentials]}, {2=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 [idHash=1928312257, hash=677512603, EXPRESSION=/swagger]}, {3=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 [idHash=1092619788, hash=-422574611, EXPRESSION=/gatekeeper/test]}, {4=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 [idHash=1337835760, hash=-57658554, EXPRESSION=/foo/index.html]}, {5=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 [idHash=1807911555, hash=-340982938, EXPRESSION=/rainbow.zul]}, {6=SQL_PUBLIC_SKIP_bd79b460_e9c9_425d_8ad5_9ebe2d32c6b3 [idHash=324507700, hash=-341590176, EXPRESSION=/swagger.json]}] The same happens for static class as predicate but now the result is empty. static class Predicate implements IgniteBiPredicate<Long, BinaryObject> { @Override public boolean apply(Long aLong, BinaryObject binaryObject) { LOG.debug("apply {} {}", aLong, binaryObject); return true; } } ScanQuery<Long, BinaryObject> scan3 = new ScanQuery<>(new Predicate()); List<Cache.Entry<Long, BinaryObject>> result3 = skipCache.query(scan3).getAll(); LOG.debug("result3 : {}", () -> result3); 2018-01-29 09:43:22,331 DEBUG [no.toyota.gatekeeper.test.ApplicationTest] result3 : [] From: Thomas Isaksen [mailto:thomas.isak...@sysco.no] Sent: fredag 26. januar 2018 21.12 To: user@ignite.apache.org; user@ignite.apache.org Subject: Re: ScanQuery with predicate always returns empty result. Ah! I make silly mistakes too often. I will give it a try. I will also make a separate class instead of an inner class. Thanks! -- Thomas Isaksen From: ezhuravlev <e.zhuravlev...@gmail.com<mailto:e.zhuravlev...@gmail.com>> Sent: Friday, January 26, 2018 3:48:56 PM To: user@ignite.apache.org<mailto:user@ignite.apache.org> Subject: Re: ScanQuery with predicate always returns empty result. Hi, in case when you use: ScanQuery<Long, BinaryObject> scan = new ScanQuery<>((key, value) -> { System.out.println(key + " = " + value); return true; }) I think the problem is that you created ScanQuery<Long, BinaryObject> while your cache is IgniteCache<String, String>. Scan query should be <String, String> too. In case of Inner class, it's trying to serialize your outer class, but it faces some problems in this process. Here you can create separate class instead of inner, it will help Evgenii -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: ScanQuery with predicate always returns empty result.
Ah! I make silly mistakes too often. I will give it a try. I will also make a separate class instead of an inner class. Thanks! -- Thomas Isaksen From: ezhuravlev <e.zhuravlev...@gmail.com> Sent: Friday, January 26, 2018 3:48:56 PM To: user@ignite.apache.org Subject: Re: ScanQuery with predicate always returns empty result. Hi, in case when you use: ScanQuery<Long, BinaryObject> scan = new ScanQuery<>((key, value) -> { System.out.println(key + “ = “ + value); return true; }) I think the problem is that you created ScanQuery<Long, BinaryObject> while your cache is IgniteCache<String, String>. Scan query should be <String, String> too. In case of Inner class, it's trying to serialize your outer class, but it faces some problems in this process. Here you can create separate class instead of inner, it will help Evgenii -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: ScanQuery with predicate always returns empty result.
Hi, in case when you use: ScanQueryscan = new ScanQuery<>((key, value) -> { System.out.println(key + “ = “ + value); return true; }) I think the problem is that you created ScanQuery while your cache is IgniteCache . Scan query should be too. In case of Inner class, it's trying to serialize your outer class, but it faces some problems in this process. Here you can create separate class instead of inner, it will help Evgenii -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ScanQuery with predicate always returns empty result.
Hi I have the following code: IgniteCacheskipCache = IgniteUtil.getCache("skipCache").withKeepBinary(); ScanQuery scan = new ScanQuery<>(); List > result = skipCache.query(scan).getAll(); This returns all the data in my cache. However, once I start using a predicate I get no data: ScanQuery scan = new ScanQuery<>((key, value) -> { System.out.println(key + " = " + value); return true; }); List > result = skipCache.query(scan).getAll(); If I try to define the ScanQuery with an Inner class: ScanQuery scan = new ScanQuery<>(new IgniteBiPredicate () { @Override public boolean apply(Long aLong, BinaryObject binaryObject) { return true; } }); I get exception: javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: Query execution failed: GridCacheQueryBean [qry=GridCacheQueryAdapter [type=SCAN, clsName=null, clause=null, filter=no.toyota.gatekeeper.test.ApplicationTest$1@67af833b, transform=null, part=null, incMeta=false, metrics=GridCacheQueryMetricsAdapter [minTime=9223372036854775807, maxTime=0, sumTime=0, avgTime=0.0, execs=0, completed=0, fails=0], pageSize=1024, timeout=0, keepAll=true, incBackups=false, dedup=false, prj=org.apache.ignite.internal.cluster.ClusterGroupAdapter@40d4009d, keepBinary=true, subjId=30d3339d-98d1-4b28-b86a-5eb8b440d7b4, taskHash=0], rdc=null, trans=null] at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1287) at org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.next(GridCacheQueryFutureAdapter.java:171) at org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$5.onHasNext(GridCacheDistributedQueryManager.java:634) at org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53) at org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45) at org.apache.ignite.internal.processors.cache.QueryCursorImpl.getAll(QueryCursorImpl.java:114) at no.toyota.gatekeeper.test.ApplicationTest.testMatch(ApplicationTest.java:476) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at