Search in sources :

Example 46 with Statement

use of com.aerospike.client.query.Statement in project aerospike-client-java by aerospike.

the class TestQueryPredExp method queryPredicate4.

@Test
public void queryPredicate4() {
    int begin = 1;
    int end = 10;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(setName);
    stmt.setFilter(Filter.range(binName, begin, end));
    stmt.setPredExp(PredExp.integerVar("x"), PredExp.integerValue(4), PredExp.integerEqual(), PredExp.listBin("listbin"), PredExp.listIterateOr("x"));
    /*
		stmt.setPredicate(
			Predicate.listInclude("listbin", "x", Predicate.var("x").equal(4))
			);
		*/
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            // System.out.println(rs.getRecord().toString());
            count++;
        }
        assertEquals(1, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) Test(org.junit.Test)

Example 47 with Statement

use of com.aerospike.client.query.Statement in project aerospike-client-java by aerospike.

the class TestQueryPredExp method queryPredicate9.

@Test
public void queryPredicate9() {
    int begin = 1;
    int end = 10;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(setName);
    stmt.setFilter(Filter.range(binName, begin, end));
    stmt.setPredExp(PredExp.stringVar("x"), PredExp.stringValue("AAA"), PredExp.stringUnequal(), PredExp.mapBin("mapbin"), PredExp.mapValIterateAnd("x"));
    /*
		stmt.setPredicate(
			Predicate.mapValueExclude("mapbin", "x", Predicate.var("x").equal("AAA"))
			);
		*/
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            // System.out.println(rs.getRecord().toString());
            count++;
        }
        assertEquals(7, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) Test(org.junit.Test)

Example 48 with Statement

use of com.aerospike.client.query.Statement in project aerospike-client-java by aerospike.

the class TestQueryPredExp method queryPredicate10.

@Test
public void queryPredicate10() {
    int begin = 1;
    int end = 10;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(setName);
    stmt.setFilter(Filter.range(binName, begin, end));
    stmt.setPredExp(PredExp.recDigestModulo(3), PredExp.integerValue(1), PredExp.integerEqual());
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            // System.out.println(rs.getRecord().toString());
            count++;
        }
        assertEquals(2, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) Test(org.junit.Test)

Example 49 with Statement

use of com.aerospike.client.query.Statement in project aerospike-client-java by aerospike.

the class TestQueryPredExp method queryPredicate5.

@Test
public void queryPredicate5() {
    int begin = 1;
    int end = 10;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(setName);
    stmt.setFilter(Filter.range(binName, begin, end));
    stmt.setPredExp(PredExp.integerVar("x"), PredExp.integerValue(5), PredExp.integerUnequal(), PredExp.listBin("listbin"), PredExp.listIterateAnd("x"));
    /*
		stmt.setPredicate(
			Predicate.listExclude("listbin", "x", Predicate.var("x").equal(5))
			);
		*/
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            // System.out.println(rs.getRecord().toString());
            count++;
        }
        assertEquals(8, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) Test(org.junit.Test)

Example 50 with Statement

use of com.aerospike.client.query.Statement in project aerospike-client-java by aerospike.

the class TestQueryPredExp method queryPredicate8.

@Test
public void queryPredicate8() {
    int begin = 1;
    int end = 10;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(setName);
    stmt.setFilter(Filter.range(binName, begin, end));
    stmt.setPredExp(PredExp.stringVar("x"), PredExp.stringValue("D"), PredExp.stringUnequal(), PredExp.mapBin("mapbin"), PredExp.mapKeyIterateAnd("x"));
    /*
		stmt.setPredicate(
			Predicate.mapKeyExclude("mapbin", "x", Predicate.var("x").equal("D"))
			);
		*/
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            // System.out.println(rs.getRecord().toString());
            count++;
        }
        assertEquals(8, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) Test(org.junit.Test)

Aggregations

Statement (com.aerospike.client.query.Statement)82 RecordSet (com.aerospike.client.query.RecordSet)63 Test (org.junit.Test)53 QueryPolicy (com.aerospike.client.policy.QueryPolicy)28 Record (com.aerospike.client.Record)23 Key (com.aerospike.client.Key)10 ResultSet (com.aerospike.client.query.ResultSet)9 Node (com.aerospike.client.cluster.Node)8 ExecuteTask (com.aerospike.client.task.ExecuteTask)8 AerospikeException (com.aerospike.client.AerospikeException)7 Map (java.util.Map)6 AerospikeClient (com.aerospike.client.AerospikeClient)4 Ignore (org.junit.Ignore)4 Bin (com.aerospike.client.Bin)3 GregorianCalendar (java.util.GregorianCalendar)3 RecordSequenceListener (com.aerospike.client.listener.RecordSequenceListener)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2