Search in sources :

Example 1 with GetElementsInRanges

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

the class AccumuloRangeIDRetrieverTest method shouldRetieveElementsInRangeBetweenSeeds.

private void shouldRetieveElementsInRangeBetweenSeeds(final AccumuloStore store) throws StoreException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0000"), new EntitySeed("0999")));
    // Retrieve elements when less simple entities are provided than the max number of entries for the batch scanner
    final GetElementsOperation<Pair<ElementSeed>, CloseableIterable<Element>> operation = new GetElementsInRanges<>(defaultView, simpleEntityRanges);
    try {
        final AccumuloRangeIDRetriever retriever = new AccumuloRangeIDRetriever(store, operation, new User());
        assertEquals(numEntries, Iterables.size(retriever));
    } catch (IteratorSettingException e) {
        fail("Unable to construct Range Retriever");
    }
}
Also used : User(uk.gov.gchq.gaffer.user.User) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) IteratorSettingException(uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException) HashSet(java.util.HashSet) Pair(uk.gov.gchq.gaffer.accumulostore.utils.Pair)

Example 2 with GetElementsInRanges

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

the class GetElementsinRangesHandlerTest method shouldReturnNothingWhenNoEdgesSet.

private void shouldReturnNothingWhenNoEdgesSet(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);
    //All Edges stored should be outgoing from our provided seeds.
    operation.setIncludeEdges(IncludeEdgeType.UNDIRECTED);
    final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
    final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
    final int count = Iterables.size(elements);
    //There should be no incoming edges to the provided range
    assertEquals(0, 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)

Example 3 with GetElementsInRanges

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

the class GetElementsinRangesHandlerTest method shouldHaveNoIncomingEdges.

private void shouldHaveNoIncomingEdges(final AccumuloStore store) throws OperationException {
    // Create set to query for
    final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
    final User user = new User();
    //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);
    //All Edges stored should be outgoing from our provided seeds.
    operation.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
    final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
    final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
    final int count = Iterables.size(elements);
    //There should be no incoming edges to the provided range
    assertEquals(0, count);
    elements.close();
}
Also used : User(uk.gov.gchq.gaffer.user.User) 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)

Example 4 with GetElementsInRanges

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

the class AccumuloRangeIDRetrieverTest method shouldRetrieveElementsInRangeBetweenSeeds.

private void shouldRetrieveElementsInRangeBetweenSeeds(final AccumuloStore store) throws Exception {
    // Create set to query for
    final Set<Pair<ElementId, ElementId>> simpleEntityRanges = new HashSet<>();
    simpleEntityRanges.add(new Pair<>(new EntitySeed("0000"), new EntitySeed("0999")));
    // Retrieve elements when less simple entities are provided than the max number of entries for the batch scanner
    final GetElementsInRanges operation = new GetElementsInRanges.Builder().view(defaultView).input(simpleEntityRanges).build();
    final AccumuloRangeIDRetriever<?> retriever = new AccumuloRangeIDRetriever<>(store, operation, new User());
    final List<Element> elements = Lists.newArrayList(retriever);
    for (final Element element : elements) {
        if (element instanceof Edge) {
            assertEquals(EdgeId.MatchedVertex.SOURCE, ((Edge) element).getMatchedVertex());
        }
    }
    assertEquals(NUM_ENTRIES, elements.size());
}
Also used : User(uk.gov.gchq.gaffer.user.User) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) HashSet(java.util.HashSet)

Example 5 with GetElementsInRanges

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

the class FederatedAddGraphHandlerTest method shouldAddGraphAndAddSupportedOperations.

@Test
public void shouldAddGraphAndAddSupportedOperations() throws Exception {
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    Schema expectedSchema = new Schema.Builder().build();
    assertFalse(store.isSupported(GetElementsInRanges.class), "Empty FederatedStore should NOT support GetElementsInRanges");
    assertFalse(store.isSupported(AddElementsFromHdfs.class), "Empty FederatedStore should NOT support AddElementsFromHdfs");
    FederatedAddGraphHandler federatedAddGraphHandler = new FederatedAddGraphHandler();
    federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).build(), new Context(testUser), store);
    assertTrue(store.isSupported(GetElementsInRanges.class), "FederatedStore with an added Accumulo store should support GetElementsInRanges");
    assertTrue(store.isSupported(AddElementsFromHdfs.class), "FederatedStore with an added Accumulo store should support AddElementsFromHdfs");
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Context(uk.gov.gchq.gaffer.store.Context) AddElementsFromHdfs(uk.gov.gchq.gaffer.hdfs.operation.AddElementsFromHdfs) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) Test(org.junit.jupiter.api.Test)

Aggregations

GetElementsInRanges (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges)10 HashSet (java.util.HashSet)8 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)8 Element (uk.gov.gchq.gaffer.data.element.Element)7 Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)6 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)6 User (uk.gov.gchq.gaffer.user.User)5 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)4 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)4 Pair (uk.gov.gchq.gaffer.commonutil.pair.Pair)3 Test (org.junit.jupiter.api.Test)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 AccumuloStoreTest (uk.gov.gchq.gaffer.accumulostore.AccumuloStoreTest)1 ByteEntityKeyPackage (uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityKeyPackage)1 ClassicKeyPackage (uk.gov.gchq.gaffer.accumulostore.key.core.impl.classic.ClassicKeyPackage)1 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)1 GetElementsBetweenSets (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsBetweenSets)1 GetElementsWithinSet (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsWithinSet)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1