use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class GetElementsinRangesHandlerTest method shouldSummariseOutGoingEdgesOnly.
private void shouldSummariseOutGoingEdgesOnly(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("C")));
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.OUTGOING);
final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
final CloseableIterable<Element> rangeElements = handler.doOperation(operation, user, store);
int count = 0;
for (final Element elm : rangeElements) {
//Make sure every element has been summarised
assertEquals(9, elm.getProperty(AccumuloPropertyNames.COLUMN_QUALIFIER));
count++;
}
assertEquals(1000, count);
rangeElements.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();
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View 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();
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class GetElementsBetweenSetsHandlerTest method shouldReturnOnlyEdgesWhenOptionSet.
private void shouldReturnOnlyEdgesWhenOptionSet(final AccumuloStore store) throws OperationException {
final View opView = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
final GetElementsBetweenSets<Element> op = new GetElementsBetweenSets<>(seedsA, seedsB, opView);
op.setIncludeEdges(IncludeEdgeType.ALL);
op.setIncludeEntities(false);
final GetElementsBetweenSetsHandler handler = new GetElementsBetweenSetsHandler();
final CloseableIterable<Element> elements = handler.doOperation(op, user, store);
//With query compaction the result size should be 1
assertEquals(1, Iterables.size(elements));
assertThat(elements, IsCollectionContaining.hasItem(expectedSummarisedEdge));
elements.close();
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class GetElementsBetweenSetsHandlerTest method shouldSummariseOutGoingEdgesOnly.
private void shouldSummariseOutGoingEdgesOnly(final AccumuloStore store) throws OperationException {
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 GetElementsBetweenSets<Element> op = new GetElementsBetweenSets<>(seedsA, seedsB, view);
op.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.OUTGOING);
final GetElementsBetweenSetsHandler handler = new GetElementsBetweenSetsHandler();
final CloseableIterable<Element> elements = handler.doOperation(op, user, store);
//With query compaction the result size should be 2
assertEquals(2, Iterables.size(elements));
assertThat(elements, IsCollectionContaining.hasItems(expectedEntity1, expectedSummarisedEdge));
elements.close();
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntitySeedQueryEntitiesOnly.
private void testEntitySeedQueryEntitiesOnly(final AccumuloStore store) throws AccumuloException, StoreException {
setupGraph(store, numEntries);
final User user = new User();
// Create set to query for
final Set<ElementSeed> ids = new HashSet<>();
for (int i = 0; i < numEntries; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
AccumuloSingleIDRetriever retriever = null;
final GetElements<ElementSeed, ?> operation = new GetElements<>(view, ids);
operation.setIncludeEntities(true);
operation.setIncludeEdges(IncludeEdgeType.NONE);
try {
retriever = new AccumuloSingleIDRetriever(store, operation, user);
} catch (IteratorSettingException e) {
e.printStackTrace();
}
//Should find only the entities i
assertEquals(numEntries, Iterables.size(retriever));
}
Aggregations