com.aerospike.client.Bin.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中com.aerospike.client.Bin.<init>()方法的一些代码示例,展示了Bin.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bin.<init>()方法的具体详情如下:
包路径:com.aerospike.client.Bin
类名称:Bin
方法名:<init>

Bin.<init>介绍

[英]Constructor, specifying bin name and byte value. For servers configured as "single-bin", enter a null or empty name.
[中]构造函数,指定bin名称和字节值。对于配置为“单箱”的服务器,请输入空名称或空名称。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

private Status write(String table, String key, WritePolicy writePolicy,
  Map<String, ByteIterator> values) {
 Bin[] bins = new Bin[values.size()];
 int index = 0;
 for (Map.Entry<String, ByteIterator> entry: values.entrySet()) {
  bins[index] = new Bin(entry.getKey(), entry.getValue().toArray());
  ++index;
 }
 Key keyObj = new Key(namespace, table, key);
 try {
  client.put(writePolicy, keyObj, bins);
  return Status.OK;
 } catch (AerospikeException e) {
  System.err.println("Error while writing key " + key + ": " + e);
  return Status.ERROR;
 }
}

代码示例来源:origin: apache/apex-malhar

@Override
public void storeCommittedWindowId(String appId, int operatorId, long windowId)
{
 try {
  String keyString = appId + String.valueOf(operatorId);
  Key key = new Key(namespace,metaSet,keyString.hashCode());
  Bin bin1 = new Bin(metaTableAppIdColumn,appId);
  Bin bin2 = new Bin(metaTableOperatorIdColumn,operatorId);
  Bin bin3 = new Bin(metaTableWindowColumn,windowId);
  client.put(null, key, bin1,bin2,bin3);
 } catch (AerospikeException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: com.aerospike/aerospike-client

/**
 * Create bin with a GeoJSON value.
 *
 * @param name        bin name, current limit is 14 characters
 * @param value        bin value
 */
public static Bin asGeoJSON(String name, String value) {
  return new Bin(name, Value.getAsGeoJSON(value));
}

代码示例来源:origin: aerospike/aerospike-client-java

/**
 * Create bin with a null value. This is useful for bin deletions within a record.
 * For servers configured as "single-bin", enter a null or empty name.
 *
 * @param name        bin name, current limit is 14 characters
 */
public static Bin asNull(String name) {
  return new Bin(name, Value.getAsNull());
}

代码示例来源:origin: com.aerospike/aerospike-client

/**
 * Create bin with a null value. This is useful for bin deletions within a record.
 * For servers configured as "single-bin", enter a null or empty name.
 *
 * @param name        bin name, current limit is 14 characters
 */
public static Bin asNull(String name) {
  return new Bin(name, Value.getAsNull());
}

代码示例来源:origin: com.aerospike/aerospike-client

/**
 * Create bin with a blob value.  The value will be java serialized.
 * This method is faster than the bin Object constructor because the blob is converted
 * directly instead of using multiple "instanceof" type checks with a blob default.
 * <p>
 * For servers configured as "single-bin", enter a null or empty name.
 *
 * @param name        bin name, current limit is 14 characters
 * @param value        bin value
 */
public static Bin asBlob(String name, Object value) {
  return new Bin(name, Value.getAsBlob(value));
}

代码示例来源:origin: aerospike/aerospike-loader

private Bin createBinForInteger(String binName, String binRawValue) {
  try {
    // Server stores all integer type data in 64bit so use long.
    Long integer = Long.parseLong(binRawValue);
    return new Bin(binName, integer);
  } catch (Exception pi) {
    log.error("File: " + Utils.getFileName(this.fileName) + " Line: " + lineNumber
        + " Integer/Long Parse Error: " + pi);
    return null;
  }
}

代码示例来源:origin: aerospike/aerospike-client-java

/**
 * Create bin with a GeoJSON value.
 *
 * @param name        bin name, current limit is 14 characters
 * @param value        bin value
 */
public static Bin asGeoJSON(String name, String value) {
  return new Bin(name, Value.getAsGeoJSON(value));
}

代码示例来源:origin: aerospike/aerospike-client-java

/**
 * Create bin with a blob value.  The value will be java serialized.
 * This method is faster than the bin Object constructor because the blob is converted
 * directly instead of using multiple "instanceof" type checks with a blob default.
 * <p>
 * For servers configured as "single-bin", enter a null or empty name.
 *
 * @param name        bin name, current limit is 14 characters
 * @param value        bin value
 */
public static Bin asBlob(String name, Object value) {
  return new Bin(name, Value.getAsBlob(value));
}

代码示例来源:origin: aerospike/aerospike-loader

private Bin createBinForFloat(String binName, String binRawValue) {
  try {
    float binfloat = Float.parseFloat(binRawValue);
    // Now server support float
    return new Bin(binName, binfloat);
  } catch (Exception e) {
    log.error("File: " + Utils.getFileName(this.fileName) + " Line: " + lineNumber
        + " Floating number Parse Error: " + e);
    return null;
  }
}

代码示例来源:origin: com.spikeify/core

/**
 * An atomic operation that adds a value to an existing bin value. Bin value must be an integer type.
 *
 * @param fieldName Name of the bin or, if mapped Class was provided, name of the mapped field
 * @param value     Value to add to the bin value.
 */
public SingleKeyCommander<T> add(String fieldName, long value) {
  String binName = mapper != null ? mapper.getBinName(fieldName) : fieldName;
  operations.add(Operation.add(new Bin(binName, value)));
  return this;
}

代码示例来源:origin: com.spikeify/core

/**
 * An atomic operation that appends a value to an existing bin value. Bin value must be a string type.
 *
 * @param fieldName Name of the bin or, if mapped Class was provided, name of the mapped field
 * @param value     Value to append to the bin value.
 */
public SingleKeyCommander<T> append(String fieldName, String value) {
  String binName = mapper != null ? mapper.getBinName(fieldName) : fieldName;
  operations.add(Operation.append(new Bin(binName, value)));
  return this;
}

代码示例来源:origin: com.spikeify/core

/**
 * An atomic operation that prepends a value to an existing bin value. Bin value must be a string type.
 *
 * @param fieldName Name of the bin or, if mapped Class was provided, name of the mapped field
 * @param value     Value to prepend to the bin value.
 */
public SingleKeyCommander<T> prepend(String fieldName, String value) {
  String binName = mapper != null ? mapper.getBinName(fieldName) : fieldName;
  operations.add(Operation.prepend(new Bin(binName, value)));
  return this;
}

代码示例来源:origin: apache/apex-malhar

public List<Bin> getBins()
{
 List<Bin> list = new ArrayList<Bin>();
 list.add(new Bin(ID, id));
 list.add(new Bin(VAL, value));
 return list;
}

代码示例来源:origin: apache/apex-malhar

@Override
 protected Key getUpdatedBins(TestEvent tuple, List<Bin> bins) throws AerospikeException
 {
  Key key = new Key(NAMESPACE,SET_NAME,String.valueOf(tuple.id));
  bins.add(new Bin("ID",tuple.id));
  return key;
 }
}

代码示例来源:origin: aerospike/aerospike-client-java

/**
 * Write records individually.
 */
private void writeRecords() {		
  WriteHandler handler = new WriteHandler(size);
  
  for (int i = 1; i <= size; i++) {
    Key key = sendKeys[i-1];
    Bin bin = new Bin(binName, valuePrefix + i);
    
    console.info("Put: ns=%s set=%s key=%s bin=%s value=%s",
      key.namespace, key.setName, key.userKey, bin.name, bin.value);
    
    client.put(eventLoop, handler, params.writePolicy, key, bin);
  }
}

代码示例来源:origin: aerospike/aerospike-client-java

/**
 * Asynchronously write and read a bin using alternate methods.
 */
@Override
public void runExample(AerospikeClient client, EventLoop eventLoop) {
  Key key = new Key(params.namespace, params.set, "putgetkey");
  Bin bin = new Bin(params.getBinName("putgetbin"), "value");
  runPutGetInline(client, eventLoop, key, bin);
  runPutGetWithRetry(client, eventLoop, key, bin);
}

代码示例来源:origin: benmfaul/XRTB

/**
 * Set a key value as string with an expiration (No expiration set on cache2k, it is already set 
 * @param skey String. The key name.
 * @param value String. The value.
 * @throws Exception on aerorpike or cache errors.
 */
public void set(String set, String skey, Object value) throws Exception   {
  WritePolicy policy = new WritePolicy();
  Key key = new Key("test", set, skey);
  Bin bin1 = new Bin("value", value);
  ae.getClient().put(null, key, bin1);
}

代码示例来源:origin: spring-projects/spring-data-aerospike

@Override
public ValueWrapper putIfAbsent(Object key, Object value) {
  Record record = client.operate(this.createOnly, getKey(key), Operation.put(new Bin(VALUE, value)), Operation.get(VALUE));
  return toWrapper(record);
}

代码示例来源:origin: aerospike/aerospike-client-java

private void writeIfGenerationNotChanged(AerospikeClient client, Parameters params) throws Exception {	
  Key key = new Key(params.namespace, params.set, "udfkey2");
  Bin bin = new Bin(params.getBinName("udfbin2"), "string value");		
  
  // Seed record.
  client.put(params.writePolicy, key, bin);
  
  // Get record generation.
  long gen = (Long)client.execute(params.writePolicy, key, "record_example", "getGeneration");
  // Write record if generation has not changed.
  client.execute(params.writePolicy, key, "record_example", "writeIfGenerationNotChanged", Value.get(bin.name), bin.value, Value.get(gen));		
  console.info("Record written.");
}

相关文章