Class CollateFunctionKeyExpression
- java.lang.Object
-
- com.apple.foundationdb.record.metadata.expressions.BaseKeyExpression
-
- com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression
-
- com.apple.foundationdb.record.metadata.expressions.CollateFunctionKeyExpression
-
- All Implemented Interfaces:
AtomKeyExpression
,KeyExpression
,KeyExpressionWithChild
,KeyExpressionWithChildren
,QueryableKeyExpression
,PlanHashable
- Direct Known Subclasses:
CollateFunctionKeyExpressionFactoryJRE.CollateFunctionKeyExpressionJRE
@API(EXPERIMENTAL) public class CollateFunctionKeyExpression extends FunctionKeyExpression implements QueryableKeyExpression
COLLATE
function. Turns a string into a locale-specific sort key.The name of the function is determined by the underlying collation rules chosen. For the Java Platform's own collations, this is
collate_jre
.The function takes the following arguments:
- text field to be collated (mandatory)
- collation to use (optional)
- strength of character matching (optional)
For example,
Key.Expressions.function("collate_jre")
is the default locale (from the JVM) and the default (weakest -- ignoring almost all character modifiers) strength.Key.Expressions.function("collate_jre", Key.Expressions.concat(Key.Expressions.field("text_field"), Key.Expressions.value("fr_CA"), Key.Expressions.value(TextCollator.Strength.SECONDARY)))
is case-insensitive, accent-sensitive, Canadian French.- See Also:
TextCollator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression
FunctionKeyExpression.BiFunctionBuilder, FunctionKeyExpression.Builder, FunctionKeyExpression.Factory, FunctionKeyExpression.Registry
-
Nested classes/interfaces inherited from class com.apple.foundationdb.record.metadata.expressions.BaseKeyExpression
BaseKeyExpression.IllegalSubKeyException, BaseKeyExpression.UnsplittableKeyExpressionException
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.metadata.expressions.KeyExpression
KeyExpression.DeserializationException, KeyExpression.FanType, KeyExpression.InvalidExpressionException, KeyExpression.InvalidResultException, KeyExpression.NoSuchArgumentException, KeyExpression.SerializationException
-
-
Field Summary
-
Fields inherited from class com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression
arguments, name
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CollateFunctionKeyExpression(TextCollatorRegistry collatorRegistry, String name, KeyExpression arguments)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
createsDuplicates()
This states whether the given expression type is capable of evaluating more to more than one value when applied to a single record.<M extends Message>
List<Key.Evaluated>evaluateFunction(FDBRecord<M> record, Message message, Key.Evaluated arguments)
TheevaluateFunction
method implements the function execution.int
getColumnSize()
Returns the number of items in each KeyValue that will be returned.Function<Object,Object>
getComparandConversionFunction()
Get a function to be applied to the comparison operand before comparing it with the application of the key expression to the record.protected static TextCollator
getInvariableCollator(TextCollatorRegistry collatorRegistry, KeyExpression arguments)
int
getMaxArguments()
Get the maximum number of arguments supported by this function.int
getMinArguments()
Get the the minimum number of arguments supported by this function.protected TextCollator
getTextCollator(Key.Evaluated arguments)
Element
toElement(Source rootSource)
-
Methods inherited from class com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression
create, equals, equalsAtomic, evaluateMessage, fromProto, getArguments, getChild, getName, hashCode, normalizeForPlanner, planHash, toKeyExpression, toProto, toString, validate
-
Methods inherited from class com.apple.foundationdb.record.metadata.expressions.BaseKeyExpression
getSubKey, getSubKeyImpl, isPrefixKey
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.metadata.expressions.KeyExpression
evaluate, evaluateMessage, evaluateSingleton, flattenForPlanner, getSubKey, hasProperInterfaces, hasRecordTypeKey, isPrefixKey, normalizeForPlanner, normalizeKeyForPositions, toKeyExpression, toProto, validate, versionColumns
-
Methods inherited from interface com.apple.foundationdb.record.metadata.expressions.KeyExpressionWithChild
getChildren
-
Methods inherited from interface com.apple.foundationdb.record.PlanHashable
planHash
-
Methods inherited from interface com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression
evalForQuery, evalForQueryAsTuple, getName
-
-
-
-
Constructor Detail
-
CollateFunctionKeyExpression
protected CollateFunctionKeyExpression(@Nonnull TextCollatorRegistry collatorRegistry, @Nonnull String name, @Nonnull KeyExpression arguments)
-
-
Method Detail
-
getInvariableCollator
@Nullable protected static TextCollator getInvariableCollator(@Nonnull TextCollatorRegistry collatorRegistry, @Nonnull KeyExpression arguments)
-
getTextCollator
protected TextCollator getTextCollator(@Nonnull Key.Evaluated arguments)
-
getMinArguments
public int getMinArguments()
Description copied from class:FunctionKeyExpression
Get the the minimum number of arguments supported by this function.- Specified by:
getMinArguments
in classFunctionKeyExpression
- Returns:
- the minimum number of arguments supported by this function
-
getMaxArguments
public int getMaxArguments()
Description copied from class:FunctionKeyExpression
Get the maximum number of arguments supported by this function.- Specified by:
getMaxArguments
in classFunctionKeyExpression
- Returns:
- the maximum number of arguments supported by this function
-
evaluateFunction
@Nonnull public <M extends Message> List<Key.Evaluated> evaluateFunction(@Nullable FDBRecord<M> record, @Nullable Message message, @Nonnull Key.Evaluated arguments)
Description copied from class:FunctionKeyExpression
TheevaluateFunction
method implements the function execution. This method is invoked once perKey.Evaluated
that was produced by the evaluation of the function's argument. Put another way, the function's argument expression is evaluated and is expected to produce a set of arguments. This method is invoked once for each of these and, itself, may produce a set ofKey.Evaluated
values that produce the final set of keys.Note that the
record
parameter might benull
. Function implementors should treat this case the same way that they would treat a non-null
record that has all of its non-repeated fields unset and all of its repeated fields empty. If the function result depends only on the value ofarguments
and notrecord
directly, then the implementor can ignore the nullity ofrecord
.- Specified by:
evaluateFunction
in classFunctionKeyExpression
- Type Parameters:
M
- the type of the records- Parameters:
record
- the record against which this function will produce a keymessage
- the Protobuf message against which this function will produce a keyarguments
- the set of arguments to be applied by the function against therecord
- Returns:
- the list of keys for the given record
-
createsDuplicates
public boolean createsDuplicates()
Description copied from interface:KeyExpression
This states whether the given expression type is capable of evaluating more to more than one value when applied to a single record. In practice, this can happen if this expression is evaluated on a repeated field withFanType.FanOut
set (either directly or indirectly).- Specified by:
createsDuplicates
in interfaceKeyExpression
- Returns:
true
if this expression can evaluate to multiple values andfalse
otherwise
-
getColumnSize
public int getColumnSize()
Description copied from interface:KeyExpression
Returns the number of items in each KeyValue that will be returned. For key expressions that supportKeyExpression.FanType.Concatenate
, this will the count of non-nested lists, i.e. this will be value of evaluate(r).get(i).toList().size() for any i or r.- Specified by:
getColumnSize
in interfaceKeyExpression
- Returns:
- the number of elements that will be produced for every key
-
toElement
@Nonnull public Element toElement(@Nonnull Source rootSource)
- Specified by:
toElement
in interfaceQueryableKeyExpression
-
getComparandConversionFunction
@Nullable public Function<Object,Object> getComparandConversionFunction()
Description copied from interface:QueryableKeyExpression
Get a function to be applied to the comparison operand before comparing it with the application of the key expression to the record.- Specified by:
getComparandConversionFunction
in interfaceQueryableKeyExpression
- Returns:
- a conversion function or
null
for no conversion
-
-