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

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

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

origin: spring-projects/spring-data-aerospike

@Override
public boolean exists(Serializable id, Class<?> type) {
  Assert.notNull(id, "Id must not be null!");
  Assert.notNull(type, "Type must not be null!");
  try {
    AerospikePersistentEntity<?> entity = mappingContext.getPersistentEntity(type);
    Key key = getKey(id, entity);
    Record record = this.client.operate(null, key, Operation.getHeader());
    return record != null;
  } catch (AerospikeException e) {
    DataAccessException translatedException = exceptionTranslator.translateExceptionIfPossible(e);
    throw translatedException == null ? e : translatedException;
  }
}
origin: spring-projects/spring-data-aerospike

private Record getAndTouch(Key key, int expiration) {
  WritePolicy writePolicy = new WritePolicy(client.writePolicyDefault);
  writePolicy.expiration = expiration;
  return this.client.operate(writePolicy, key, Operation.touch(), Operation.get());
}
origin: aerospike/aerospike-loader

client.operate(this.params.writePolicy, key,
    com.aerospike.client.cdt.ListOperation.append(b.name, b.value));
origin: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
@Override
public <T> T append(T objectToAppendTo, Map<String, String> values) {
  Assert.notNull(objectToAppendTo,
      "Object to append to must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToAppendTo, data);
    Operation[] ops = new Operation[values.size() + 1];
    int x = 0;
    for (Map.Entry<String, String> entry : values.entrySet()) {
      Bin newBin = new Bin(entry.getKey(), entry.getValue());
      ops[x] = Operation.append(newBin);
      x++;
    }
    ops[x] = Operation.get();
    Record record = this.client.operate(null, data.getKey(), ops);
    return mapToEntity(data.getKey(), (Class<T>) objectToAppendTo.getClass(), record);
  }
  catch (AerospikeException o_O) {
    DataAccessException translatedException = exceptionTranslator
        .translateExceptionIfPossible(o_O);
    throw translatedException == null ? o_O : translatedException;
  }
}
origin: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
@Override
public <T> T prepend(T objectToPrependTo, Map<String, String> values) {
  Assert.notNull(objectToPrependTo,
      "Object to prepend to must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToPrependTo, data);
    Operation[] ops = new Operation[values.size() + 1];
    int x = 0;
    for (Map.Entry<String, String> entry : values.entrySet()) {
      Bin newBin = new Bin(entry.getKey(), entry.getValue());
      ops[x] = Operation.prepend(newBin);
      x++;
    }
    ops[x] = Operation.get();
    Record record = this.client.operate(null, data.getKey(), ops);
    return mapToEntity(data.getKey(), (Class<T>) objectToPrependTo.getClass(), record);
  }
  catch (AerospikeException o_O) {
    DataAccessException translatedException = exceptionTranslator
        .translateExceptionIfPossible(o_O);
    throw translatedException == null ? o_O : translatedException;
  }
}
origin: aerospike/aerospike-client-java

Record record = client.operate(params.writePolicy, key, 
    MapOperation.putItems(MapPolicy.Default, binName, inputMap)
    );
record = client.operate(params.writePolicy, key, 
    MapOperation.removeByValueRange(binName, null, Value.get(end), MapReturnType.COUNT)
    );
origin: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
public <T> T add(T objectToAddTo, Map<String, Long> values) {
  Assert.notNull(objectToAddTo, "Object to add to must not be null!");
  Assert.notNull(values, "Values must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToAddTo, data);
    Operation[] operations = new Operation[values.size() + 1];
    int x = 0;
    for (Map.Entry<String, Long> entry : values.entrySet()) {
      Bin newBin = new Bin(entry.getKey(), entry.getValue());
      operations[x] = Operation.add(newBin);
      x++;
    }
    operations[x] = Operation.get();
    WritePolicy writePolicy = new WritePolicy(this.client.writePolicyDefault);
    writePolicy.expiration = data.getExpiration();
    Record record = this.client.operate(writePolicy, data.getKey(),
        operations);
    return mapToEntity(data.getKey(), (Class<T>) objectToAddTo.getClass(), record);
  } catch (AerospikeException e) {
    DataAccessException translatedException = exceptionTranslator.translateExceptionIfPossible(e);
    throw translatedException == null ? e : translatedException;
  }
}
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: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
public <T> T add(T objectToAddTo, String binName, long value) {
  Assert.notNull(objectToAddTo, "Object to add to must not be null!");
  Assert.notNull(binName, "Bin name must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToAddTo, data);
    WritePolicy writePolicy = new WritePolicy(this.client.writePolicyDefault);
    writePolicy.expiration = data.getExpiration();
    Record record = this.client.operate(writePolicy, data.getKey(),
        Operation.add(new Bin(binName, value)), Operation.get());
    return mapToEntity(data.getKey(), (Class<T>) objectToAddTo.getClass(), record);
  } catch (AerospikeException e) {
    DataAccessException translatedException = exceptionTranslator.translateExceptionIfPossible(e);
    throw translatedException == null ? e : translatedException;
  }
}
origin: aerospike/aerospike-client-java

Record record = client.operate(params.writePolicy, key, 
    ListOperation.appendItems(binName, inputList)
    );
