Skip to content

Usage notes and next steps

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Usage notes

  • Errors during evaluation:

    • Errors such as type match and bin existence can be checked using cond to avoid run time evaluation errors:

      // If bin "a" is an integer, return true if the value of "a" is > 1, otherwise return false
      Exp.cond(
      Exp.eq( // check if the bin is of type int
      Exp.binType("a"),
      Exp.val(ParticleType.INTEGER)),
      Exp.eq( // perform int comparison
      Exp.intBin("a"),
      Exp.val(1)),
      Exp.val(false)); // default is false
  • All branches of a cond expression must evaluate to the same type, otherwise the condition will always fail.

  • cond expressions must always have a default value. This can be unknown which matches every type.

    • Filter expressions treat the final unknown value as false, whereas in operation expressions it results in an error.
    • If appropriate, evaluation failure can be ignored while performing multiple operate operations by setting the flags argument in ExpOperation.read or .write to ExpReadFlags.EVAL_NO_FAIL or ExpWriteFlags.EVAL_NO_FAIL respectively.
  • Constructs like loops and iterators over record bins or CDT elements are not currently supported. General manipulation of data beyond what is available in the APIs also is not supported.

Takeaways and conclusion

The tutorial described expressions capabilities in Aerospike. It explained the scope and syntax, and described the key components and constructs. It provided code examples for how to work with expressions in two client uses: filter expressions and operation expressions.

The enhanced capabilities in filtering expressions allow records to be processed more efficiently by avoiding the need for more expensive client or UDF based processing. New capabilities include access to metadata, bin data, powerful APIs, as well as enhanced arithmetic and other operators.

Operation expressions can eliminate the need to read before update by allowing read, processing for update, and update to happen on the server side in the same request. This saves a round-trip and transfer of potentially large data.

Expressions provide powerful capabilities; evaluate and use them if they are suitable and provide better performance for your use case over UDFs and client-side processing.

Cleaning up

Remove tutorial data and close connection.

truncateTestData();
client.close();
System.out.println("Removed tutorial data and closed server connection.");

Output:

Removed tutorial data and closed server connection.

Further exploration and resources

Here are some links for further exploration.

Resources