Search in sources :

Example 56 with Statement

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

the class TestQueryRPS method queryAggregation.

@Ignore
@Test
public void queryAggregation() {
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(args.set);
    stmt.setBinNames(binName1);
    stmt.setFilter(Filter.range(binName1, 0, n_records));
    stmt.setAggregateFunction(TestQuerySum.class.getClassLoader(), "udf/sum_example.lua", "sum_example", "sum_single_bin", Value.get(binName1));
    stmt.setRecordsPerSecond(rps);
    ResultSet rs = client.queryAggregate(null, stmt);
    try {
        while (rs.next()) {
        }
    } finally {
        rs.close();
    }
    for (Node n : client.getNodes()) {
        checkRuntime(n, stmt);
    }
}
Also used : Statement(com.aerospike.client.query.Statement) Node(com.aerospike.client.cluster.Node) ResultSet(com.aerospike.client.query.ResultSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 57 with Statement

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

the class TestQueryRPS method bgScanWithOps.

@Test
public void bgScanWithOps() {
    Statement stmt = new Statement();
    stmt.setNamespace(args.namespace);
    stmt.setSetName(args.set);
    stmt.setRecordsPerSecond(rps);
    ExecuteTask task = client.execute(null, stmt, Operation.put(new Bin(binName3, 1)));
    task.waitTillComplete();
    for (Node n : client.getNodes()) {
        checkRuntime(n, stmt);
    }
}
Also used : Statement(com.aerospike.client.query.Statement) Bin(com.aerospike.client.Bin) Node(com.aerospike.client.cluster.Node) ExecuteTask(com.aerospike.client.task.ExecuteTask) Test(org.junit.Test)

Example 58 with Statement

use of com.aerospike.client.query.Statement 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 59 with Statement

use of com.aerospike.client.query.Statement 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)

Example 60 with Statement

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

the class TestQueryKey method queryKey.

@Test
public void queryKey() {
    int begin = 2;
    int end = 5;
    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()) {
            Key key = rs.getKey();
            assertNotNull(key.userKey);
            Object userkey = key.userKey.getObject();
            assertNotNull(userkey);
            count++;
        }
        assertEquals(4, count);
    } finally {
        rs.close();
    }
}
Also used : Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet) Key(com.aerospike.client.Key) 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