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) {
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
On Fri, Mar 31, 2017 at 7:40 PM, Andrey Mashenkov <
[email protected]> wrote:
> Hi David,
>
> Would you please share your code.
>
> On Fri, Mar 31, 2017 at 10:42 AM, David Li <[email protected]> wrote:
>
>> It is weird.
>>
>> I run the cache query example, scan query works fine.
>>
>> I create my cache query code with a local started server node, scan query
>> works fine.
>>
>> I start a server node from terminal, start a client node in my code and
>> issue scan query, the first query after the server node is started works
>> fine, all the following queries will just return the exactly same result as
>> the first query. I try adding data into the cache, the newly added data
>> will be returned as per the first query. It looks like the first query has
>> been kept somewhere.
>>
>>
>>
>>
>> On Thu, Mar 30, 2017 at 9:02 PM, Andrey Mashenkov <
>> [email protected]> wrote:
>>
>>> Hi David,
>>>
>>> I've run your code and it works fine for me on ignite 1.7-1.9 versions
>>> and master branch.
>>>
>>> On Thu, Mar 30, 2017 at 12:19 PM, David Li <[email protected]>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> I am having a little issue with the ScanQuery for BinaryObject.
>>>>
>>>> Some code snippets
>>>>
>>>> IgniteCache<Long, Organization> cache =
>>>> ignite.cache(CacheConfig.CACHE_NAME);
>>>> IgniteCache<Long, BinaryObject> binaryCache = cache.withKeepBinary();
>>>>
>>>> // scan query
>>>> IgniteBiPredicate<Long, BinaryObject> filter = new IgniteBiPredicate<Long,
>>>> BinaryObject>() {
>>>> @Override
>>>> public boolean apply(Long key, BinaryObject value) {
>>>> return false;
>>>> }
>>>> };
>>>> ScanQuery<Long, BinaryObject> scanQuery = new ScanQuery<>(filter);
>>>>
>>>> List<Cache.Entry<Long, BinaryObject>> result =
>>>> binaryCache.query(scanQuery).getAll();
>>>>
>>>>
>>>> I expect it will return an empty result, somehow it always returns
>>>> everything in the cache.
>>>>
>>>> Not sure what is wrong?
>>>>
>>>>
>>>> BRs,
>>>>
>>>> David
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Andrey V. Mashenkov
>>>
>>
>>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>