Accumulo Operations
These are special Operations for use with Accumulo Stores and will not work with other stores.
This directed graph is used in all the examples on this page:
graph TD
1(1, count=3) -- count=3 --> 2
1 -- count=1 --> 4
2(2, count=1) -- count=2 --> 3
2 -- count=1 --> 4(4, count=1)
2 -- count=1 --> 5(5, count=3)
3(3, count=2) -- count=4 --> 4
GetElementsBetweenSets
Deprecated
Operation has been deprecated in favour of GetElementsBetweenSetPairs
Gets edges that exist between 2 sets and entities in the first set. Javadoc
Example getting elements within set of vertices 1 and 2 and 4
Results:
Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=2,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=4,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Example getting elements within set of vertices 1 and 2 and 4 with count greater than 2
final GetElementsBetweenSets operation = new GetElementsBetweenSets.Builder()
.input(new EntitySeed(1))
.inputB(new EntitySeed(2), new EntitySeed(4))
.view(new View.Builder()
.entity("entity", new ViewElementDefinition.Builder()
.preAggregationFilter(new ElementFilter.Builder()
.select("count")
.execute(new IsMoreThan(2))
.build())
.build())
.edge("edge", new ViewElementDefinition.Builder()
.preAggregationFilter(new ElementFilter.Builder()
.select("count")
.execute(new IsMoreThan(2))
.build())
.build())
.build())
.build();
{
"class" : "GetElementsBetweenSets",
"input" : [ {
"class" : "EntitySeed",
"vertex" : 1
} ],
"inputB" : [ {
"class" : "EntitySeed",
"vertex" : 2
}, {
"class" : "EntitySeed",
"vertex" : 4
} ],
"view" : {
"edges" : {
"edge" : {
"preAggregationFilterFunctions" : [ {
"selection" : [ "count" ],
"predicate" : {
"class" : "IsMoreThan",
"orEqualTo" : false,
"value" : 2
}
} ]
}
},
"entities" : {
"entity" : {
"preAggregationFilterFunctions" : [ {
"selection" : [ "count" ],
"predicate" : {
"class" : "IsMoreThan",
"orEqualTo" : false,
"value" : 2
}
} ]
}
}
}
}
g.GetElementsBetweenSets(
view=g.View(
entities=[
g.ElementDefinition(
group="entity",
pre_aggregation_filter_functions=[
g.PredicateContext(
selection=[
"count"
],
predicate=g.IsMoreThan(
value=2,
or_equal_to=False
)
)
]
)
],
edges=[
g.ElementDefinition(
group="edge",
pre_aggregation_filter_functions=[
g.PredicateContext(
selection=[
"count"
],
predicate=g.IsMoreThan(
value=2,
or_equal_to=False
)
)
]
)
],
all_edges=False,
all_entities=False
),
input=[
g.EntitySeed(
vertex=1
)
],
input_b=[
g.EntitySeed(
vertex=2
),
g.EntitySeed(
vertex=4
)
]
)
Results:
GetElementsBetweenSetsPairs
Given a Pair
containing two sets of EntityIds
, this returns all edges that exist between the two sets of Entities. Also returns Entities
from the first set.
This operation has been introduced as a replacement to the GetElementsBetweenSets
operation as that could not be used in operation chains due to it requiring two inputs. Instead this operation requires a single Pair
input containing two Sets which have the Entity IDs you wish to get the edges between. Javadoc
Example getting edges between a Set
of node 1 and a Set
of node 2 and 4
// Create and populate first input set
final Set inputSet1 = new HashSet();
inputSet1.add(new EntitySeed(1));
// Create and populate second input set
final Set inputSet2 = new HashSet();
inputSet2.add(new EntitySeed(2));
inputSet2.add(new EntitySeed(4));
// Create operation using the Sets wrapped in a Pair object
final GetElementsBetweenSetsPairs operation = new GetElementsBetweenSetsPairs.Builder()
.input(new Pair(inputSet1, inputSet2))
.build();
Currently Unavailable
The Python API for this operation is currently unavailable see this issue.
Results:
Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=2,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=4,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>1]]
[
{
"class": "uk.gov.gchq.gaffer.data.element.Entity",
"group": "entity",
"vertex": 1,
"properties": {
"count": 3
}
},
{
"class": "uk.gov.gchq.gaffer.data.element.Edge",
"group": "edge",
"source": 1,
"destination": 2,
"directed": true,
"matchedVertex": "SOURCE",
"properties": {
"count": 3
}
},
{
"class": "uk.gov.gchq.gaffer.data.element.Edge",
"group": "edge",
"source": 1,
"destination": 4,
"directed": true,
"matchedVertex": "SOURCE",
"properties": {
"count": 1
}
}
]
GetElementsWithinSet
Gets edges with both vertices in a given set and entities with vertices in a given set. Javadoc
Example getting elements within set of vertices 1 and 2 and 3
Results:
Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=2,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Entity[vertex=2,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=2,destination=3,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>2]]
Entity[vertex=3,group=entity,properties=Properties[count=<java.lang.Integer>2]]
Example getting elements within set of vertices 1 and 2 and 3 with count greater than 2
final GetElementsWithinSet operation = new GetElementsWithinSet.Builder()
.input(new EntitySeed(1), new EntitySeed(2), new EntitySeed(3))
.view(new View.Builder()
.entity("entity", new ViewElementDefinition.Builder()
.preAggregationFilter(new ElementFilter.Builder()
.select("count")
.execute(new IsMoreThan(2))
.build())
.build())
.edge("edge", new ViewElementDefinition.Builder()
.preAggregationFilter(new ElementFilter.Builder()
.select("count")
.execute(new IsMoreThan(2))
.build())
.build())
.build())
.build();
{
"class" : "GetElementsWithinSet",
"input" : [ {
"class" : "EntitySeed",
"vertex" : 1
}, {
"class" : "EntitySeed",
"vertex" : 2
}, {
"class" : "EntitySeed",
"vertex" : 3
} ],
"view" : {
"edges" : {
"edge" : {
"preAggregationFilterFunctions" : [ {
"selection" : [ "count" ],
"predicate" : {
"class" : "IsMoreThan",
"orEqualTo" : false,
"value" : 2
}
} ]
}
},
"entities" : {
"entity" : {
"preAggregationFilterFunctions" : [ {
"selection" : [ "count" ],
"predicate" : {
"class" : "IsMoreThan",
"orEqualTo" : false,
"value" : 2
}
} ]
}
}
}
}
g.GetElementsWithinSet(
view=g.View(
entities=[
g.ElementDefinition(
group="entity",
pre_aggregation_filter_functions=[
g.PredicateContext(
selection=[
"count"
],
predicate=g.IsMoreThan(
value=2,
or_equal_to=False
)
)
]
)
],
edges=[
g.ElementDefinition(
group="edge",
pre_aggregation_filter_functions=[
g.PredicateContext(
selection=[
"count"
],
predicate=g.IsMoreThan(
value=2,
or_equal_to=False
)
)
]
)
],
all_edges=False,
all_entities=False
),
input=[
g.EntitySeed(
vertex=1
),
g.EntitySeed(
vertex=2
),
g.EntitySeed(
vertex=3
)
]
)
Results:
GetElementsInRanges
Gets elements that have vertices within a given range. Javadoc
Example getting all elements in the range from entity 1 to entity 4
Results:
Entity[vertex=1,group=entity,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=2,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Edge[source=1,destination=4,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Entity[vertex=2,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=2,destination=3,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>2]]
Edge[source=2,destination=4,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=2,destination=5,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=1,destination=2,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>3]]
Entity[vertex=3,group=entity,properties=Properties[count=<java.lang.Integer>2]]
Edge[source=3,destination=4,directed=true,matchedVertex=SOURCE,group=edge,properties=Properties[count=<java.lang.Integer>4]]
Edge[source=2,destination=3,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>2]]
Entity[vertex=4,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=1,destination=4,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=2,destination=4,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=3,destination=4,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>4]]
Example getting all elements in the range from entity 4 to edge 4->5
Results:
Entity[vertex=4,group=entity,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=1,destination=4,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=2,destination=4,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>1]]
Edge[source=3,destination=4,directed=true,matchedVertex=DESTINATION,group=edge,properties=Properties[count=<java.lang.Integer>4]]
Entity[vertex=5,group=entity,properties=Properties[count=<java.lang.Integer>3]]