本文整理汇总了Java中com.aerospike.client.Record类的典型用法代码示例。如果您正苦于以下问题:Java Record类的具体用法?Java Record怎么用?Java Record使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Record类属于com.aerospike.client包,在下文中一共展示了Record类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getURLDetails
import com.aerospike.client.Record; //导入依赖的package包/类
public static JSONObject getURLDetails(String shortURL) {
JSONObject json = new JSONObject();
try {
Record record = db.readKey(Constants.URLS, shortURL);
json.append(Constants.SHORT_URL, shortURL);
json.append(Constants.LONG_URL, record.getString(Constants.LONG_URL));
json.append(Constants.HIT_COUNT, record.getLong(Constants.HIT_COUNT));
Date date = new Date(record.getLong(Constants.TIMESTAMP));
DateFormat format = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss");
json.append(Constants.TIMESTAMP, format.format(date));
} catch (Exception e) {
e.printStackTrace();
try {
json.append(Constants.MESSAGE, Constants.INVALID_SHORT_URL);
json.remove(Constants.SHORT_URL);
} catch (JSONException e1) {
e1.printStackTrace();
}
}
return json;
}
示例2: emitTuples
import com.aerospike.client.Record; //导入依赖的package包/类
/**
* 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);
}
}
示例3: getElementKeys
import com.aerospike.client.Record; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Key[] getElementKeys() {
Key[] keys = null;
Record topRecord = client.get(this.policy, this.key, this.binNameString);
if (topRecord != null) {
List<byte[]> digestList = (List<byte[]>) topRecord.getList(this.binNameString);
if (digestList != null) {
keys = new Key[digestList.size()];
int index = 0;
for (byte[] digest : digestList) {
Key subKey = new Key(this.key.namespace, digest, null, null);
keys[index] = subKey;
index++;
}
}
}
return keys;
}
示例4: filterBinByRange
import com.aerospike.client.Record; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private boolean filterBinByRange(Record record, String bin, Value low, Value high) {
if (record == null)
return false;
Object value = record.getValue(bin);
if (value instanceof List) {
//TODO
return false;
} else if (value instanceof Map) {
Map dict = (Map) value;
Object keyValue = dict.get("key");
if (keyValue == null)
return false;
return filterRange(keyValue, low, high);
} else {
return filterRange(value, low, high);
}
}
示例5: config
import com.aerospike.client.Record; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void config() {
Map<String, Object> conf = null;
Record record = this.client.get(this.policy, key, binName);
if (record != null) {
conf = (Map<String, Object>) record.getValue(binName);
}
if (conf == null) {
conf = new HashMap<String, Object>();
conf.put(configBucketSize, DefaultBucketSize);
this.bucketSize = DefaultBucketSize;
this.client.put(this.policy, this.key, new Bin(binName, Value.get(conf)));
} else {
this.bucketSize = (Long) conf.get(configBucketSize);
}
}
示例6: updateByKey
import com.aerospike.client.Record; //导入依赖的package包/类
@Test
public void updateByKey(){
for (int x = 1; x <= TestQueryEngine.RECORD_COUNT; x++){
String keyString = "selector-test:"+x;
Key key = new Key(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, keyString);
KeyQualifier kq = new KeyQualifier(Value.get(keyString));
Statement stmt = new Statement();
stmt.setNamespace(TestQueryEngine.NAMESPACE);
stmt.setSetName(TestQueryEngine.SET_NAME);
ArrayList<Bin> bins = new ArrayList<Bin>() {{
add(new Bin("ending", "ends with e"));
}};
Map<String, Long> counts = queryEngine.update(stmt, bins, kq );
Assert.assertEquals((Long)1L, (Long)counts.get("write"));
Record record = this.client.get(null, key);
Assert.assertNotNull(record);
String ending = record.getString("ending");
Assert.assertTrue(ending.endsWith("ends with e"));
}
}
示例7: updateByDigest
import com.aerospike.client.Record; //导入依赖的package包/类
@Test
public void updateByDigest(){
for (int x = 1; x <= TestQueryEngine.RECORD_COUNT; x++){
String keyString = "selector-test:"+x;
Key key = new Key(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, keyString);
KeyQualifier kq = new KeyQualifier(key.digest);
Statement stmt = new Statement();
stmt.setNamespace(TestQueryEngine.NAMESPACE);
stmt.setSetName(TestQueryEngine.SET_NAME);
ArrayList<Bin> bins = new ArrayList<Bin>() {{
add(new Bin("ending", "ends with e"));
}};
Map<String, Long> counts = queryEngine.update(stmt, bins, kq );
Assert.assertEquals((Long)1L, (Long)counts.get("write"));
Record record = this.client.get(null, key);
Assert.assertNotNull(record);
String ending = record.getString("ending");
Assert.assertTrue(ending.endsWith("ends with e"));
}
}
示例8: deleteWithFilter
import com.aerospike.client.Record; //导入依赖的package包/类
@Test
public void deleteWithFilter() throws Exception {
Key key = new Key(TestQueryEngine.NAMESPACE, TestQueryEngine.SET_NAME, "first-name-1");
Bin firstNameBin = new Bin("first_name", "first-name-1");
Bin lastNameBin = new Bin("last_name", "last-name-1");
int age = 25;
Bin ageBin = new Bin("age", age);
this.client.put(null, key, firstNameBin, lastNameBin, ageBin);
Qualifier qual1 = new Qualifier("last_name", Qualifier.FilterOperation.EQ, Value.get("last-name-1"));
//DELETE FROM test.people WHERE last_name='last-name-1'
Statement stmt = new Statement();
stmt.setNamespace(TestQueryEngine.NAMESPACE);
stmt.setSetName(TestQueryEngine.SET_NAME);
Map<String, Long> counts = queryEngine.delete(stmt, qual1);
Assert.assertEquals((Long)1L, (Long)counts.get("read"));
Assert.assertEquals((Long)1L, (Long)counts.get("write"));
Record record = this.client.get(null, key);
Assert.assertNull(record);
}
示例9: CDTListOperations
import com.aerospike.client.Record; //导入依赖的package包/类
@Test
public void CDTListOperations(){
Key key = new Key (TestQueryEngine.NAMESPACE, SET, "CDT-list-test-key");
List<Value> inputList = new ArrayList<Value>();
inputList.add(Value.get(55));
inputList.add(Value.get(77));
for (int x = 0; x < 100; x++) {
client.operate(null, key, ListOperation.insert("integer-list", 0, Value.get(x)));
}
Record record = client.operate(null, key, ListOperation.size("integer-list"));
Assert.assertEquals (100, record.getInt("integer-list"));
record = client.operate(null, key, ListOperation.appendItems("integer-list", inputList));
record = client.operate(null, key, ListOperation.size("integer-list"));
Assert.assertEquals (102, record.getInt("integer-list"));
}
示例10: addEntityIndex
import com.aerospike.client.Record; //导入依赖的package包/类
/**
* Replicates all the indexes defined in the entity to database.
*
* @param structure
*/
private void addEntityIndex(EntityStructure structure) {
for (Entry<String, Index> entry : structure.getSecondaryIndexes().entrySet()) {
//Check if indexes have already been done. This is done using a new set
// and using entity namespace and index set. If index is already set no need
//to do any thing. Otherwise create index and set in the database
String indexName = entry.getValue().getIndexName();
Record record = client.getAerospikeClient().get(null, createKey(structure.getNameSpace(), "indexes", indexName));
if(record != null && 1 == record.getInt(indexName)) {
LOGGER.warn("Index: {} for class: {} has already been created. Skipping index creation for this field", entry.getValue().getIndexName(), structure.getClazzName());
continue;
}
addIndex(structure.getPolicy(), structure.getNameSpace(), structure.getSet(), entry.getKey(), entry.getValue().getIndexName(), entry
.getValue().getIndexType());
client.getAerospikeClient().put(null, createKey(structure.getNameSpace(), "indexes", indexName), new Bin(indexName, 1));
LOGGER.info("Index: {} for class: {} has been created", entry.getValue().getIndexName(), structure.getClazzName());
}
structure.setIndexesInitialized(true);
}
示例11: reverseMap
import com.aerospike.client.Record; //导入依赖的package包/类
/**
* Creates entities array from the passed {@link Record} array.
*
* @param record
* @param clazz
* @return
*/
@PerformanceMonitor
public <K extends Serializable, T extends Serializable> Map<K, T> reverseMap(K[] keys, Record[] records, Class clazz) {
if (records.length <= 0) {
return Collections.EMPTY_MAP;
}
Map<K, T> values = new HashMap<K, T>(records.length);
for (int i = 0; i < records.length; i++) {
if (records[i] != null) {
T value = (T) reverseMap(records[i], clazz);
if (value != null) {
values.put(keys[i], value);
}
}
}
if (values.isEmpty()) {
return Collections.EMPTY_MAP;
}
return values;
}
示例12: BatchCommandGet
import com.aerospike.client.Record; //导入依赖的package包/类
public BatchCommandGet(
Node node,
BatchNode.BatchNamespace batchNamespace,
Policy policy,
HashMap<Key,BatchItem> keyMap,
HashSet<String> binNames,
Record[] records,
int readAttr
) {
super(node);
this.batchNamespace = batchNamespace;
this.policy = policy;
this.keyMap = keyMap;
this.binNames = binNames;
this.records = records;
this.readAttr = readAttr;
}
示例13: parseResult
import com.aerospike.client.Record; //导入依赖的package包/类
protected void parseResult(Connection conn) throws AerospikeException, IOException {
// Read header.
conn.readFully(dataBuffer, MSG_TOTAL_HEADER_SIZE);
int resultCode = dataBuffer[13] & 0xFF;
if (resultCode == 0) {
int generation = Buffer.bytesToInt(dataBuffer, 14);
int expiration = Buffer.bytesToInt(dataBuffer, 18);
record = new Record(null, null, generation, expiration);
}
else {
if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
record = null;
}
else {
throw new AerospikeException(resultCode);
}
}
emptySocket(conn);
}
示例14: AsyncBatchGetArray
import com.aerospike.client.Record; //导入依赖的package包/类
public AsyncBatchGetArray(
AsyncMultiExecutor parent,
AsyncCluster cluster,
AsyncNode node,
BatchNode.BatchNamespace batchNamespace,
Policy policy,
HashMap<Key,BatchItem> keyMap,
HashSet<String> binNames,
Record[] records,
int readAttr
) {
super(parent, cluster, node, false, binNames);
this.batchNamespace = batchNamespace;
this.policy = policy;
this.keyMap = keyMap;
this.records = records;
this.readAttr = readAttr;
}
示例15: parseResult
import com.aerospike.client.Record; //导入依赖的package包/类
protected final void parseResult(ByteBuffer byteBuffer) throws AerospikeException {
int resultCode = byteBuffer.get(5) & 0xFF;
if (resultCode == 0) {
int generation = byteBuffer.getInt(6);
int expiration = byteBuffer.getInt(10);
record = new Record(null, null, generation, expiration);
}
else {
if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
record = null;
}
else {
throw new AerospikeException(resultCode);
}
}
}