Search in sources :

Example 36 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 37 with Statement

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

the class TestQueryString method queryString.

@Test
public void queryString() {
    String filter = valuePrefix + 3;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(args.set);
    stmt.setBinNames(binName);
    stmt.setFilter(Filter.equal(binName, filter));
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            Record record = rs.getRecord();
            String result = record.getString(binName);
            assertEquals(filter, result);
            count++;
        }
        assertNotEquals(0, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) Record(com.aerospike.client.Record) RecordSet(com.aerospike.client.query.RecordSet) Test(org.junit.Test)

Aggregations

Statement (com.aerospike.client.query.Statement)37 RecordSet (com.aerospike.client.query.RecordSet)26 Test (org.junit.Test)18 Record (com.aerospike.client.Record)16 Key (com.aerospike.client.Key)9 ResultSet (com.aerospike.client.query.ResultSet)7 Map (java.util.Map)6 AerospikeException (com.aerospike.client.AerospikeException)2 RecordSequenceListener (com.aerospike.client.listener.RecordSequenceListener)2 ExecuteTask (com.aerospike.client.task.ExecuteTask)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 HashSet (java.util.HashSet)1