Search in sources :

Example 1 with Length

use of uk.gov.gchq.koryphe.impl.function.Length in project gaffer-doc by gchq.

the class LengthExample method getLength.

public void getLength() {
    // ---------------------------------------------------------
    final Length function = new Length();
    // ---------------------------------------------------------
    runExample(function, null, Lists.newArrayList(new Entity.Builder().group("entity").vertex("1").build(), new Entity.Builder().group("entity").vertex("2").build(), new Entity.Builder().group("entity").vertex("3").build(), new Entity.Builder().group("entity").vertex("4").build(), new Entity.Builder().group("entity").vertex("5").build()), new GetAllElements.Builder().option("option1", "value1").option("option2", "value2").option("option3", "value3").build().getOptions(), new Walk.Builder().edge(new Edge.Builder().group("BasicEdge").source("A").dest("B").directed(true).build()).edges(new Edge.Builder().group("BasicEdge").source("B").dest("C").directed(true).build(), new Edge.Builder().group("EnhancedEdge").source("B").dest("C").directed(true).build()).edge(new Edge.Builder().group("BasicEdge").source("C").dest("A").directed(true).build()).edge(new Edge.Builder().group("BasicEdge").source("A").dest("E").directed(true).build()).build(), 5, "some string", new String[] { "1", "2" }, null);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Length(uk.gov.gchq.koryphe.impl.function.Length) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 2 with Length

use of uk.gov.gchq.koryphe.impl.function.Length in project Gaffer by gchq.

the class TypeValueToTupleTest method shouldGetAndSetUsingCompositeFunction.

@Test
public void shouldGetAndSetUsingCompositeFunction() {
    // Given
    final TypeValue typeValue = new TypeValue("type", "value");
    final Function<Object, Object> compositeFunction = new FunctionComposite(Lists.newArrayList(new TypeValueToTuple(), new TupleAdaptedFunctionComposite.Builder().select(new String[] { "value" }).execute(new FunctionComposite(Arrays.asList(new Length(), new ToString()))).project(new String[] { "type" }).build()));
    // When
    compositeFunction.apply(typeValue);
    // Then
    assertEquals(new TypeValue("5", "value"), typeValue);
}
Also used : Length(uk.gov.gchq.koryphe.impl.function.Length) TypeValue(uk.gov.gchq.gaffer.types.TypeValue) ToString(uk.gov.gchq.koryphe.impl.function.ToString) ToString(uk.gov.gchq.koryphe.impl.function.ToString) TupleAdaptedFunctionComposite(uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite) FunctionComposite(uk.gov.gchq.koryphe.function.FunctionComposite) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest) Test(org.junit.jupiter.api.Test)

Example 3 with Length

use of uk.gov.gchq.koryphe.impl.function.Length in project Gaffer by gchq.

the class TypeSubTypeValueToTupleTest method shouldGetAndSetUsingCompositeFunction.

@Test
public void shouldGetAndSetUsingCompositeFunction() {
    // Given
    final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue("type", "subType", "value");
    final Function<Object, Object> compositeFunction = new FunctionComposite(Lists.newArrayList(new TypeSubTypeValueToTuple(), new TupleAdaptedFunctionComposite.Builder().select(new String[] { "value" }).execute(new FunctionComposite(Arrays.asList(new Length(), new ToString()))).project(new String[] { "type" }).build()));
    // When
    compositeFunction.apply(typeSubTypeValue);
    // Then
    assertEquals(new TypeSubTypeValue("5", "subType", "value"), typeSubTypeValue);
}
Also used : Length(uk.gov.gchq.koryphe.impl.function.Length) TypeSubTypeValue(uk.gov.gchq.gaffer.types.TypeSubTypeValue) ToString(uk.gov.gchq.koryphe.impl.function.ToString) ToString(uk.gov.gchq.koryphe.impl.function.ToString) TupleAdaptedFunctionComposite(uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite) FunctionComposite(uk.gov.gchq.koryphe.function.FunctionComposite) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest) Test(org.junit.jupiter.api.Test)

Aggregations

Length (uk.gov.gchq.koryphe.impl.function.Length)3 Test (org.junit.jupiter.api.Test)2 FunctionComposite (uk.gov.gchq.koryphe.function.FunctionComposite)2 FunctionTest (uk.gov.gchq.koryphe.function.FunctionTest)2 ToString (uk.gov.gchq.koryphe.impl.function.ToString)2 TupleAdaptedFunctionComposite (uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite)2 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 TypeSubTypeValue (uk.gov.gchq.gaffer.types.TypeSubTypeValue)1 TypeValue (uk.gov.gchq.gaffer.types.TypeValue)1