Class TestAndSetCondition
The TestAndSetCondition class represents a test and set condition. A test and set condition is an (optional) string representing a document selection (cf. document selection language), which is used to match a document for test and set.
If #isPresent evaluates to false, the condition is not present and matches any document.
- Author:
- Vegard Sjonfjell, vekterli
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
static TestAndSetCondition
fromConditionString
(Optional<String> conditionString) Maps and optional test and set condition string to a TestAndSetCondition.int
hashCode()
boolean
static TestAndSetCondition
ofRequiredTimestamp
(long requiredTimestamp) Returns a TestAndSetCondition that requires the currently persisted document in the backend to have a timestamp exactly matching the provided timestamp value.static TestAndSetCondition
ofRequiredTimestampWithSelectionFallback
(long requiredTimestamp, String selectionFallback) Returns a TestAndSetCondition with a required timestamp, but which has a transparent fallback to evaluating a selection string if the backend does not support timestamp conditions.long
Returns the timestamp that the document stored in the backend must match exactly for the associated document operation to go through, or 0 if no timestamp requirement is present (i.e. only the selection condition, if present, is checked).toString()
-
Field Details
-
NOT_PRESENT_CONDITION
-
-
Constructor Details
-
TestAndSetCondition
public TestAndSetCondition() -
TestAndSetCondition
-
-
Method Details
-
getSelection
-
requiredTimestamp
public long requiredTimestamp()Returns the timestamp that the document stored in the backend must match exactly for the associated document operation to go through, or 0 if no timestamp requirement is present (i.e. only the selection condition, if present, is checked).
Note: the timestamp should be compared with Long.compareUnsigned(), as it reflects an unsigned 64-bit integer in the backend.
Note: this API is currently in Beta.
-
isPresent
public boolean isPresent() -
fromConditionString
Maps and optional test and set condition string to a TestAndSetCondition. If the condition string is not present, a "not present" condition is returned- Parameters:
conditionString
- test and set condition string (document selection)- Returns:
- a TestAndSetCondition representing the condition string or a "not present" condition
-
ofRequiredTimestampWithSelectionFallback
public static TestAndSetCondition ofRequiredTimestampWithSelectionFallback(long requiredTimestamp, String selectionFallback) Returns a TestAndSetCondition with a required timestamp, but which has a transparent fallback to evaluating a selection string if the backend does not support timestamp conditions. This has the following semantics:
- If the backend supports test and set conditions with timestamp requirements, the condition passes iff the currently persisted timestamp exactly matches the timestamp in the condition. The selection condition string is completely ignored in this case.
- If the backend is too old to support timestamp requirements the condition selection string is evaluated as if there was no required timestamp present.
Note: this API is currently in Beta.
- Parameters:
requiredTimestamp
- required timestamp, or 0 for no timestamp requirement.selectionFallback
- condition selection string that will be evaluated by nodes that are on a version too old to support timestamp requirements.
-
ofRequiredTimestamp
Returns a TestAndSetCondition that requires the currently persisted document in the backend to have a timestamp exactly matching the provided timestamp value.
Version compatibility note: older versions of Vespa that do not support timestamp requirements as part of test and set conditions will observe a condition with only a timestamp set as if the condition is empty, i.e. the operation will be applied unconditionally.
Note: this API is currently in Beta
- Parameters:
requiredTimestamp
- An (unsigned) timestamp corresponding exactly to the persisted backend timestamp of the document to update.
-
equals
-
hashCode
public int hashCode() -
toString
-