FunctionChain
See javadoc - uk.gov.gchq.koryphe.impl.function.FunctionChain
Available since Koryphe version 1.8.0
Applies the given functions consecutively
Examples
Function chain using tuple adapted functions
Java
JSON
Full JSON
Python
final FunctionChain function = new FunctionChain.Builder<>()
.execute(new Integer[]{0}, new ToUpperCase(), new Integer[]{1})
.execute(new Integer[]{1}, new ToSet(), new Integer[]{2})
.build();
{
"class" : "FunctionChain",
"functions" : [ {
"class" : "TupleAdaptedFunction",
"selection" : [ 0 ],
"function" : {
"class" : "ToUpperCase"
},
"projection" : [ 1 ]
}, {
"class" : "TupleAdaptedFunction",
"selection" : [ 1 ],
"function" : {
"class" : "uk.gov.gchq.koryphe.impl.function.ToSet"
},
"projection" : [ 2 ]
} ]
}
{
"class" : "uk.gov.gchq.koryphe.impl.function.FunctionChain",
"functions" : [ {
"class" : "uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunction",
"selection" : [ 0 ],
"function" : {
"class" : "uk.gov.gchq.koryphe.impl.function.ToUpperCase"
},
"projection" : [ 1 ]
}, {
"class" : "uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunction",
"selection" : [ 1 ],
"function" : {
"class" : "uk.gov.gchq.koryphe.impl.function.ToSet"
},
"projection" : [ 2 ]
} ]
}
g.FunctionChain(
functions=[
g.TupleAdaptedFunction(
selection=[
0
],
function=g.ToUpperCase(),
projection=[
1
]
),
g.TupleAdaptedFunction(
selection=[
1
],
function=g.ToSet(),
projection=[
2
]
)
]
)
Input type:
java.lang.Object
Example inputs:
Input Type | Input | Result Type | Result |
---|---|---|---|
[java.lang.String, ,] | [someString, null, null] | [java.lang.String, java.lang.String, java.util.HashSet] | [someString, SOMESTRING, [SOMESTRING]] |
[java.lang.String, ,] | [SOMESTRING, null, null] | [java.lang.String, java.lang.String, java.util.HashSet] | [SOMESTRING, SOMESTRING, [SOMESTRING]] |
[java.lang.String, ,] | [somestring, null, null] | [java.lang.String, java.lang.String, java.util.HashSet] | [somestring, SOMESTRING, [SOMESTRING]] |
[java.lang.String, ,] | [@£$%, null, null] | [java.lang.String, java.lang.String, java.util.HashSet] | [@£$%, @£$%, [@£$%]] |
[java.lang.String, ,] | [1234, null, null] | [java.lang.String, java.lang.String, java.util.HashSet] | [1234, 1234, [1234]] |
[java.lang.String, ,] | [, null, null] | [java.lang.String, java.lang.String, java.util.HashSet] | [, , []] |
[ , ,] | [null, null, null] | [ , ,java.util.HashSet] | [null, null, [null]] |
[java.lang.Integer, ,] | [1234, null, null] | [java.lang.Integer, java.lang.String, java.util.HashSet] | [1234, 1234, [1234]] |
Function chain using standard functions
Java
JSON
Full JSON
Python
final FunctionChain function = new FunctionChain.Builder<>()
.execute(new ToLowerCase())
.execute(new ToTypeSubTypeValue())
.execute(new ToEntityId())
.build();
{
"class" : "FunctionChain",
"functions" : [ {
"class" : "ToLowerCase"
}, {
"class" : "ToTypeSubTypeValue"
}, {
"class" : "ToEntityId"
} ]
}
{
"class" : "uk.gov.gchq.koryphe.impl.function.FunctionChain",
"functions" : [ {
"class" : "uk.gov.gchq.koryphe.impl.function.ToLowerCase"
}, {
"class" : "uk.gov.gchq.gaffer.types.function.ToTypeSubTypeValue"
}, {
"class" : "uk.gov.gchq.gaffer.operation.function.ToEntityId"
} ]
}
g.FunctionChain(
functions=[
g.ToLowerCase(),
g.ToTypeSubTypeValue(),
g.ToEntityId()
]
)
Input type:
java.lang.Object
Example inputs:
Input Type | Input | Result Type | Result |
---|---|---|---|
java.lang.String | a string | uk.gov.gchq.gaffer.operation.data.EntitySeed | EntitySeed[vertex=TypeSubTypeValue[value=a string]] |
java.lang.String | UPPER | uk.gov.gchq.gaffer.operation.data.EntitySeed | EntitySeed[vertex=TypeSubTypeValue[value=upper]] |
null | uk.gov.gchq.gaffer.operation.data.EntitySeed | EntitySeed[vertex=TypeSubTypeValue[]] | |
java.lang.Integer | 12 | uk.gov.gchq.gaffer.operation.data.EntitySeed | EntitySeed[vertex=TypeSubTypeValue[value=12]] |