public class LambdaFunction extends Object
There are lambda functions for all types: boolean, int, long, float, double, date and string. Lambda functions must have parameters of all the same type, which will be the same type as the returned Value or ValueStream.
The types of functions that are accepted are: (multi = multi-valued expression, single = single-valued expression)
func(single) -> single
func(multi) -> multi
func(single,single) -> single
func(multi,single) -> multi
func(single,multi) -> multi
func(multi) -> single
func(single,single,...) -> single
(You can also specify whether all parameters must exist, or at least one must exist for the returned value to exist)
NOTE: The combination of name and parameters MUST be unique for an expression.
For example consider if join(fieldA, ',')
and join(fieldA, ';')
are both called. If the JoinFunction uses:
LambdaFunction.createStringLambdaFunction("join", (a,b) -> a + sep + b, (StringValueStream)params[0])
then both the name "join" and single parameter fieldA will be used for two DIFFERENT expressions.
This does not meet the uniqueness requirmenet and will break the query.
A solution to this is to name the function using the missing information:
LambdaFunction.createStringLambdaFunction("join(" + sep + ")", (a,b) -> a + sep + b, (StringValueStream)params[0])
Therefore both expressions will have fieldA as the only parameter, but the names "join(,)"
and "join(;)"
will be different.
This meets the uniqueness requirement for lambda functions.
Constructor and Description |
---|
LambdaFunction() |
Modifier and Type | Method and Description |
---|---|
static BooleanValueStream |
createBooleanLambdaFunction(String name,
LambdaFunction.BoolInBoolOutLambda lambda,
BooleanValueStream param)
Creates a function that takes in either a single or multi valued boolean expression and returns the same type of expression with
the given lambda function applied to every value.
|
static BooleanValue |
createBooleanLambdaFunction(String name,
LambdaFunction.TwoBoolInBoolOutLambda lambda,
BooleanValue[] params)
Forwards the creation of the function to
createBooleanLambdaFunction(String, TwoBoolInBoolOutLambda, BooleanValue[], boolean) ,
using for the last argument (allMustExist ). |
static BooleanValue |
createBooleanLambdaFunction(String name,
LambdaFunction.TwoBoolInBoolOutLambda lambda,
BooleanValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value boolean expressions into a single-value boolean expression for each document.
|
static BooleanValue |
createBooleanLambdaFunction(String name,
LambdaFunction.TwoBoolInBoolOutLambda lambda,
BooleanValueStream param)
Creates a function that takes in a multi-valued boolean expression and returns a single-valued boolean expression.
|
static BooleanValueStream |
createBooleanLambdaFunction(String name,
LambdaFunction.TwoBoolInBoolOutLambda lambda,
BooleanValueStream param1,
BooleanValueStream param2)
Creates a function that maps two booleans to a single boolean.
|
static DateValueStream |
createDateLambdaFunction(String name,
LambdaFunction.LongInLongOutLambda lambda,
DateValueStream param)
Creates a function that takes in either a single or multi valued date expression and returns the same type of expression with
the given lambda function applied to every value.
|
static DateValue |
createDateLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
DateValue[] params)
Forwards the creation of the function to
createDateLambdaFunction(String, TwoLongInLongOutLambda, DateValue[], boolean) ,
using for the last argument (allMustExist ). |
static DateValue |
createDateLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
DateValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value date expressions into a single-value date expression for each document.
|
static DateValue |
createDateLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
DateValueStream param)
Creates a function that takes in a multi-valued date expression and returns a single-valued date expression.
|
static DateValueStream |
createDateLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
DateValueStream param1,
DateValueStream param2)
Creates a function that maps two dates to a single date.
|
static DoubleValueStream |
createDoubleLambdaFunction(String name,
LambdaFunction.DoubleInDoubleOutLambda lambda,
DoubleValueStream param)
Creates a function that takes in either a single or multi valued double expression and returns the same type of expression with
the given lambda function applied to every value.
|
static DoubleValue |
createDoubleLambdaFunction(String name,
LambdaFunction.TwoDoubleInDoubleOutLambda lambda,
DoubleValue[] params)
Forwards the creation of the function to
createDoubleLambdaFunction(String, TwoDoubleInDoubleOutLambda, DoubleValue[], boolean) ,
using for the last argument (allMustExist ). |
static DoubleValue |
createDoubleLambdaFunction(String name,
LambdaFunction.TwoDoubleInDoubleOutLambda lambda,
DoubleValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value double expressions into a single-value double expression for each document.
|
static DoubleValue |
createDoubleLambdaFunction(String name,
LambdaFunction.TwoDoubleInDoubleOutLambda lambda,
DoubleValueStream param)
Creates a function that takes in a multi-valued double expression and returns a single-valued double expression.
|
static DoubleValueStream |
createDoubleLambdaFunction(String name,
LambdaFunction.TwoDoubleInDoubleOutLambda lambda,
DoubleValueStream param1,
DoubleValueStream param2)
Creates a function that maps two doubles to a single double.
|
static FloatValueStream |
createFloatLambdaFunction(String name,
LambdaFunction.FloatInFloatOutLambda lambda,
FloatValueStream param)
Creates a function that takes in either a single or multi valued float expression and returns the same type of expression with
the given lambda function applied to every value.
|
static FloatValue |
createFloatLambdaFunction(String name,
LambdaFunction.TwoFloatInFloatOutLambda lambda,
FloatValue[] params)
Forwards the creation of the function to
createFloatLambdaFunction(String, TwoFloatInFloatOutLambda, FloatValue[], boolean) ,
using for the last argument (allMustExist ). |
static FloatValue |
createFloatLambdaFunction(String name,
LambdaFunction.TwoFloatInFloatOutLambda lambda,
FloatValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value float expressions into a single-value float expression for each document.
|
static FloatValue |
createFloatLambdaFunction(String name,
LambdaFunction.TwoFloatInFloatOutLambda lambda,
FloatValueStream param)
Creates a function that takes in a multi-valued float expression and returns a single-valued float expression.
|
static FloatValueStream |
createFloatLambdaFunction(String name,
LambdaFunction.TwoFloatInFloatOutLambda lambda,
FloatValueStream param1,
FloatValueStream param2)
Creates a function that maps two floats to a single float.
|
static IntValueStream |
createIntLambdaFunction(String name,
LambdaFunction.IntInIntOutLambda lambda,
IntValueStream param)
Creates a function that takes in either a single or multi valued integer expression and returns the same type of expression with
the given lambda function applied to every value.
|
static IntValue |
createIntLambdaFunction(String name,
LambdaFunction.TwoIntInIntOutLambda lambda,
IntValue[] params)
Forwards the creation of the function to
createIntLambdaFunction(String, TwoIntInIntOutLambda, IntValue[], boolean) ,
using for the last argument (allMustExist ). |
static IntValue |
createIntLambdaFunction(String name,
LambdaFunction.TwoIntInIntOutLambda lambda,
IntValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value integer expressions into a single-value integer expression for each document.
|
static IntValue |
createIntLambdaFunction(String name,
LambdaFunction.TwoIntInIntOutLambda lambda,
IntValueStream param)
Creates a function that takes in a multi-valued integer expression and returns a single-valued integer expression.
|
static IntValueStream |
createIntLambdaFunction(String name,
LambdaFunction.TwoIntInIntOutLambda lambda,
IntValueStream param1,
IntValueStream param2)
Creates a function that maps two integers to a single integer.
|
static LongValueStream |
createLongLambdaFunction(String name,
LambdaFunction.LongInLongOutLambda lambda,
LongValueStream param)
Creates a function that takes in either a single or multi valued long expression and returns the same type of expression with
the given lambda function applied to every value.
|
static LongValue |
createLongLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
LongValue[] params)
Forwards the creation of the function to
createLongLambdaFunction(String, TwoLongInLongOutLambda, LongValue[], boolean) ,
using for the last argument (allMustExist ). |
static LongValue |
createLongLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
LongValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value long expressions into a single-value long expression for each document.
|
static LongValue |
createLongLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
LongValueStream param)
Creates a function that takes in a multi-valued long expression and returns a single-valued long expression.
|
static LongValueStream |
createLongLambdaFunction(String name,
LambdaFunction.TwoLongInLongOutLambda lambda,
LongValueStream param1,
LongValueStream param2)
Creates a function that maps two longs to a single long.
|
static StringValueStream |
createStringLambdaFunction(String name,
LambdaFunction.StringInStringOutLambda lambda,
StringValueStream param)
Creates a function that takes in either a single or multi valued string expression and returns the same type of expression with
the given lambda function applied to every value.
|
static StringValue |
createStringLambdaFunction(String name,
LambdaFunction.TwoStringInStringOutLambda lambda,
StringValue[] params)
Forwards the creation of the function to
createStringLambdaFunction(String, TwoStringInStringOutLambda, StringValue[], boolean) ,
using for the last argument (allMustExist ). |
static StringValue |
createStringLambdaFunction(String name,
LambdaFunction.TwoStringInStringOutLambda lambda,
StringValue[] params,
boolean allMustExist)
Creates a function that associatively (order is guaranteed) reduces multiple
single-value string expressions into a single-value string expression for each document.
|
static StringValue |
createStringLambdaFunction(String name,
LambdaFunction.TwoStringInStringOutLambda lambda,
StringValueStream param)
Creates a function that takes in a multi-valued string expression and returns a single-valued string expression.
|
static StringValueStream |
createStringLambdaFunction(String name,
LambdaFunction.TwoStringInStringOutLambda lambda,
StringValueStream param1,
StringValueStream param2)
Creates a function that maps two strings to a single string.
|
public static BooleanValueStream createBooleanLambdaFunction(String name, LambdaFunction.BoolInBoolOutLambda lambda, BooleanValueStream param)
name
- name for the functionlambda
- the function to be applied to every value: (boolean) -> boolean
param
- the expression to apply the lambda topublic static BooleanValue createBooleanLambdaFunction(String name, LambdaFunction.TwoBoolInBoolOutLambda lambda, BooleanValueStream param)
name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
param
- the expression to be reduced per-documentpublic static BooleanValueStream createBooleanLambdaFunction(String name, LambdaFunction.TwoBoolInBoolOutLambda lambda, BooleanValueStream param1, BooleanValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
name
- name for the functionlambda
- the function to be applied to every value: (boolean,boolean) -> boolean
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static BooleanValue createBooleanLambdaFunction(String name, LambdaFunction.TwoBoolInBoolOutLambda lambda, BooleanValue[] params)
createBooleanLambdaFunction(String, TwoBoolInBoolOutLambda, BooleanValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static BooleanValue createBooleanLambdaFunction(String name, LambdaFunction.TwoBoolInBoolOutLambda lambda, BooleanValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reduceallMustExist
- whether all parameters are required to existpublic static IntValueStream createIntLambdaFunction(String name, LambdaFunction.IntInIntOutLambda lambda, IntValueStream param)
name
- name for the functionlambda
- the function to be applied to every value: (integer) -> integer
param
- the expression to apply the lambda topublic static IntValue createIntLambdaFunction(String name, LambdaFunction.TwoIntInIntOutLambda lambda, IntValueStream param)
name
- name for the functionlambda
- the associative function used to reduce the values: (integer, integer) -> integer
param
- the expression to be reduced per-documentpublic static IntValueStream createIntLambdaFunction(String name, LambdaFunction.TwoIntInIntOutLambda lambda, IntValueStream param1, IntValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
name
- name for the functionlambda
- the function to be applied to every value: (integer,integer) -> integer
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static IntValue createIntLambdaFunction(String name, LambdaFunction.TwoIntInIntOutLambda lambda, IntValue[] params)
createIntLambdaFunction(String, TwoIntInIntOutLambda, IntValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static IntValue createIntLambdaFunction(String name, LambdaFunction.TwoIntInIntOutLambda lambda, IntValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.name
- name for the functionlambda
- the associative function used to reduce the values: (integer, integer) -> integer
params
- the expressions to reduceallMustExist
- whether all parameters are required to existpublic static LongValueStream createLongLambdaFunction(String name, LambdaFunction.LongInLongOutLambda lambda, LongValueStream param)
name
- name for the functionlambda
- the function to be applied to every value: (long) -> long
param
- the expression to apply the lambda topublic static LongValue createLongLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, LongValueStream param)
name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
param
- the expression to be reduced per-documentpublic static LongValueStream createLongLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, LongValueStream param1, LongValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
name
- name for the functionlambda
- the function to be applied to every value: (long,long) -> long
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static LongValue createLongLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, LongValue[] params)
createLongLambdaFunction(String, TwoLongInLongOutLambda, LongValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static LongValue createLongLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, LongValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.name
- name for the functionlambda
- the associative function used to reduce the values: (long, long) -> long
params
- the expressions to reduceallMustExist
- whether all parameters are required to existpublic static FloatValueStream createFloatLambdaFunction(String name, LambdaFunction.FloatInFloatOutLambda lambda, FloatValueStream param)
name
- name for the functionlambda
- the function to be applied to every value: (float) -> float
param
- the expression to apply the lambda topublic static FloatValue createFloatLambdaFunction(String name, LambdaFunction.TwoFloatInFloatOutLambda lambda, FloatValueStream param)
name
- name for the functionlambda
- the associative function used to reduce the values: (float, float) -> float
param
- the expression to be reduced per-documentpublic static FloatValueStream createFloatLambdaFunction(String name, LambdaFunction.TwoFloatInFloatOutLambda lambda, FloatValueStream param1, FloatValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
name
- name for the functionlambda
- the function to be applied to every value: (float,float) -> float
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static FloatValue createFloatLambdaFunction(String name, LambdaFunction.TwoFloatInFloatOutLambda lambda, FloatValue[] params)
createFloatLambdaFunction(String, TwoFloatInFloatOutLambda, FloatValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static FloatValue createFloatLambdaFunction(String name, LambdaFunction.TwoFloatInFloatOutLambda lambda, FloatValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.name
- name for the functionlambda
- the associative function used to reduce the values: (float, float) -> float
params
- the expressions to reduceallMustExist
- whether all parameters are required to existpublic static DoubleValueStream createDoubleLambdaFunction(String name, LambdaFunction.DoubleInDoubleOutLambda lambda, DoubleValueStream param)
name
- name for the functionlambda
- the function to be applied to every value: (double) -> double
param
- the expression to apply the lambda topublic static DoubleValue createDoubleLambdaFunction(String name, LambdaFunction.TwoDoubleInDoubleOutLambda lambda, DoubleValueStream param)
name
- name for the functionlambda
- the associative function used to reduce the values: (double, double) -> double
param
- the expression to be reduced per-documentpublic static DoubleValueStream createDoubleLambdaFunction(String name, LambdaFunction.TwoDoubleInDoubleOutLambda lambda, DoubleValueStream param1, DoubleValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
name
- name for the functionlambda
- the function to be applied to every value: (double,double) -> double
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static DoubleValue createDoubleLambdaFunction(String name, LambdaFunction.TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params)
createDoubleLambdaFunction(String, TwoDoubleInDoubleOutLambda, DoubleValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static DoubleValue createDoubleLambdaFunction(String name, LambdaFunction.TwoDoubleInDoubleOutLambda lambda, DoubleValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.name
- name for the functionlambda
- the associative function used to reduce the values: (double, double) -> double
params
- the expressions to reduceallMustExist
- whether all parameters are required to existpublic static DateValueStream createDateLambdaFunction(String name, LambdaFunction.LongInLongOutLambda lambda, DateValueStream param)
NOTE: The lambda must work on longs, not Date objects
name
- name for the functionlambda
- the function to be applied to every value: (long) -> long
param
- the expression to apply the lambda topublic static DateValue createDateLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, DateValueStream param)
NOTE: The lambda must work on longs, not Date objects
name
- name for the functionlambda
- the associative function used to reduce the values: (long, long) -> long
param
- the expression to be reduced per-documentpublic static DateValueStream createDateLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, DateValueStream param1, DateValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
NOTE: The lambda must work on longs, not Date objects
name
- name for the functionlambda
- the function to be applied to every value: (long,long) -> long
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static DateValue createDateLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, DateValue[] params)
createDateLambdaFunction(String, TwoLongInLongOutLambda, DateValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static DateValue createDateLambdaFunction(String name, LambdaFunction.TwoLongInLongOutLambda lambda, DateValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.
NOTE: The lambda must work on longs, not Date objects
name
- name for the functionlambda
- the associative function used to reduce the values: (long, long) -> long
params
- the expressions to reduceallMustExist
- whether all parameters are required to existpublic static StringValueStream createStringLambdaFunction(String name, LambdaFunction.StringInStringOutLambda lambda, StringValueStream param)
name
- name for the functionlambda
- the function to be applied to every value: (String) -> String
param
- the expression to apply the lambda topublic static StringValue createStringLambdaFunction(String name, LambdaFunction.TwoStringInStringOutLambda lambda, StringValueStream param)
name
- name for the functionlambda
- the associative function used to reduce the values: (String, String) -> String
param
- the expression to be reduced per-documentpublic static StringValueStream createStringLambdaFunction(String name, LambdaFunction.TwoStringInStringOutLambda lambda, StringValueStream param1, StringValueStream param2) throws SolrException
func(single,multi)
or func(multi,single)
.
name
- name for the functionlambda
- the function to be applied to every value: (String,String) -> String
param1
- the first parameter in the lambdaparam2
- the second parameter in the lambdaSolrException
- if neither parameter is single-valuedpublic static StringValue createStringLambdaFunction(String name, LambdaFunction.TwoStringInStringOutLambda lambda, StringValue[] params)
createStringLambdaFunction(String, TwoStringInStringOutLambda, StringValue[], boolean)
,
using for the last argument (allMustExist
).name
- name for the functionlambda
- the associative function used to reduce the values: (boolean, boolean) -> boolean
params
- the expressions to reducepublic static StringValue createStringLambdaFunction(String name, LambdaFunction.TwoStringInStringOutLambda lambda, StringValue[] params, boolean allMustExist)
allMustExist
is true.
If allMustExist
is false, only one of the parameters' values must exist.name
- name for the functionlambda
- the associative function used to reduce the values: (String, String) -> String
params
- the expressions to reduceallMustExist
- whether all parameters are required to existCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.