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

How to use
Operation
in
com.aerospike.client

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

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

/**
 * Create read record header database operation.
 */
public static Operation getHeader() {
  return new Operation(Type.READ_HEADER);
}
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")
@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: 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: aerospike/aerospike-client-java

Record record = client.operate(writePolicy, key, Operation.touch(), Operation.getHeader());
origin: com.spikeify/core

/**
 * An atomic operation that gets a value of a bin.
 * The provided field value will be converted to the property value, based on the converters defined via the class mapping.
 *
 * @param fieldName Name of the mapped field.
 */
public SingleKeyCommander<T> get(String fieldName) {
  String binName = mapper.getBinName(fieldName);
  operations.add(Operation.get(binName));
  return this;
}
origin: com.spikeify/core

/**
 * An atomic operation that rewrite the record. Generation and time-to-live are updated.
 * The provided field value will be converted to the property value, based on the converters defined via the class mapping.
 *
 */
public SingleKeyCommander<T> touch() {
  operations.add(Operation.touch());
  return this;
}
origin: com.spikeify/core

/**
 * An atomic operation that sets or updates a value of a bin.
 * The provided field value will be converted to the property value, based on the converters defined via the class mapping.
 *
 * @param fieldName  Name of the mapped field.
 * @param fieldValue Field value to be saved to the bin.
 */
@SuppressWarnings("unchecked")
public SingleKeyCommander<T> set(String fieldName, Object fieldValue) {
  String binName = mapper.getBinName(fieldName);
  Object propertyValue = mapper.getFieldMapper(fieldName).converter.fromField(fieldValue);
  operations.add(Operation.put(new Bin(binName, propertyValue)));
  return this;
}
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: 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: 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: com.aerospike/aerospike-client

/**
 * Create string append database operation.
 */
public static Operation append(Bin bin) {
  return new Operation(Type.APPEND, bin.name, bin.value);
}
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: com.spikeify/core

/**
 * An atomic operation that sets or updates a value of a bin.
 * The provided field value will be converted to the property value, based on the converters defined via the class mapping.
 *
 * @param fieldName Name of the mapped field.
 */
public SingleKeyCommander<T> getBytes(String fieldName, int offset, int length) {
  String binName = mapper.getBinName(fieldName);
  operations.add(Operation.get(binName));
  return this;
}
com.aerospike.clientOperation

Javadoc

Database operation definition. The class is used in client's operate() method.

Most used methods

  • add
  • get
  • put
  • touch
  • append
  • getHeader
    Create read record header database operation.
  • prepend
  • <init>

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • JCheckBox (javax.swing)
  • From CI to AI: The AI layer in your organization
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