Search in sources :

Example 46 with RecordSet

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

the class TestQueryFilterSet method queryDouble.

@Test
public void queryDouble() {
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(set2);
    QueryPolicy policy = new QueryPolicy();
    policy.filterExp = Exp.build(Exp.gt(Exp.floatBin(binB), Exp.val(21.5)));
    RecordSet rs = client.query(policy, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            count++;
        }
        assertEquals(1, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) QueryPolicy(com.aerospike.client.policy.QueryPolicy) Test(org.junit.Test)

Example 47 with RecordSet

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

the class TestQueryFilterSet method queryKeyExists.

@Test
public void queryKeyExists() {
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(set3);
    QueryPolicy policy = new QueryPolicy();
    policy.filterExp = Exp.build(Exp.keyExists());
    RecordSet rs = client.query(policy, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            count++;
        }
        assertEquals(20, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) QueryPolicy(com.aerospike.client.policy.QueryPolicy) Test(org.junit.Test)

Example 48 with RecordSet

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

the class TestQueryInteger method queryInteger.

@Test
public void queryInteger() {
    int begin = 14;
    int end = 18;
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(args.set);
    stmt.setBinNames(binName);
    stmt.setFilter(Filter.range(binName, begin, end));
    RecordSet rs = client.query(null, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            count++;
        }
        assertEquals(5, 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 RecordSet

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

the class TestQueryRPS method query.

@Ignore
@Test
public void query() {
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(args.set);
    stmt.setFilter(Filter.range(binName1, 0, n_records));
    stmt.setRecordsPerSecond(rps);
    RecordSet rs = client.query(null, stmt);
    drainRecords(rs);
    for (Node n : client.getNodes()) {
        checkRuntime(n, stmt);
    }
}
Also used : Statement(com.aerospike.client.query.Statement) Node(com.aerospike.client.cluster.Node) RecordSet(com.aerospike.client.query.RecordSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 50 with RecordSet

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

the class TestQueryGeo method queryGeo1.

@Test
public void queryGeo1() {
    String region = "{ \"type\": \"Point\", \"coordinates\": [ -122.0986857, 37.4214209 ] }";
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(setNameRegions);
    QueryPolicy policy = new QueryPolicy();
    policy.filterExp = Exp.build(Exp.geoCompare(Exp.geoBin("loc"), Exp.geo(region)));
    RecordSet rs = client.query(policy, stmt);
    try {
        int count = 0;
        while (rs.next()) {
            // System.out.println(rs.getRecord().toString());
            count++;
        }
        assertEquals(5, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) QueryPolicy(com.aerospike.client.policy.QueryPolicy) Test(org.junit.Test)

Aggregations

RecordSet (com.aerospike.client.query.RecordSet)65 Statement (com.aerospike.client.query.Statement)63 Test (org.junit.Test)43 QueryPolicy (com.aerospike.client.policy.QueryPolicy)28 Record (com.aerospike.client.Record)22 Key (com.aerospike.client.Key)9 AerospikeException (com.aerospike.client.AerospikeException)6 AerospikeClient (com.aerospike.client.AerospikeClient)4 ArrayList (java.util.ArrayList)3 GregorianCalendar (java.util.GregorianCalendar)3 Node (com.aerospike.client.cluster.Node)2 ExecuteTask (com.aerospike.client.task.ExecuteTask)2 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Bin (com.aerospike.client.Bin)1 Expression (com.aerospike.client.exp.Expression)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 AerospikeQueryResult (org.apache.gora.aerospike.query.AerospikeQueryResult)1