Search in sources :

Example 6 with GetElementsInRanges

use of uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges in project Gaffer by gchq.

the class GetElementsinRangesHandlerTest method shouldSummarise.

private void shouldSummarise(final AccumuloStore store) throws OperationException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    //get Everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0"), new EntitySeed("1")));
    final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
    final GetElementsInRanges<Pair<ElementSeed>, Element> operation = new GetElementsInRanges<>(view, simpleEntityRanges);
    final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
    final CloseableIterable<Element> elementsInRange = handler.doOperation(operation, user, store);
    int count = 0;
    for (final Element elm : elementsInRange) {
        //Make sure every element has been summarised
        assertEquals(9, elm.getProperty(AccumuloPropertyNames.COLUMN_QUALIFIER));
        count++;
    }
    assertEquals(1000, count);
    elementsInRange.close();
    simpleEntityRanges.clear();
    //This should get everything between 0 and 0799 (again being string ordering 0800 is more than 08)
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0"), new EntitySeed("08")));
    final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
    count = 0;
    for (final Element elm : elements) {
        //Make sure every element has been summarised
        assertEquals(9, elm.getProperty(AccumuloPropertyNames.COLUMN_QUALIFIER));
        count++;
    }
    assertEquals(800, count);
    elements.close();
}
Also used : GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) Element(uk.gov.gchq.gaffer.data.element.Element) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Aggregations

HashSet (java.util.HashSet)6 GetElementsInRanges (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges)6 Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)6 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)6 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)6 Element (uk.gov.gchq.gaffer.data.element.Element)5 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)4 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)4 User (uk.gov.gchq.gaffer.user.User)3 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1