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( 
      projection=[ 
        1 
      ], 
      function=g.ToUpperCase(), 
      selection=[ 
        0 
      ] 
    ), 
    g.TupleAdaptedFunction( 
      projection=[ 
        2 
      ], 
      function=g.ToSet(), 
      selection=[ 
        1 
      ] 
    ) 
  ] 
)

Input type:

uk.gov.gchq.koryphe.signature.Signature$UnknownGenericType

Example inputs:

Input TypeInputResult TypeResult
[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:

uk.gov.gchq.koryphe.signature.Signature$UnknownGenericType

Example inputs:

Input TypeInputResult TypeResult
java.lang.Stringa stringuk.gov.gchq.gaffer.operation.data.EntitySeedEntitySeed[vertex=TypeSubTypeValue[value=a string]]
java.lang.StringUPPERuk.gov.gchq.gaffer.operation.data.EntitySeedEntitySeed[vertex=TypeSubTypeValue[value=upper]]
nulluk.gov.gchq.gaffer.operation.data.EntitySeedEntitySeed[vertex=TypeSubTypeValue[]]
java.lang.Integer12uk.gov.gchq.gaffer.operation.data.EntitySeedEntitySeed[vertex=TypeSubTypeValue[value=12]]

results matching ""

    No results matching ""