congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
AerospikeClient.put
Code IndexAdd Tabnine to your IDE (free)

How to use
put
method
in
com.aerospike.client.AerospikeClient

Best Java code snippets using com.aerospike.client.AerospikeClient.put (Showing top 20 results out of 315)

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: aerospike/aerospike-client-java

@Override
protected void put(WritePolicy policy, Key key, Bin[] bins) {
  if (useLatency) {
    begin = System.nanoTime();
  }
  client.put(eventLoop, writeListener, policy, key, bins);	
}

origin: aerospike/aerospike-client-java

/**
 * inserts a record with a time to live. If the record exists, and exception will be thrown.
 *
 * @param namespace Namespace to store the record
 * @param set       Set to store the record
 * @param key       Key of the record
 * @param bins      A list of Bins to insert
 * @param ttl       The record time to live in seconds
 */
public void insert(String namespace, String set, Key key, List<Bin> bins, int ttl) {
  this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
}
origin: aerospike/aerospike-client-java

@Override
protected void put(WritePolicy writePolicy, Key key, Bin[] bins) {
  if (counters.write.latency != null) {
    long begin = System.nanoTime();
    client.put(writePolicy, key, bins);
    long elapsed = System.nanoTime() - begin;
    counters.write.count.getAndIncrement();            
    counters.write.latency.add(elapsed);
  }
  else {
    client.put(writePolicy, key, bins);
    counters.write.count.getAndIncrement();            
  }
}

origin: aerospike/aerospike-client-java

  private void put(Key key, Bin[] bins) {
    if (counters.write.latency != null) {
      long begin = System.nanoTime();
      client.put(args.writePolicy, key, bins);
      long elapsed = System.nanoTime() - begin;
      counters.write.count.getAndIncrement();            
      counters.write.latency.add(elapsed);
    }
    else {
      client.put(args.writePolicy, key, bins);
      counters.write.count.getAndIncrement();            
    }
  }        
}
origin: aerospike/aerospike-client-java

public void runCommand() {
  long currentKey = keyStart + keyCount;
  Key key = new Key(args.namespace, args.setName, currentKey);
  Bin[] bins = args.getBins(random, true, currentKey);
  
  if (useLatency) {
    begin = System.nanoTime();
  }
  client.put(eventLoop, listener, args.writePolicy, key, bins);		
}

origin: benmfaul/XRTB

/**
 * Read only constructor (does not load the data) for use with Aerospike.
 * @param name String. The name of the symbol.
 * @param client AerospikeClient. The aerospike to use.
 */
public Membership(String name, AerospikeClient client) {
  this.name = name;
  this.client = client;
  key = new Key("test", "database", "rtb4free");
  bin1 = new Bin(name, tree);
  client.put(null, key, bin1);
  tree = null;
}

origin: aerospike/aerospike-client-java

private void runPutGetWithRetry(AerospikeClient client, EventLoop eventLoop, Key key, Bin bin) {
  console.info("Put with retry: namespace=%s set=%s key=%s value=%s", key.namespace, key.setName, key.userKey, bin.value);
  client.put(eventLoop, new WriteHandler(client, eventLoop, key, bin), writePolicy, key, bin);
}

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: aerospike/aerospike-client-java

/**
 * inserts a record, with a time to live, using a Statement and KeyQualifier. If the record exists, and exception will be thrown.
 *
 * @param stmt         A Statement object containing Namespace and Set
 * @param keyQualifier KeyQualifier containin the primary key
 * @param bins         A list of Bins to insert
 * @param ttl          The record time to live in seconds
 */
public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins, int ttl) {
  Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
  //		Key key = new Key(stmt.getNamespace(), stmt.getSetName(), keyQualifier.getValue1());
  this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
}
origin: org.apache.apex/malhar-contrib

@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: 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

private void writeRecords(
  AerospikeClient client,
  Parameters params,
  String keyPrefix,
  String binName,
  int size
) throws Exception {
  for (int i = 1; i <= size; i++) {
    Key key = new Key(params.namespace, params.set, keyPrefix + i);
    Bin bin = new Bin(binName, 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(params.writePolicy, key, bin);
  }
}
origin: aerospike/aerospike-client-java

private void writeRecords(
  AerospikeClient client,
  Parameters params,
  String keyPrefix,
  String binName,
  int size
) throws Exception {
  console.info("Write " + size + " records.");
  for (int i = 1; i <= size; i++) {
    Key key = new Key(params.namespace, params.set, keyPrefix + i);
    Bin bin = new Bin(binName, i);	
    client.put(params.writePolicy, key, bin);
  }
}
origin: spring-projects/spring-data-aerospike

@Override
public Object put(Serializable id, Object item, Serializable keyspace) {
  AerospikeWriteData data = AerospikeWriteData.forWrite();
  converter.write(item, data);
  client.put(null, data.getKey(), data.getBinsAsArray());
  return item;
}
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

private void serializeAndPut(WritePolicy writePolicy, Object key, Object value) {
  AerospikeWriteData data = AerospikeWriteData.forWrite();
  aerospikeConverter.write(value, data);
  client.put(writePolicy, getKey(key), data.getBinsAsArray());
}
origin: aerospike/aerospike-client-java

private void writeRecords(
  AerospikeClient client,
  Parameters params,
  String keyPrefix,
  String binName1,
  String binName2,
  int size
) throws Exception {
  console.info("Write " + size + " records.");
  for (int i = 1; i <= size; i++) {
    Key key = new Key(params.namespace, params.set, keyPrefix + i);
    client.put(params.writePolicy, key, new Bin(binName1, i), new Bin(binName2, i));
  }
}
origin: aerospike/aerospike-client-java

private void writeRecords(
  AerospikeClient client,
  Parameters params,
  String keyPrefix,
  int size
) throws Exception {
  for (int i = 1; i <= size; i++) {
    Key key = new Key(params.namespace, params.set, keyPrefix + i);
    Bin bin = new Bin("l1", 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(params.writePolicy, key, bin, new Bin("l2", 1));
  }
}
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.");
}
com.aerospike.clientAerospikeClientput

Javadoc

Asynchronously write record bin(s). This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.

The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.

Popular methods of AerospikeClient

  • <init>
    Initialize Aerospike client. If the host connection succeeds, the client will: - Add host to the clu
  • close
    Close all client connections to database server nodes. If event loops are defined, the client will s
  • delete
    Delete record for specified key. The policy specifies the transaction timeout.
  • get
    Read record header and bins for specified key. The policy can be used to specify timeouts.
  • query
    Execute query on all server nodes and return record iterator. The query executor puts records on a q
  • getNodes
    Return array of active server nodes in the cluster.
  • createIndex
  • execute
    Apply user defined function on records that match the statement filter. Records are not returned to
  • queryAggregate
    Execute query, apply statement's aggregation function, and return result iterator. The query executo
  • isConnected
    Determine if we are ready to talk to the database server cluster.
  • operate
    Perform multiple read/write operations on a single key in one batch call. An example would be to add
  • register
    Register package located in a file containing user defined functions with server. This asynchronous
  • operate,
  • register,
  • add,
  • dropIndex,
  • exists,
  • getHeader,
  • getNodeNames,
  • scanAll,
  • scanNode

Popular in Java

  • Start an intent from android
  • getResourceAsStream (ClassLoader)
  • setContentView (Activity)
  • getApplicationContext (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • ImageIO (javax.imageio)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now