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

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

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

origin: aerospike/aerospike-client-java

@Override
protected void get(Key key, String udfPackageName, String udfFunctionName, Value[] udfValues) {
  Object udfReturnObj;
  if (counters.read.latency != null) {
    long begin = System.nanoTime();
    udfReturnObj = client.execute(args.writePolicy, key, udfPackageName, udfFunctionName, udfValues);
    long elapsed = System.nanoTime() - begin;
    counters.read.latency.add(elapsed);
  }
  else {
    udfReturnObj = client.execute(args.writePolicy, key, udfPackageName, udfFunctionName, udfValues);
  }
  processRead(key, udfReturnObj);
}
origin: aerospike/aerospike-client-java

  private void writeBlobUsingUdf(AerospikeClient client, Parameters params) throws Exception {	
    Key key = new Key(params.namespace, params.set, "udfkey6");
    String binName = params.getBinName("udfbin6");

    // Create packed blob using standard java tools.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeInt(9845);
    dos.writeUTF("Hello world.");
    byte[] blob = baos.toByteArray();
    
    client.execute(params.writePolicy, key, "record_example", "writeBin", Value.get(binName), Value.get(blob));
    byte[] received = (byte[])client.execute(params.writePolicy, key, "record_example", "readBin", Value.get(binName));

    if (Arrays.equals(blob, received)) {
      console.info("Blob data matched: namespace=%s set=%s key=%s bin=%s value=%s", 
          key.namespace, key.setName, key.userKey, binName, Arrays.toString(received));
    }
    else {
      throw new Exception(String.format(
        "Mismatch: expected=%s received=%s", Arrays.toString(blob), Arrays.toString(received))); 
    }
  }    
}
origin: Playtika/testcontainers-spring-boot

  public void cleanExpiredDocumentsBefore(long expireTimeMillis) {
    long duration = expireTimeMillis - System.currentTimeMillis();
    int expiration = (int) TimeUnit.MILLISECONDS.toSeconds(duration);
    Value value = Value.get(expiration);

    Statement statement = new Statement();
    statement.setNamespace(namespace);

    ExecuteTask executeTask = client.execute(null, statement, PACKAGE_NAME, FUNC_NAME, value);
    executeTask.waitTillComplete(SLEEP_INTERVAL, TIMEOUT);
  }
}
origin: aerospike/aerospike-client-java

client.execute(params.writePolicy, key, "record_example", "writeBin", Value.get(binName), Value.get(list));
Object received = client.execute(params.writePolicy, key, "record_example", "readBin", Value.get(binName));
origin: aerospike/aerospike-client-java

public void onSuccess(final Key key, final Object obj) {
  try {
    // Write succeeded.  Now call read using udf.
    console.info("Get: namespace=%s set=%s key=%s", key.namespace, key.setName, key.userKey);
    client.execute(eventLoop, new ExecuteListener() {
      
      public void onSuccess(final Key key, final Object received) {
        Object expected = bin.value.getObject();    
        if (received != null && received.equals(expected)) {
          console.info("Data matched: namespace=%s set=%s key=%s bin=%s value=%s", 
            key.namespace, key.setName, key.userKey, bin.name, received);
        }
        else {
          console.error("Data mismatch: Expected %s. Received %s.", expected, received);
        }
      }
      
      public void onFailure(AerospikeException e) {
        console.error("Failed to get: namespace=%s set=%s key=%s exception=%s", key.namespace, key.setName, key.userKey, e.getMessage());
      }
      
    }, writePolicy, key, "record_example", "readBin", Value.get(bin.name));
  }
  catch (Exception e) {				
    console.error("Failed to read: namespace=%s set=%s key=%s exception=%s", key.namespace, key.setName, key.userKey, e.getMessage());
  }
}

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

/**
 * Deletes the records specified by the Statement and Qualifiers
 *
 * @param stmt       A Statement object containing Namespace and Set
 * @param qualifiers Zero or more Qualifiers for the update query
 * @return returns a Map containing a number of successful updates. The Map will contain 2 keys "read" and "write", the values will be the count of successful operations
 */
