You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Guilherme Melo <gu...@gmelo.org> on 2017/07/06 08:13:22 UTC

Passing parameters to IgniteBiPredicate

Hello, I am having problems submitting a query to the service from a
client. Using the example from the documentation:

IgniteCache<Long, Person> cache = ignite.cache("mycache");
int sal = 100// Find only persons earning more than 1,000.try
(QueryCursor cursor = cache.query(new ScanQuery((k, p) ->
p.getSalary() > sal)) {
  for (Person p : cursor)
    System.out.println(p.toString());
}


It fails silently. I have also tried creating a class that implements the
 IgniteBiPredicate that takes the value as a parameter on the constructor.
Has anyone had experience pushing a scan query with parameters?
Thanks !

Re: [RESOLVED] Passing parameters to IgniteBiPredicate

Posted by joseheitor <jo...@heitorprojects.com>.
Please ignore my previous post - it is working correctly:

        String date = "2018-10-21";
        ScanQuery<Integer, Transaction> filter = new ScanQuery<>(
            new IgniteBiPredicate<Integer, Transaction>() {
                @Override
                public boolean apply(Integer key, Transaction trans) {
                      return trans.getDate().equals(date);
                }
            }
        );
        List result = database.getCache().query(filter).getAll();




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Passing parameters to IgniteBiPredicate

Posted by joseheitor <jo...@heitorprojects.com>.
Hi have the same question... did you ever find a solution?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Passing parameters to IgniteBiPredicate

Posted by Guilherme Melo <gu...@gmail.com>.
Hello Taras,
thanks, this example is showing a normal query with a fixed value, this is
working, the problem is passing a parameter to the predicate.

Cheers,

Guilherme Melo
www.gmelo.org

On 6 July 2017 at 22:18, Taras Ledkov <tl...@gridgain.com> wrote:

> Hi,
>
> Sure, please take a look at the example:
> https://github.com/apache/ignite/blob/master/examples/
> src/main/java/org/apache/ignite/examples/datagrid/
> CacheQueryExample.java#L155
>
> On 06.07.2017 11:13, Guilherme Melo wrote:
>
> Hello, I am having problems submitting a query to the service from a
> client. Using the example from the documentation:
>
> IgniteCache<Long, Person> cache = ignite.cache("mycache");
> int sal = 100// Find only persons earning more than 1,000.try (QueryCursor cursor = cache.query(new ScanQuery((k, p) -> p.getSalary() > sal)) {
>   for (Person p : cursor)
>     System.out.println(p.toString());
> }
>
>
> It fails silently. I have also tried creating a class that implements the
>  IgniteBiPredicate that takes the value as a parameter on the constructor.
> Has anyone had experience pushing a scan query with parameters?
> Thanks !
>
>
> --
> Taras Ledkov
> Mail-To: tledkov@gridgain.com
>
>

Re: Passing parameters to IgniteBiPredicate

Posted by Taras Ledkov <tl...@gridgain.com>.
Hi,

Sure, please take a look at the example:
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java#L155


On 06.07.2017 11:13, Guilherme Melo wrote:
> Hello, I am having problems submitting a query to the service from a 
> client. Using the example from the documentation:
>
> |IgniteCache<Long, Person> cache = ignite.cache("mycache"); int sal = 
> 100 // Find only persons earning more than 1,000. try (QueryCursor 
> cursor = cache.query(new ScanQuery((k, p) -> p.getSalary() > sal)) { 
> for (Person p : cursor) System.out.println(p.toString()); }|
>
> It fails silently. I have also tried creating a class that implements 
> the IgniteBiPredicate that takes the value as a parameter on the 
> constructor.
> Has anyone had experience pushing a scan query with parameters?
> Thanks !

-- 
Taras Ledkov
Mail-To: tledkov@gridgain.com