/** * Select records filtered by Qualifiers * * @param stmt A Statement object containing Namespace, Set and the Bins to be returned. * @param sortMap <STRONG>NOT IMPLEMENTED</STRONG> * @param qualifiers Zero or more Qualifiers for the update query * @return A KeyRecordIterator to iterate over the results */ public KeyRecordIterator select(Statement stmt, Map<String, String> sortMap, Qualifier... qualifiers) { KeyRecordIterator results = null; if (qualifiers != null && qualifiers.length > 0) { Map<String, Object> originArgs = new HashMap<String, Object>(); originArgs.put("includeAllFields", 1); String filterFuncStr = buildFilterFunction(qualifiers); originArgs.put("filterFuncStr", filterFuncStr); String sortFuncStr = buildSortFunction(sortMap); originArgs.put("sortFuncStr", sortFuncStr); stmt.setAggregateFunction(this.getClass().getClassLoader(), AS_UTILITY_PATH, QUERY_MODULE, "select_records", Value.get(originArgs)); ResultSet resultSet = this.client.queryAggregate(queryPolicy, stmt); results = new KeyRecordIterator(stmt.getNamespace(), resultSet); } else { RecordSet recordSet = this.client.query(queryPolicy, stmt); results = new KeyRecordIterator(stmt.getNamespace(), recordSet); } return results; }
RecordSet recordSet = client.query(null, statement);
@Override public long getCommittedWindowId(String appId, int operatorId) { try { lastWindowFetchCommand.setFilters(Filter.equal(metaTableOperatorIdColumn, operatorId)); lastWindowFetchCommand.setFilters(Filter.equal(metaTableAppIdColumn, appId)); long lastWindow = -1; RecordSet recordSet = client.query(null, lastWindowFetchCommand); while(recordSet.next()) { lastWindow = Long.parseLong(recordSet.getRecord().getValue(metaTableWindowColumn).toString()); } return lastWindow; } catch (AerospikeException ex) { throw new RuntimeException(ex); } }
@Override public long getCommittedWindowId(String appId, int operatorId) { try { lastWindowFetchCommand.setFilters(Filter.equal(metaTableOperatorIdColumn, operatorId)); lastWindowFetchCommand.setFilters(Filter.equal(metaTableAppIdColumn, appId)); long lastWindow = -1; RecordSet recordSet = client.query(null, lastWindowFetchCommand); while (recordSet.next()) { lastWindow = Long.parseLong(recordSet.getRecord().getValue(metaTableWindowColumn).toString()); } return lastWindow; } catch (AerospikeException ex) { throw new RuntimeException(ex); } }
/** * This executes the query to retrieve result from database. * It then converts each row into tuple and emit that into output port. */ @Override public void emitTuples() { Statement query = queryToRetrieveData(); logger.debug(String.format("select statement: %s", query.toString())); RecordSet rs; try { rs = store.getClient().query(null, query); while (rs.next()) { Record rec = rs.getRecord(); T tuple = getTuple(rec); outputPort.emit(tuple); } } catch (Exception ex) { store.disconnect(); DTThrowable.rethrow(ex); } } }
/** * This executes the query to retrieve result from database. * It then converts each row into tuple and emit that into output port. */ @Override public void emitTuples() { Statement query = queryToRetrieveData(); logger.debug(String.format("select statement: %s", query.toString())); RecordSet rs; try { rs = store.getClient().query(null, query); while(rs.next()){ Record rec = rs.getRecord(); T tuple = getTuple(rec); outputPort.emit(tuple); } } catch (Exception ex) { store.disconnect(); DTThrowable.rethrow(ex); } } }
stmt.setFilter(Filter.geoWithinRegion(binName, indexType, rgnsb.toString())); RecordSet rs = client.query(null, stmt);
client.query(eventLoop, new RecordSequenceListener() { public void onRecord(Key key, Record record) throws AerospikeException { int result = record.getInt(binName);
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(); } } }
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(); } } }
); RecordSet rs = client.query(null, stmt);
stmt.setFilter(Filter.contains(binName, IndexCollectionType.MAPKEYS, queryMapKey)); RecordSet rs = client.query(null, stmt);
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(); } } }
stmt.setFilter(Filter.equal(binName, filter)); RecordSet rs = client.query(null, stmt);
static boolean checkEvents() { long count = 0; 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() ) { Record record = rs.getRecord(); Key key = rs.getKey(); if (!TestPOJO.check(key, record)) { return false; } count++; } } catch (AerospikeException e) { throw new RuntimeException("Error fetching records: ", e); } finally { if (null != client) { client.close(); } } return NUM_TUPLES == count; }
); RecordSet rs = client.query(null, stmt);
stmt.setFilter(Filter.range(binName, begin, end)); RecordSet rs = client.query(null, stmt);
stmt.setFilter(Filter.geoWithinRadius(binName, lon, lat, radius)); RecordSet rs = client.query(null, stmt);
stmt.setFilter(Filter.range(binName1, begin, end)); RecordSet rs = client.query(null, stmt);
); RecordSet rs = client.query(null, stmt);