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");
}
}
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();
}
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();
}
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());
}
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");
}
Aggregations