This tutorial uses the following Java classes, which can be found in org.apache.accumulo.examples.constraints:
- AlphaNumKeyConstraint.java - a constraint that requires alphanumeric keys
- NumericValueConstraint.java - a constraint that requires numeric string values
- MaxMutationSize.java - a constraint that limits the size of mutations accepted into a table
AlphaNumKeyConstraint prevents insertion of keys with characters not between aA and zZ or 0 to 9.
NumericValueConstraint prevents insertion of values with characters not between 0 and 9. The examples create mutations
that violate the constraint, throwing an exception.
$ ./bin/runex constraints.AlphaNumKeyConstraint
$ ./bin/runex constraints.NumericValueConstraint
The MaxMutationSize constraint will force the table to reject any mutation that is larger than 1/256th of the working memory of the tablet server. The following example attempts to ingest a single row with a million columns, which exceeds the memory limit. Depending on the amount of Java heap your tserver(s) are given, you may have to increase the number of columns provided to see the failure.
$ ./bin/runex constraints.MaxMutationSize