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
condto avoid run time evaluation errors:// If bin "a" is an integer, return true if the value of "a" is > 1, otherwise return falseExp.cond(Exp.eq( // check if the bin is of type intExp.binType("a"),Exp.val(ParticleType.INTEGER)),Exp.eq( // perform int comparisonExp.intBin("a"),Exp.val(1)),Exp.val(false)); // default is falseexp.Cond(exp.Eq( # check if the bin is of type intexp.BinType("a"),aerospike.AS_BYTES_INTEGER),exp.Eq( # perform int comparisonexp.IntBin("a"), 1),False) # default is falseas.ExpCond(as.ExpEq( // check if the bin is of type int (ParticleType.INTEGER == 1)as.ExpBinType("a"),as.ExpIntVal(1)),as.ExpEq( // perform int comparisonas.ExpIntBin("a"), as.ExpIntVal(1)),as.ExpBoolVal(false)) // default is falseExp.Cond(Exp.EQ( // check if the bin is of type int (ParticleType.INTEGER == 1)Exp.BinType("a"),Exp.Val(1)),Exp.EQ( // perform int comparisonExp.IntBin("a"), Exp.Val(1)),Exp.Val(false)); // default is falseexp.cond(exp.eq( // check if the bin is of type int (ParticleType.INTEGER == 1)exp.binType('a'),exp.int(1)),exp.eq( // perform int comparisonexp.binInt('a'), exp.int(1)),exp.bool(false)) // default is falsecond(vec![eq( // check if the bin is of type int (ParticleType.INTEGER == 1)bin_type("a".to_string()),int_val(ParticleType::INTEGER as i64)),eq( // perform int comparisonint_bin("a".to_string()), int_val(1)),bool_val(false), // default is false])
-
-
All branches of a
condexpression must evaluate to the same type, otherwise the condition will always fail. -
condexpressions must always have a default value. This can beunknownwhich 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
operateoperations by setting the flags argument inExpOperation.reador.writetoExpReadFlags.EVAL_NO_FAILorExpWriteFlags.EVAL_NO_FAILrespectively.
-
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.
truncate_test_data()client.close()print("Removed tutorial data and closed server connection.")Output:
Removed tutorial data and closed server connection.
truncateTestData()client.Close()fmt.Println("Removed tutorial data and closed server connection.")Output:
Removed tutorial data and closed server connection.
TruncateTestData();client.Close();Console.WriteLine("Removed tutorial data and closed server connection.");Output:
Removed tutorial data and closed server connection.
await truncateTestData();await client.close();console.log('Removed tutorial data and closed server connection.');Output:
Removed tutorial data and closed server connection.
truncate_test_data(&client).await;client.close().await?;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.