Search in sources :

Example 11 with IsLessThan

use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.

the class AndExample method isLessThan3AndIsMoreThan0.

public void isLessThan3AndIsMoreThan0() {
    // ---------------------------------------------------------
    final And function = new And(Arrays.asList(new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select first property
    0).execute(new IsLessThan(3)).build(), new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select first property
    0).execute(new IsMoreThan(0)).build()));
    // ---------------------------------------------------------
    runExample(function, new Object[] { 0 }, new Object[] { 1 }, new Object[] { 2 }, new Object[] { 3 }, new Object[] { 1L }, new Object[] { 2L });
}
Also used : FilterFunction(uk.gov.gchq.gaffer.function.FilterFunction) ConsumerFunctionContext(uk.gov.gchq.gaffer.function.context.ConsumerFunctionContext) IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan) And(uk.gov.gchq.gaffer.function.filter.And) IsMoreThan(uk.gov.gchq.gaffer.function.filter.IsMoreThan)

Example 12 with IsLessThan

use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.

the class AndExample method property1IsLessThan2AndProperty2IsMoreThan2.

public void property1IsLessThan2AndProperty2IsMoreThan2() {
    // ---------------------------------------------------------
    final And function = new And(Arrays.asList(new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select first property
    0).execute(new IsLessThan(2)).build(), new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select second property
    1).execute(new IsMoreThan(2)).build()));
    // ---------------------------------------------------------
    runExample(function, new Object[] { 1, 3 }, new Object[] { 1, 1 }, new Object[] { 3, 3 }, new Object[] { 3, 1 }, new Object[] { 1L, 3L }, new Object[] { 1 });
}
Also used : FilterFunction(uk.gov.gchq.gaffer.function.FilterFunction) ConsumerFunctionContext(uk.gov.gchq.gaffer.function.context.ConsumerFunctionContext) IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan) And(uk.gov.gchq.gaffer.function.filter.And) IsMoreThan(uk.gov.gchq.gaffer.function.filter.IsMoreThan)

Example 13 with IsLessThan

use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.

the class IsLessThanExample method isLessThan5.

public void isLessThan5() {
    // ---------------------------------------------------------
    final IsLessThan function = new IsLessThan(5);
    // ---------------------------------------------------------
    runExample(function, 1, 1L, 5, 5L, 10, 10L, "1");
}
Also used : IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan)

Example 14 with IsLessThan

use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.

the class IsLessThanExample method isLessThanALong5.

public void isLessThanALong5() {
    // ---------------------------------------------------------
    final IsLessThan function = new IsLessThan(5L);
    // ---------------------------------------------------------
    runExample(function, 1, 1L, 5, 5L, 10, 10L, "1");
}
Also used : IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan)

Example 15 with IsLessThan

use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.

the class ArrayListStoreTest method shouldAddAndGetEdgesThenEntities.

@Test
public void shouldAddAndGetEdgesThenEntities() throws OperationException {
    final Graph graph = createGraph();
    addElementsToGraph(graph);
    //set up the operation to fetch the entities
    final OperationChain<CloseableIterable<SimpleEntityDataObject>> opChain = new OperationChain.Builder().first(new GetEdges.Builder<>().addSeed(new EntitySeed(1)).build()).then(new GenerateObjects.Builder<Edge, EntitySeed>().generator(new EntitySeedExtractor(IdentifierType.DESTINATION)).build()).then(new GetEntities.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Entity, SimpleEntityDataObject>().generator(new SimpleEntityGenerator()).build()).build();
    //now do the hop
    final CloseableIterable<SimpleEntityDataObject> results = graph.execute(opChain, new User());
    //check the results by converting our edges back into SimpleDataObjects
    if (!results.iterator().hasNext()) {
        fail("No results returned");
    } else {
        for (final SimpleEntityDataObject obj : results) {
            LOGGER.info(obj.toString());
        }
        final List<SimpleEntityDataObject> resultList = Lists.newArrayList(results);
        assertEquals(1, resultList.size());
        assertEquals(1, resultList.get(0).getId());
        assertEquals(1, resultList.get(0).getVisibility());
        assertEquals("Red", resultList.get(0).getProperties());
    }
    results.close();
}
Also used : SimpleEntityGenerator(uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEntityGenerator) User(uk.gov.gchq.gaffer.user.User) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Graph(uk.gov.gchq.gaffer.graph.Graph) IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan) EntitySeedExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor) GetEdges(uk.gov.gchq.gaffer.operation.impl.get.GetEdges) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) SimpleEntityDataObject(uk.gov.gchq.gaffer.arrayliststore.data.SimpleEntityDataObject) Test(org.junit.Test)

Aggregations

IsLessThan (uk.gov.gchq.gaffer.function.filter.IsLessThan)21 Test (org.junit.Test)11 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)11 IsMoreThan (uk.gov.gchq.gaffer.function.filter.IsMoreThan)10 ConsumerFunctionContext (uk.gov.gchq.gaffer.function.context.ConsumerFunctionContext)9 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)8 FilterFunction (uk.gov.gchq.gaffer.function.FilterFunction)8 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)7 Graph (uk.gov.gchq.gaffer.graph.Graph)6 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)6 User (uk.gov.gchq.gaffer.user.User)6 ArrayList (java.util.ArrayList)5 GreaterThan (org.apache.spark.sql.sources.GreaterThan)5 LessThan (org.apache.spark.sql.sources.LessThan)5 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)5 SQLContext (org.apache.spark.sql.SQLContext)4 Filter (org.apache.spark.sql.sources.Filter)4 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)4 Schema (uk.gov.gchq.gaffer.store.schema.Schema)4 HashSet (java.util.HashSet)3