Search in sources :

Example 41 with Statement

use of com.aerospike.client.query.Statement in project apex-malhar by apache.

the class AerospikeTestUtils method cleanMetaTable.

// removes all records from set AerospikeTransactionalStore.DEFAULT_META_SET (used to store
// committed window ids) in namespace NAMESPACE
// 
static void cleanMetaTable() {
    AerospikeClient client = null;
    try {
        client = new AerospikeClient(NODE, PORT);
        Statement stmnt = new Statement();
        stmnt.setNamespace(NAMESPACE);
        stmnt.setSetName(AerospikeTransactionalStore.DEFAULT_META_SET);
        RecordSet rs = client.query(null, stmnt);
        while (rs.next()) {
            client.delete(null, rs.getKey());
        }
    } catch (AerospikeException e) {
        LOG.error("cleanMetaTable failed: {}", e);
        throw e;
    } finally {
        if (null != client) {
            client.close();
        }
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) AerospikeException(com.aerospike.client.AerospikeException) Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet)

Example 42 with Statement

use of com.aerospike.client.query.Statement in project apex-malhar by apache.

the class AerospikeTestUtils method getNumOfEventsInStore.

// returns the number of records in set SET_NAME in namespace NAMESPACE
static long getNumOfEventsInStore() {
    AerospikeClient client = null;
    try {
        long count = 0;
        client = new AerospikeClient(NODE, PORT);
        Statement stmnt = new Statement();
        stmnt.setNamespace(NAMESPACE);
        stmnt.setSetName(SET_NAME);
        RecordSet rs = client.query(null, stmnt);
        while (rs.next()) {
            count++;
        }
        return count;
    } catch (AerospikeException e) {
        LOG.error("getNumOfEventsInStore failed: {}", e);
        throw e;
    } finally {
        if (null != client) {
            client.close();
        }
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) AerospikeException(com.aerospike.client.AerospikeException) Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet)

Example 43 with Statement

use of com.aerospike.client.query.Statement in project apex-malhar by apache.

the class AerospikeTestUtils method cleanTable.

// removes all records from set SET_NAME in namespace NAMESPACE
static void cleanTable() {
    AerospikeClient client = null;
    try {
        client = new AerospikeClient(NODE, PORT);
        Statement stmnt = new Statement();
        stmnt.setNamespace(NAMESPACE);
        stmnt.setSetName(SET_NAME);
        RecordSet rs = client.query(null, stmnt);
        while (rs.next()) {
            client.delete(null, rs.getKey());
        }
    } catch (AerospikeException e) {
        LOG.error("cleanTable failed: {}", e);
        throw e;
    } finally {
        if (null != client) {
            client.close();
        }
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) AerospikeException(com.aerospike.client.AerospikeException) Statement(com.aerospike.client.query.Statement) RecordSet(com.aerospike.client.query.RecordSet)

Aggregations

Statement (com.aerospike.client.query.Statement)43 RecordSet (com.aerospike.client.query.RecordSet)31 Record (com.aerospike.client.Record)18 Test (org.junit.Test)18 Key (com.aerospike.client.Key)10 AerospikeException (com.aerospike.client.AerospikeException)7 ResultSet (com.aerospike.client.query.ResultSet)7 Map (java.util.Map)6 AerospikeClient (com.aerospike.client.AerospikeClient)4 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