use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class GetElementsBetweenSetsHandlerTest method setupGraph.
private static void setupGraph(final AccumuloStore store) {
List<Element> data = new ArrayList<>();
// Create edges A0 -> A1, A0 -> A2, ..., A0 -> A99. Also create an Entity for each.
final Entity entity = new Entity(TestGroups.ENTITY, "A0");
entity.putProperty(AccumuloPropertyNames.COUNT, 10000);
data.add(entity);
for (int i = 1; i < 100; i++) {
data.add(new Edge.Builder().group(TestGroups.EDGE).source("A0").dest("A" + i).directed(true).property(AccumuloPropertyNames.COUNT, 23).property(AccumuloPropertyNames.COLUMN_QUALIFIER, 1).property(AccumuloPropertyNames.PROP_1, 0).property(AccumuloPropertyNames.PROP_2, 0).property(AccumuloPropertyNames.PROP_3, 0).property(AccumuloPropertyNames.PROP_4, 0).build());
data.add(new Edge.Builder().group(TestGroups.EDGE).source("A0").dest("A" + i).directed(true).property(AccumuloPropertyNames.COUNT, 23).property(AccumuloPropertyNames.COLUMN_QUALIFIER, 2).build());
data.add(new Edge.Builder().group(TestGroups.EDGE).source("A0").dest("A" + i).directed(true).property(AccumuloPropertyNames.COUNT, 23).property(AccumuloPropertyNames.COLUMN_QUALIFIER, 3).build());
data.add(new Entity.Builder().group(TestGroups.ENTITY).vertex("A" + i).property(AccumuloPropertyNames.COUNT, i).build());
}
addElements(data, store, new User());
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntityIdQueryIncomingEdgesOnly.
private void testEntityIdQueryIncomingEdgesOnly(final AccumuloStore store) throws StoreException {
setupGraph(store, NUM_ENTRIES);
final User user = new User();
// Create set to query for
final Set<ElementId> ids = new HashSet<>();
for (int i = 0; i < NUM_ENTRIES; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).build();
AccumuloSingleIDRetriever<?> retriever = null;
final GetElements operation = new GetElements.Builder().view(view).input(ids).build();
operation.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
try {
retriever = new AccumuloSingleIDRetriever<>(store, operation, user);
} catch (final IteratorSettingException e) {
throw new RuntimeException(e);
}
for (final Element element : retriever) {
Edge edge = (Edge) element;
assertEquals("B", edge.getDestination());
}
// Incoming option should find all edges i-B as undirected are both incoming and outgoing.
assertEquals(NUM_ENTRIES, Iterables.size(retriever));
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntityIdQueryOutgoingEdgesOnly.
private void testEntityIdQueryOutgoingEdgesOnly(final AccumuloStore store) throws StoreException {
setupGraph(store, NUM_ENTRIES);
final User user = new User();
// Create set to query for
Set<ElementId> ids = new HashSet<>();
for (int i = 0; i < NUM_ENTRIES; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).build();
AccumuloSingleIDRetriever<?> retriever = null;
GetElements operation = new GetElements.Builder().view(view).input(ids).build();
operation.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.OUTGOING);
try {
retriever = new AccumuloSingleIDRetriever<>(store, operation, user);
} catch (final IteratorSettingException e) {
throw new RuntimeException(e);
}
int count = 0;
for (final Element element : retriever) {
count++;
assertEquals(TestGroups.EDGE, element.getGroup());
}
// Should find both i-B and i-C edges.
assertEquals(NUM_ENTRIES * 2, count);
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testDirectedEdgeIdQueries.
private void testDirectedEdgeIdQueries(final AccumuloStore store) throws StoreException {
setupGraph(store, NUM_ENTRIES);
final User user = new User();
// Create set to query for
final Set<ElementId> ids = new HashSet<>();
for (int i = 0; i < NUM_ENTRIES; i++) {
ids.add(new EdgeSeed("" + i, "B", false));
ids.add(new EdgeSeed("" + i, "C", true));
}
final View view = new View.Builder().edge(TestGroups.EDGE).build();
AccumuloSingleIDRetriever<?> retriever = null;
final GetElements operation = new GetElements.Builder().view(view).input(ids).build();
operation.setDirectedType(DirectedType.DIRECTED);
try {
retriever = new AccumuloSingleIDRetriever<>(store, operation, user);
} catch (final IteratorSettingException e) {
throw new RuntimeException(e);
}
for (final Element element : retriever) {
Edge edge = (Edge) element;
assertEquals("C", edge.getDestination());
}
// Should find 1000 only A-C
assertEquals(NUM_ENTRIES, Iterables.size(retriever));
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class AccumuloSingleIDRetrieverTest method testEntityIdQueryEdgesAndEntities.
private void testEntityIdQueryEdgesAndEntities(final AccumuloStore store) throws AccumuloException, StoreException {
setupGraph(store, NUM_ENTRIES);
final User user = new User();
// Create set to query for
final Set<ElementId> ids = new HashSet<>();
for (int i = 0; i < NUM_ENTRIES; i++) {
ids.add(new EntitySeed("" + i));
}
final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
final GetElements operation = new GetElements.Builder().view(view).input(ids).build();
try {
final AccumuloSingleIDRetriever retriever = new AccumuloSingleIDRetriever(store, operation, new User());
assertEquals(NUM_ENTRIES * 3, Iterables.size(retriever));
} catch (final IteratorSettingException e) {
fail("Unable to construct SingleID Retriever");
}
// Should find both i-B and i-C edges and entities i
}
Aggregations