当前位置: 首页>>代码示例>>Java>>正文


Java Bin类代码示例

本文整理汇总了Java中com.aerospike.client.Bin的典型用法代码示例。如果您正苦于以下问题:Java Bin类的具体用法?Java Bin怎么用?Java Bin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Bin类属于com.aerospike.client包,在下文中一共展示了Bin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: incrementBin

import com.aerospike.client.Bin; //导入依赖的package包/类
public void incrementBin(String name, String key, String bin) {
	Thread thread = new Thread(new Runnable() {
           @Override
           public void run() {
           	synchronized (obj) {
           		try {
           			aClient = new AerospikeClient(Constants.IP, Constants.PORT);            		
            		Key keyObj = new Key(NAMESPACE, name, key);
                	Bin binObj = new Bin(bin, 1);
                	aClient.add(writePolicy, keyObj, binObj);
           		} catch (Exception e) {
           			e.printStackTrace();
           		} finally {
           			if (aClient != null) aClient.close();
           		}
			}
           }
       });
       thread.start();
}
 
开发者ID:pawankumbhare4213,项目名称:TinyURL,代码行数:21,代码来源:AerospikeDB.java

示例2: processBatch

import com.aerospike.client.Bin; //导入依赖的package包/类
@Override
public void processBatch(Collection<T> tuples)
{
  Key key;
  Bin[] binsArray;
  try {
    for (T tuple: tuples) {
      key = getUpdatedBins(tuple,bins);
      binsArray = new Bin[bins.size()];
      binsArray = bins.toArray(binsArray);
      store.getClient().put(null, key, binsArray);
      bins.clear();
    }
  } catch (AerospikeException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:18,代码来源:AbstractAerospikeTransactionalPutOperator.java

示例3: update

import com.aerospike.client.Bin; //导入依赖的package包/类
private Map<String, Long> update(KeyRecordIterator results, List<Bin> bins) {
	long readCount = 0;
	long updateCount = 0;
	while (results.hasNext()) {
		KeyRecord keyRecord = results.next();
		readCount++;
		WritePolicy up = new WritePolicy(updatePolicy);
		up.generation = keyRecord.record.generation;
		try {
			client.put(up, keyRecord.key, bins.toArray(new Bin[0]));
			updateCount++;
		} catch (AerospikeException e) {
			System.out.println(keyRecord.key);
		}
	}
	Map<String, Long> map = new HashMap<String, Long>();
	map.put("read", readCount);
	map.put("write", updateCount);
	return map;
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:21,代码来源:QueryEngine.java

示例4: remove

import com.aerospike.client.Bin; //导入依赖的package包/类
/**
 * Delete values from list.
 *
 * @param values A list of values to delete
 */
public void remove(List<Value> values) {
	Key[] keys = makeSubKeys(values);
	List<byte[]> digestList = getDigestList();

	//		int startIndex = digestList.IndexOf (subKey.digest);
	//		int count = values.Count;
	//		foreach (Key key in keys){
	//
	//			client.Delete (this.policy, key);
	//		}
	//		client.Operate(this.policy, this.key, ListOperation.Remove(this.binNameString, startIndex, count));

	for (Key key : keys) {
		client.delete(this.policy, key);
		digestList.remove(key.digest);
	}

	client.put(this.policy, this.key, new Bin(this.binNameString, digestList));
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:25,代码来源:LargeList.java

示例5: config

import com.aerospike.client.Bin; //导入依赖的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);
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:17,代码来源:TimeSeries.java

示例6: updateByKey

import com.aerospike.client.Bin; //导入依赖的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"));
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:23,代码来源:UpdatorTests.java

示例7: updateByDigest

import com.aerospike.client.Bin; //导入依赖的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"));
		}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:24,代码来源:UpdatorTests.java

示例8: deleteWithFilter

import com.aerospike.client.Bin; //导入依赖的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);
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:21,代码来源:DeleterTests.java

示例9: addEntityIndex

import com.aerospike.client.Bin; //导入依赖的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);
}
 
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:24,代码来源:AerospikeOperationsImpl.java

示例10: getBins

import com.aerospike.client.Bin; //导入依赖的package包/类
/**
 * Returns bins for the passed entity. The bins will not contain any field
 * which are annotated with {@link AerospikeTransient}.
 * 
 * @param entity
 * @return
 */
@PerformanceMonitor
public Bin[] getBins(Serializable entity) {
	EntityStructure structure = entityStructure.get(entity.getClass());
	if (structure != null) {
		// Get all settable fields count. Iterate and get the value from
		// specific entity.
		Bin[] bins = new Bin[structure.getPersistableFields().size()];
		int cntr = 0;
		for (PersistableField field : structure.getPersistableFields()) {
			bins[cntr++] = prepareBin(entity, field);
		}
		return bins;
	}
	return null;
}
 
开发者ID:fanendra22,项目名称:spring-data-aerospike,代码行数:23,代码来源:EntityMapper.java

示例11: dataSetImport

import com.aerospike.client.Bin; //导入依赖的package包/类
/**
 * Imports dataset.
 *
 * @throws java.io.IOException
 */
private static void dataSetImport() throws IOException, ParseException {
    URL url = Resources.getResource(DATA_SET_NAME);
    JSONParser parser = new JSONParser();
    Object obj = parser.parse(new FileReader(url.getFile()));
    JSONObject jsonObject = (JSONObject) obj;

    String id = (String) jsonObject.get("id");
    JSONObject metadata = (JSONObject) jsonObject.get("metadata");
    JSONArray cantos = (JSONArray) jsonObject.get("cantos");

    Key key = new Key(NAMESPACE_ENTITY, SET_NAME, id);
    Bin binId = new Bin("id", id);
    Bin binMetadata = new Bin("metadata", metadata);
    Bin binCantos = new Bin("cantos", cantos);
    aerospike.put(null, key, binId, binMetadata, binCantos);
    aerospike.createIndex(null, NAMESPACE_ENTITY, SET_NAME, "id_idx", "id", IndexType.STRING);

    Key key2 = new Key(NAMESPACE_CELL, SET_NAME, 3);
    Bin bin_id = new Bin("_id", "3");
    Bin bin_number = new Bin("number", 3);
    Bin bin_text = new Bin("message", "new message test");
    aerospike.put(null, key2, bin_id, bin_number, bin_text);
    aerospike.createIndex(null, NAMESPACE_CELL, SET_NAME, "num_idx", "number", IndexType.NUMERIC);
    aerospike.createIndex(null, NAMESPACE_CELL, SET_NAME, "_id_idx", "_id", IndexType.STRING);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:31,代码来源:AerospikeJavaRDDFT.java

示例12: writeAerospike

import com.aerospike.client.Bin; //导入依赖的package包/类
@Override
public void writeAerospike(Text sessid,
                           Session session,
                           AerospikeClient client,
                           WritePolicy writePolicy,
                           String namespace,
                           String setName) throws IOException {
    writePolicy.timeout = 10000;
    Key kk = new Key(namespace, setName, sessid.toString());
    Bin bin0 = new Bin("userid", session.userid);
    Bin bin1 = new Bin("start", session.start);
    Bin bin2 = new Bin("end", session.end);
    Bin bin3 = new Bin("nhits", session.nhits);
    Bin bin4 = new Bin("age", session.age);
    Bin bin5 = new Bin("isMale", session.isMale);
    client.put(writePolicy, kk, bin0, bin1, bin2, bin3, bin4, bin5);
}
 
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:18,代码来源:ExternalJoin.java

示例13: runTextFile

import com.aerospike.client.Bin; //导入依赖的package包/类
public static void runTextFile(String[] args, int argi) throws Exception {

        while (argi < args.length) {
            String path = args[argi++];
            log.info("processing " + path + " ...");
            int nrecs = 0;
            BufferedReader br = new BufferedReader(new FileReader(path));
            for (String line; (line = br.readLine()) != null; ) {
                // The key is "path:linenum".
                String keystr = path + ':' + Long.toString(nrecs++);
                Key key = new Key(namespace, setName, keystr);
                Bin bin = new Bin(binName, line);
                client.put(writePolicy, key, bin);
            }
            log.info("inserted " + nrecs + " records");
        }
    }
 
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:18,代码来源:SampleData.java

示例14: getUpdatedBins

import com.aerospike.client.Bin; //导入依赖的package包/类
@Override
protected Key getUpdatedBins(Integer tuple, List<Bin> bins)
  throws AerospikeException
{

  Key key = new Key(KEYSPACE, SET_NAME, id++);
  bins.add(new Bin("ID", tuple));
  return key;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:10,代码来源:AerospikeOutputOperator.java

示例15: getUpdatedBins

import com.aerospike.client.Bin; //导入依赖的package包/类
@Override
protected Key getUpdatedBins(Object tuple, List<Bin> list)
{
  if (null == keyGetter) {    // first tuple
    Class<?> tupleClass = tuple.getClass();
    keyGetter  = PojoUtils.createGetter(tupleClass, expressions.get(0), Key.class);
    binsGetter = PojoUtils.createGetter(tupleClass, expressions.get(1), List.class);
  }
  Key key = keyGetter.get(tuple);
  List<Bin> binList = binsGetter.get(tuple);
  if ( !(null == binList || binList.isEmpty()) ) {
    list.addAll(binList);
  }
  return key;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:AerospikePOJOTransactionalPutOperator.java


注:本文中的com.aerospike.client.Bin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。