record = client.operate(params.writePolicy, key, 
    ListOperation.pop(binName, -1),
    ListOperation.size(binName)
origin: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
@Override
public <T> T prepend(T objectToPrependTo, String fieldName, String value) {
  Assert.notNull(objectToPrependTo,
      "Object to prepend to must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToPrependTo, data);
    Record record = this.client.operate(null, data.getKey(),
        Operation.prepend(new Bin(fieldName, value)),
        Operation.get(fieldName));
    return mapToEntity(data.getKey(), (Class<T>) objectToPrependTo.getClass(), record);
  }
  catch (AerospikeException o_O) {
    DataAccessException translatedException = exceptionTranslator
        .translateExceptionIfPossible(o_O);
    throw translatedException == null ? o_O : translatedException;
  }
}
origin: spring-projects/spring-data-aerospike

@SuppressWarnings("unchecked")
@Override
public <T> T append(T objectToAppendTo, String binName, String value) {
  Assert.notNull(objectToAppendTo,
      "Object to append to must not be null!");
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(objectToAppendTo, data);
    Record record = this.client.operate(null, data.getKey(),
        Operation.append(new Bin(binName, value)),
        Operation.get(binName));
    return mapToEntity(data.getKey(), (Class<T>) objectToAppendTo.getClass(), record);
  }
  catch (AerospikeException o_O) {
    DataAccessException translatedException = exceptionTranslator
        .translateExceptionIfPossible(o_O);
    throw translatedException == null ? o_O : translatedException;
  }
}
origin: aerospike/aerospike-client-java

Record record = client.operate(writePolicy, key, Operation.touch(), Operation.getHeader());
origin: aerospike/aerospike-client-java

Record record = client.operate(params.writePolicy, key, 
    MapOperation.putItems(MapPolicy.Default, binName, inputMap)
    );
record = client.operate(params.writePolicy, key, 
    MapOperation.removeByKey(binName, Value.get(1), MapReturnType.VALUE),
    MapOperation.size(binName)
origin: aerospike/aerospike-client-java

Record record = client.operate(params.writePolicy, key, 
    MapOperation.putItems(MapPolicy.Default, binName, inputMap)
    );
record = client.operate(params.writePolicy, key, 
    MapOperation.increment(MapPolicy.Default, binName, Value.get("John"), Value.get(5)),
    MapOperation.decrement(MapPolicy.Default, binName, Value.get("Jim"), Value.get(4))
record = client.operate(params.writePolicy, key, 
    MapOperation.getByRankRange(binName, -2, 2, MapReturnType.KEY_VALUE)
    );
origin: aerospike/aerospike-client-java

/**
 * Demonstrate multiple operations on a single record in one call.
 */
@Override
public void runExample(AerospikeClient client, Parameters params) throws Exception {
  // Write initial record.
  Key key = new Key(params.namespace, params.set, "opkey");
  Bin bin1 = new Bin("optintbin", 7);
  Bin bin2 = new Bin("optstringbin", "string value");		
  console.info("Put: namespace=%s set=%s key=%s bin1=%s value1=%s bin2=%s value2=%s",
    key.namespace, key.setName, key.userKey, bin1.name, bin1.value, bin2.name, bin2.value);
  client.put(params.writePolicy, key, bin1, bin2);
  // Add integer, write new string and read record.
  Bin bin3 = new Bin(bin1.name, 4);
  Bin bin4 = new Bin(bin2.name, "new string");
  console.info("Add: " + bin3.value);
  console.info("Write: " + bin4.value);
  console.info("Read:");
  Record record = client.operate(params.writePolicy, key, Operation.add(bin3), Operation.put(bin4), Operation.get());
  if (record == null) {
    throw new Exception(String.format(
      "Failed to get: namespace=%s set=%s key=%s",
      key.namespace, key.setName, key.userKey));
  }
  validateBin(key, record, bin3.name, 11, record.getInt(bin3.name));
  validateBin(key, record, bin4.name, bin4.value.toString(), record.getValue(bin4.name));    
}

origin: spring-projects/spring-data-aerospike

private void doPersistWithCas(Object document, AerospikePersistentEntity<?> entity) {
  try {
    AerospikeWriteData data = AerospikeWriteData.forWrite();
    converter.write(document, data);
    Key key = data.getKey();
    Bin[] bins = data.getBinsAsArray();
    ConvertingPropertyAccessor accessor = getPropertyAccessor(entity, document);
    WritePolicy policy = getCasAwareWritePolicy(data, entity, accessor);
    Operation[] operations = OperationUtils.operations(bins, Operation::put, Operation.getHeader());
    Record newRecord = client.operate(policy, key, operations);
    accessor.setProperty(entity.getVersionProperty(), newRecord.generation);
  } catch (AerospikeException e) {
    int code = e.getResultCode();
    if (code == ResultCode.KEY_EXISTS_ERROR || code == ResultCode.GENERATION_ERROR) {
      throw new OptimisticLockingFailureException("Save document with version value failed", e);
    }
    DataAccessException translatedException = exceptionTranslator.translateExceptionIfPossible(e);
    throw translatedException == null ? e : translatedException;
  }
}
origin: aerospike/aerospike-client-java

record = client.operate(params.writePolicy, key, Operation.add(bin), Operation.get(bin.name));
com.aerospike.clientAerospikeClientoperate

Javadoc

Asynchronously perform multiple read/write operations on a single key in one batch call. 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.

An example would be to add an integer value to an existing record and then read the result, all in one database call.

The server executes operations in the same order as the operations array. Both scalar bin operations (Operation) and CDT bin operations (ListOperation, MapOperation) can be performed in same call.

Popular methods of AerospikeClient

  • <init>
    Initialize Aerospike client. If the host connection succeeds, the client will: - Add host to the clu
  • put
    Write record bin(s). The policy specifies the transaction timeout, record expiration and how the tra
  • 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.
  • register
    Register package located in a file containing user defined functions with server. This asynchronous
  • isConnected,
  • register,
  • add,
  • dropIndex,
  • exists,
  • getHeader,
  • getNodeNames,
  • scanAll,
  • scanNode

Popular in Java

  • Creating JSON documents from java classes using gson
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top Vim plugins
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