ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Li <david.li...@gmail.com>
Subject Re: ScanQuery With BinaryObject
Date Fri, 07 Apr 2017 08:27:22 GMT
Hi Andrey,

Your suggestion fixed my problem. Thank you.

On Tue, Apr 4, 2017 at 1:08 AM, Andrey Mashenkov <andrey.mashenkov@gmail.com
> wrote:

> Hi David,
>
> Scan query results are never cached. It looks like your IgniteBiPredicate
> implementation is cached on server side.
> Try to move this class to upper level or make it inner and make "prefix"
> configurable with class constructor. This should work.
>
> On Mon, Apr 3, 2017 at 9:24 AM, David Li <david.li.sg@gmail.com> wrote:
>
>> Sorry, please ignore the previous email, it was sent by mistake.
>>
>> 1. I download apache-ignite-fabric-1.9.0-bin.zip, and unzip it.
>> 2. In terminal, I start an ignite instance by *bin/ignite.sh
>> examples/config/example-ignite.xml*
>> 3. I create a Java application, source code as below:
>>
>> public static void main(String[] args) {
>>     String ORG_CACHE = "org_cache_remote";
>>    * Ignition.setClientMode(true);*
>>     Ignite ignite = Ignition.start("example-ignite.xml");
>>     CacheConfiguration<Long, Organization> orgCacheCfg = new
>> CacheConfiguration<>(ORG_CACHE);
>>     orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
>>     ignite.destroyCache(ORG_CACHE);
>>     IgniteCache<Long, Organization> cache = ignite.createCache(orgCacheCfg
>> );
>>     cache.put(1L, new Organization(1L, "org1", true, "jurong east",
>> "1111"));
>>     cache.put(2L, new Organization(2L, "org2", false, "orchard", "2222"));
>>     cache.put(3L, new Organization(3L, "org3", true, "jurong west",
>> "3333"));
>>     cache.put(4L, new Organization(4L, "org4", false, "woodlands",
>> "4444"));
>>     cache.put(5L, new Organization(5L, "org5", false, "changi", "5555"));
>>     // cache.put(6L, new Organization(6L, "org6", true, "jurong island",
>> "6666"));
>>
>>     IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>>
>>     List<Cache.Entry<Long, BinaryObject>> result;
>>
>>     System.out.println("Scan by address");
>>     ScanQuery<Long, BinaryObject> scanAddress = new ScanQuery<>(
>>         new IgniteBiPredicate<Long, BinaryObject>() {
>>             @Override
>>             public boolean apply(Long aLong, BinaryObject binaryObject) {
>>                 *// first time filter by jurong, got two entries, org1
>> and org3*
>> *                // second time filter by changi, got two entries, org1
>> and org3*
>> *                // third time filter by changi as well, uncomment org6,
>> got three entries, org1, org3 and org6*
>> *                return
>> binaryObject.<String>field("address").startsWith("jurong");*
>>             }
>>         }
>>     );
>>     result = binaryCache.query(scanAddress).getAll();
>>     System.out.println("result: " + result.size());
>>     for (Cache.Entry<Long, BinaryObject> entry : result) {
>>         System.out.println(entry.getValue().deserialize().toString());
>>     }
>>
>>     ignite.close();
>> }
>>
>> Here what I want to do is start a client node, connect to the server node
>> started in step 2. Then I create a cache, put some data inside,
>> then try to run a scan query to find entries by its address.
>> The problem is when I run this program first time, it will return two
>> entries, their addresses are started with "jurong", which is correct.
>> When I run the program again, with changed value, eg. "changi", it should
>> return one entry, somehow, it still return two entries with address started
>> with "jurong", rather than "changi".
>> When I uncomment the line of "org6", and run the program again, it will
>> return three entries, all of their addresses are started with "jurong".
>>
>> I have no idea what is going on.
>>
>>
>>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Mime
View raw message