Search in sources :

Example 16 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class ViewTest method shouldConcatGlobalPreAggFiltersWhenSpecificGroupPreAggFiltersSet.

@Test
public void shouldConcatGlobalPreAggFiltersWhenSpecificGroupPreAggFiltersSet() {
    // Given
    final ElementFilter globalFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build();
    final ElementFilter groupFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new ExampleFilterFunction()).build();
    final View view = new View.Builder().globalEntities(new GlobalViewElementDefinition.Builder().groups(TestGroups.ENTITY).preAggregationFilter(globalFilter).build()).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(groupFilter).build()).build();
    // When
    view.expandGlobalDefinitions();
    // Then
    assertTrue(view.hasPreAggregationFilters());
    assertEquals(Exists.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPreAggregationFilter().getComponents().get(0).getPredicate().getClass().getSimpleName());
    assertEquals(ExampleFilterFunction.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPreAggregationFilter().getComponents().get(1).getPredicate().getClass().getSimpleName());
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ExampleFilterFunction(uk.gov.gchq.gaffer.function.ExampleFilterFunction) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 17 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class ViewUtilTest method shouldReturnTrueWhenViewHasPreAggEdgeFilters.

@Test
public void shouldReturnTrueWhenViewHasPreAggEdgeFilters() {
    final View view = new View.Builder().entity(TestGroups.ENTITY).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).edge(TestGroups.EDGE_2, null).build();
    final boolean result = view.hasPreAggregationFilters();
    assertTrue(result);
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Test(org.junit.jupiter.api.Test)

Example 18 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class GetWalksIT method shouldGetPathsWithWhile.

@Test
public void shouldGetPathsWithWhile() throws Exception {
    // Given
    final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
    final GetWalks op = new Builder().input(seedA).operations(new While.Builder<>().conditional(new Conditional(// This will always be true
    new Exists(), new Map.Builder<>().first(new AssertEntityIdsUnwrapped()).build())).operation(operation).maxRepeats(2).build()).build();
    // When
    final Iterable<Walk> results = graph.execute(op, getUser());
    // Then
    assertThat(getPaths(results)).isEqualTo("AED,ABC");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) HashMap(java.util.HashMap) Map(uk.gov.gchq.gaffer.operation.impl.Map) Test(org.junit.Test)

Example 19 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project gaffer-doc by gchq.

the class NotExample method doesNotExist.

public void doesNotExist() {
    // ---------------------------------------------------------
    final Not function = new Not<>(new Exists());
    // ---------------------------------------------------------
    runExample(function, null, 1, null, "", "abc");
}
Also used : Not(uk.gov.gchq.koryphe.impl.predicate.Not) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists)

Example 20 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class AddOperationsToChainTest method shouldAddIfOperation.

@Test
public void shouldAddIfOperation() throws SerialisationException {
    // Given
    final GetWalks getWalks = new GetWalks();
    final uk.gov.gchq.gaffer.operation.impl.Map map = new uk.gov.gchq.gaffer.operation.impl.Map();
    final ToVertices toVertices = new ToVertices();
    final ToSet toSet = new ToSet();
    final Exists exists = new Exists();
    final Limit limit = new Limit();
    final GetAllElements getAllElements = new GetAllElements();
    final GetElements getElements = new GetElements();
    final Conditional conditional = new Conditional();
    conditional.setPredicate(exists);
    final If ifOp = new If.Builder<>().conditional(conditional).then(getElements).otherwise(getAllElements).build();
    final AddOperationsToChain hook = new AddOperationsToChain();
    final Map<String, List<Operation>> after = new HashMap<>();
    final List<Operation> afterOps = new LinkedList<>();
    afterOps.add(ifOp);
    afterOps.add(limit);
    after.put("uk.gov.gchq.gaffer.operation.impl.output.ToSet", afterOps);
    hook.setAfter(after);
    final OperationChain opChain = new OperationChain.Builder().first(getWalks).then(map).then(toVertices).then(toSet).build();
    // When
    hook.preExecute(opChain, new Context());
    // Then
    final OperationChain expectedOpChain = new OperationChain.Builder().first(getWalks).then(map).then(toVertices).then(toSet).then(ifOp).then(limit).build();
    JsonAssert.assertEquals(JSONSerialiser.serialise(expectedOpChain), JSONSerialiser.serialise(opChain));
}
Also used : HashMap(java.util.HashMap) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) Operation(uk.gov.gchq.gaffer.operation.Operation) ToSet(uk.gov.gchq.gaffer.operation.impl.output.ToSet) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) LinkedList(java.util.LinkedList) List(java.util.List) Context(uk.gov.gchq.gaffer.store.Context) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) LinkedList(java.util.LinkedList) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Limit(uk.gov.gchq.gaffer.operation.impl.Limit) HashMap(java.util.HashMap) Map(java.util.Map) If(uk.gov.gchq.gaffer.operation.impl.If) Test(org.junit.jupiter.api.Test)

Aggregations

Exists (uk.gov.gchq.koryphe.impl.predicate.Exists)38 Test (org.junit.jupiter.api.Test)31 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)12 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)9 Schema (uk.gov.gchq.gaffer.store.schema.Schema)9 AccumuloStore (uk.gov.gchq.gaffer.accumulostore.AccumuloStore)8 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)6 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)6 HashMap (java.util.HashMap)5 Map (java.util.Map)3 MiniAccumuloStore (uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore)3 SingleUseMiniAccumuloStore (uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore)3 AccumuloElementConverter (uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter)3 AccumuloKeyPackage (uk.gov.gchq.gaffer.accumulostore.key.AccumuloKeyPackage)3 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)3 ExampleFilterFunction (uk.gov.gchq.gaffer.function.ExampleFilterFunction)3 Operation (uk.gov.gchq.gaffer.operation.Operation)3 StringConcat (uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat)3 Date (java.util.Date)2 List (java.util.List)2