public Map<String, Long> delete(Statement stmt, Qualifier... qualifiers) {
  if (qualifiers == null || qualifiers.length == 0) {
    /*
     * There are no qualifiers, so delete every record in the set
     * using Scan UDF delete
     */
    ExecuteTask task = client.execute(null, stmt, QUERY_MODULE, "delete_record");
    task.waitTillComplete();
    return null;
  }
  if (qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) {
    KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0];
    Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
    this.client.delete(null, key);
    Map<String, Long> map = new HashMap<String, Long>();
    map.put("read", 1L);
    map.put("write", 1L);
    return map;
  }
  KeyRecordIterator results = select(stmt, true, null, qualifiers);
  return delete(results);
}
origin: aerospike/aerospike-client-java

private void writeUsingUdf(AerospikeClient client, Parameters params) throws Exception {	
  Key key = new Key(params.namespace, params.set, "udfkey1");
  Bin bin = new Bin(params.getBinName("udfbin1"), "string value");		
  
  client.execute(params.writePolicy, key, "record_example", "writeBin", Value.get(bin.name), bin.value);
  
  Record record = client.get(params.policy, key, bin.name);
  String expected = bin.value.toString();    
  String received = record.getString(bin.name);
  if (received != null && received.equals(expected)) {
    console.info("Data matched: namespace=%s set=%s key=%s bin=%s value=%s", 
      key.namespace, key.setName, key.userKey, bin.name, received);
  }
  else {
    console.error("Data mismatch: Expected %s. Received %s.", expected, received);
  }
}

origin: aerospike/aerospike-client-java

private void writeWithValidation(AerospikeClient client, Parameters params) throws Exception {
  Key key = new Key(params.namespace, params.set, "udfkey4");
  String binName = "udfbin4";
      
  // Lua function writeWithValidation accepts number between 1 and 10.
  // Write record with valid value.
  console.info("Write with valid value.");
  client.execute(params.writePolicy, key, "record_example", "writeWithValidation", Value.get(binName), Value.get(4));
  // Write record with invalid value.
  console.info("Write with invalid value.");
  
  try {
    client.execute(params.writePolicy, key, "record_example", "writeWithValidation", Value.get(binName), Value.get(11));
    console.error("UDF should not have succeeded!");
  }
  catch (Exception e) {
    console.info("Success. UDF resulted in exception as expected.");
  }
}
origin: aerospike/aerospike-client-java

String value = "appended value";
client.execute(params.writePolicy, key, "record_example", "appendListBin", Value.get(binName), Value.get(value));
origin: aerospike/aerospike-client-java

client.execute(eventLoop, new ExecuteListener() {
origin: aerospike/aerospike-client-java

client.execute(params.writePolicy, key, "record_example", "writeUnique", Value.get(binName), Value.get("first"));
client.execute(params.writePolicy, key, "record_example", "writeUnique", Value.get(binName), Value.get("second"));
origin: aerospike/aerospike-client-java

private void runQueryExecute(
  AerospikeClient client,
  Parameters params,
  String indexName,
  String binName1,
  String binName2
) throws Exception {		
  int begin = 3;
  int end = 9;
  
  console.info("For ns=%s set=%s index=%s bin=%s >= %s <= %s",
    params.namespace, params.set, indexName, binName1, begin, end);            
  console.info("Even integers: add 100 to existing " + binName1);
  console.info("Multiple of 5: delete " + binName2 + " bin");
  console.info("Multiple of 9: delete record");
  
  Statement stmt = new Statement();
  stmt.setNamespace(params.namespace);
  stmt.setSetName(params.set);
  stmt.setFilter(Filter.range(binName1, begin, end));
  
  ExecuteTask task = client.execute(params.writePolicy, stmt, "record_example", "processRecord", Value.get(binName1), Value.get(binName2), Value.get(100));
  task.waitTillComplete();
}
com.aerospike.clientAerospikeClientexecute

Javadoc

Execute user defined function on server and return results. The function operates on a single record. The package name is used to locate the udf file location:

udf file = /.lua

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
  • 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

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • setRequestProperty (URLConnection)
  • Menu (java.awt)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Permission (java.security)
    Legacy security code; do not use.
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • BoxLayout (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