Tabnine Logo
com.aerospike.client
Code IndexAdd Tabnine to your IDE (free)

How to use com.aerospike.client

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

origin: brianfrankcooper/YCSB

@Override
public void cleanup() throws DBException {
 client.close();
}
origin: brianfrankcooper/YCSB

 @Override
 public Status delete(String table, String key) {
  try {
   if (!client.delete(deletePolicy, new Key(namespace, table, key))) {
    System.err.println("Record key " + key + " not found (delete)");
    return Status.ERROR;
   }

   return Status.OK;
  } catch (AerospikeException e) {
   System.err.println("Error while deleting key " + key + ": " + e);
   return Status.ERROR;
  }
 }
}
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

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.");
}
origin: brianfrankcooper/YCSB

@Override
public Status read(String table, String key, Set<String> fields,
  Map<String, ByteIterator> result) {
 try {
  Record record;
  if (fields != null) {
   record = client.get(readPolicy, new Key(namespace, table, key),
     fields.toArray(new String[fields.size()]));
  } else {
   record = client.get(readPolicy, new Key(namespace, table, key));
  }
  if (record == null) {
   System.err.println("Record key " + key + " not found (read)");
   return Status.ERROR;
  }
  for (Map.Entry<String, Object> entry: record.bins.entrySet()) {
   result.put(entry.getKey(),
     new ByteArrayByteIterator((byte[])entry.getValue()));
  }
  return Status.OK;
 } catch (AerospikeException e) {
  System.err.println("Error while reading key " + key + ": " + e);
  return Status.ERROR;
 }
}
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: 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 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: brianfrankcooper/YCSB

@Override
public void init() throws DBException {
 insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
 updatePolicy.recordExistsAction = RecordExistsAction.REPLACE_ONLY;
 Properties props = getProperties();
 namespace = props.getProperty("as.namespace", DEFAULT_NAMESPACE);
 String host = props.getProperty("as.host", DEFAULT_HOST);
 String user = props.getProperty("as.user");
 String password = props.getProperty("as.password");
 int port = Integer.parseInt(props.getProperty("as.port", DEFAULT_PORT));
 int timeout = Integer.parseInt(props.getProperty("as.timeout",
   DEFAULT_TIMEOUT));
 readPolicy.timeout = timeout;
 insertPolicy.timeout = timeout;
 updatePolicy.timeout = timeout;
 deletePolicy.timeout = timeout;
 ClientPolicy clientPolicy = new ClientPolicy();
 if (user != null && password != null) {
  clientPolicy.user = user;
  clientPolicy.password = password;
 }
 try {
  client =
    new com.aerospike.client.AerospikeClient(clientPolicy, host, port);
 } catch (AerospikeException e) {
  throw new DBException(String.format("Error while creating Aerospike " +
    "client for %s:%d.", host, port), e);
 }
}
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: com.aerospike/aerospike-client

/**
 * Constructor, specifying bin name and byte array value.
 * 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 Bin(String name, byte[] value) {
  this.name = name;
  this.value = Value.get(value);
}
origin: com.aerospike/aerospike-client

  /**
   * Filter and forward message to callback.
   *
   * @param level            message severity level
   * @param message        message string not terminated with a newline
   */
  public static void log(Level level, String message) {
    if (gCallback != null && level.ordinal() <= gLevel.ordinal() ) {
      gCallback.log(level, message);
    }
  }
}
origin: com.aerospike/aerospike-client

/**
 * Parse response in name/value pair format:
 * <p>
 * <command>\t<name1>=<value1>;<name2>=<value2>;...\n
 *
 * @return                parser for name/value pairs
 */
public NameValueParser getNameValueParser() {
  skipToValue();
  return new NameValueParser();
}
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 deleteRecords(
  AerospikeClient client,
  Parameters params,
  String keyPrefix,
  int size	
) throws Exception {
  for (int i = 0; i < size; i++) {
    Key key = new Key(params.namespace, params.set, keyPrefix + i);
    client.delete(params.writePolicy, key);			
  }
}

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

  /**
   * Filter and forward message to callback.
   * 
   * @param level            message severity level                
   * @param message        message string not terminated with a newline
   */
  public static void log(Level level, String message) {
    if (gCallback != null && level.ordinal() <= gLevel.ordinal() ) {
      gCallback.log(level, message);
    }
  }
}
origin: aerospike/aerospike-client-java

/**
 * Parse response in name/value pair format:
 * <p>
 * <command>\t<name1>=<value1>;<name2>=<value2>;...\n
 *     
 * @return                parser for name/value pairs
 */
public NameValueParser getNameValueParser() {
  skipToValue();
  return new NameValueParser();
}
com.aerospike.client

Most used classes

  • Key
    Unique record identifier. Records can be identified using a specified namespace, an optional set nam
  • AerospikeClient
    Instantiate an AerospikeClient object to access an Aerospike database cluster and perform database o
  • Bin
    Column name/value pair.
  • Statement
    Query statement parameters.
  • WritePolicy
    Container object for policy attributes used in write operations. This object is passed into methods
  • Value,
  • RecordSet,
  • ClientPolicy,
  • AerospikeException,
  • Info,
  • Host,
  • Policy,
  • Filter,
  • RegisterTask,
  • Log,
  • Operation,
  • EventLoops,
  • ScanPolicy,
  • TlsPolicy
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