Package com.apple.foundationdb
Enum MutationType
- java.lang.Object
-
- java.lang.Enum<MutationType>
-
- com.apple.foundationdb.MutationType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<MutationType>
public enum MutationType extends java.lang.Enum<MutationType>
A set of operations that can be performed atomically on a database. These are used as parameters toTransaction.mutate(MutationType, byte[], byte[])
.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ADD
Performs an addition of little-endian integers.AND
Deprecated.APPEND_IF_FITS
Appendsparam
to the end of the existing value already in the database at the given key (or creates the key and sets the value toparam
if the key is empty).BIT_AND
Performs a bitwiseand
operation.BIT_OR
Performs a bitwiseor
operation.BIT_XOR
Performs a bitwisexor
operation.BYTE_MAX
Performs lexicographic comparison of byte strings.BYTE_MIN
Performs lexicographic comparison of byte strings.COMPARE_AND_CLEAR
Performs an atomiccompare and clear
operation.MAX
Performs a little-endian comparison of byte strings.MIN
Performs a little-endian comparison of byte strings.OR
Deprecated.SET_VERSIONSTAMPED_KEY
Transformskey
using a versionstamp for the transaction.SET_VERSIONSTAMPED_VALUE
Transformsparam
using a versionstamp for the transaction.XOR
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
code()
Gets the FoundationDB native-level constant code for aMutationType
.static MutationType
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static MutationType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ADD
public static final MutationType ADD
Performs an addition of little-endian integers. If the existing value in the database is not present or shorter thanparam
, it is first extended to the length ofparam
with zero bytes. Ifparam
is shorter than the existing value in the database, the existing value is truncated to match the length ofparam
. The integers to be added must be stored in a little-endian representation. They can be signed in two's complement representation or unsigned. You can add to an integer at a known offset in the value by prepending the appropriate number of zero bytes toparam
and padding with zero bytes to match the length of the value. However, this offset technique requires that you know the addition will not cause the integer field within the value to overflow.
-
AND
@Deprecated public static final MutationType AND
Deprecated.Deprecated.
-
BIT_AND
public static final MutationType BIT_AND
Performs a bitwiseand
operation. If the existing value in the database is not present, thenparam
is stored in the database. If the existing value in the database is shorter thanparam
, it is first extended to the length ofparam
with zero bytes. Ifparam
is shorter than the existing value in the database, the existing value is truncated to match the length ofparam
.
-
OR
@Deprecated public static final MutationType OR
Deprecated.Deprecated.
-
BIT_OR
public static final MutationType BIT_OR
Performs a bitwiseor
operation. If the existing value in the database is not present or shorter thanparam
, it is first extended to the length ofparam
with zero bytes. Ifparam
is shorter than the existing value in the database, the existing value is truncated to match the length ofparam
.
-
XOR
@Deprecated public static final MutationType XOR
Deprecated.Deprecated.
-
BIT_XOR
public static final MutationType BIT_XOR
Performs a bitwisexor
operation. If the existing value in the database is not present or shorter thanparam
, it is first extended to the length ofparam
with zero bytes. Ifparam
is shorter than the existing value in the database, the existing value is truncated to match the length ofparam
.
-
APPEND_IF_FITS
public static final MutationType APPEND_IF_FITS
Appendsparam
to the end of the existing value already in the database at the given key (or creates the key and sets the value toparam
if the key is empty). This will only append the value if the final concatenated value size is less than or equal to the maximum value size (i.e., if it fits). WARNING: No error is surfaced back to the user if the final value is too large because the mutation will not be applied until after the transaction has been committed. Therefore, it is only safe to use this mutation type if one can guarantee that one will keep the total value size under the maximum size.
-
MAX
public static final MutationType MAX
Performs a little-endian comparison of byte strings. If the existing value in the database is not present or shorter thanparam
, it is first extended to the length ofparam
with zero bytes. Ifparam
is shorter than the existing value in the database, the existing value is truncated to match the length ofparam
. The larger of the two values is then stored in the database.
-
MIN
public static final MutationType MIN
Performs a little-endian comparison of byte strings. If the existing value in the database is not present, thenparam
is stored in the database. If the existing value in the database is shorter thanparam
, it is first extended to the length ofparam
with zero bytes. Ifparam
is shorter than the existing value in the database, the existing value is truncated to match the length ofparam
. The smaller of the two values is then stored in the database.
-
SET_VERSIONSTAMPED_KEY
public static final MutationType SET_VERSIONSTAMPED_KEY
Transformskey
using a versionstamp for the transaction. Sets the transformed key in the database toparam
. The key is transformed by removing the final four bytes from the key and reading those as a little-Endian 32-bit integer to get a positionpos
. The 10 bytes of the key frompos
topos + 10
are replaced with the versionstamp of the transaction used. The first byte of the key is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java, Python, and Go bindings. Also, note that prior to API version 520, the offset was computed from only the final two bytes rather than the final four bytes.
-
SET_VERSIONSTAMPED_VALUE
public static final MutationType SET_VERSIONSTAMPED_VALUE
Transformsparam
using a versionstamp for the transaction. Sets thekey
given to the transformedparam
. The parameter is transformed by removing the final four bytes fromparam
and reading those as a little-Endian 32-bit integer to get a positionpos
. The 10 bytes of the parameter frompos
topos + 10
are replaced with the versionstamp of the transaction used. The first byte of the parameter is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java, Python, and Go bindings. Also, note that prior to API version 520, the versionstamp was always placed at the beginning of the parameter rather than computing an offset.
-
BYTE_MIN
public static final MutationType BYTE_MIN
Performs lexicographic comparison of byte strings. If the existing value in the database is not present, thenparam
is stored. Otherwise the smaller of the two values is then stored in the database.
-
BYTE_MAX
public static final MutationType BYTE_MAX
Performs lexicographic comparison of byte strings. If the existing value in the database is not present, thenparam
is stored. Otherwise the larger of the two values is then stored in the database.
-
COMPARE_AND_CLEAR
public static final MutationType COMPARE_AND_CLEAR
Performs an atomiccompare and clear
operation. If the existing value in the database is equal to the given value, then given key is cleared.
-
-
Method Detail
-
values
public static MutationType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MutationType c : MutationType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MutationType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
code
public int code()
Gets the FoundationDB native-level constant code for aMutationType
.- Returns:
- the native code for a FoundationDB
MutationType
constant.
-
-