use of org.janusgraph.core.JanusGraphEdge in project janusgraph by JanusGraph.
the class JanusGraphTest method testRelationTypeIndexes.
@Test
public void testRelationTypeIndexes() {
PropertyKey weight = makeKey("weight", Float.class);
PropertyKey time = makeKey("time", Long.class);
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.LIST).make();
EdgeLabel connect = mgmt.makeEdgeLabel("connect").signature(time).make();
EdgeLabel child = mgmt.makeEdgeLabel("child").multiplicity(Multiplicity.ONE2MANY).make();
EdgeLabel link = mgmt.makeEdgeLabel("link").unidirected().make();
RelationTypeIndex name1 = mgmt.buildPropertyIndex(name, "weightDesc", weight);
RelationTypeIndex connect1 = mgmt.buildEdgeIndex(connect, "weightAsc", Direction.BOTH, incr, weight);
RelationTypeIndex connect2 = mgmt.buildEdgeIndex(connect, "weightDesc", Direction.OUT, decr, weight);
RelationTypeIndex connect3 = mgmt.buildEdgeIndex(connect, "time+weight", Direction.OUT, decr, time, weight);
RelationTypeIndex child1 = mgmt.buildEdgeIndex(child, "time", Direction.OUT, time);
RelationTypeIndex link1 = mgmt.buildEdgeIndex(link, "time", Direction.OUT, time);
final String name1n = name1.name(), connect1n = connect1.name(), connect2n = connect2.name(), connect3n = connect3.name(), child1n = child1.name(), link1n = link1.name();
// ########### INSPECTION & FAILURE ##############
assertTrue(mgmt.containsRelationIndex(name, "weightDesc"));
assertTrue(mgmt.containsRelationIndex(connect, "weightDesc"));
assertFalse(mgmt.containsRelationIndex(child, "weightDesc"));
assertEquals("time+weight", mgmt.getRelationIndex(connect, "time+weight").name());
assertNotNull(mgmt.getRelationIndex(link, "time"));
assertNull(mgmt.getRelationIndex(name, "time"));
assertEquals(1, Iterables.size(mgmt.getRelationIndexes(child)));
assertEquals(3, Iterables.size(mgmt.getRelationIndexes(connect)));
assertEquals(0, Iterables.size(mgmt.getRelationIndexes(weight)));
try {
// Name already exists
mgmt.buildEdgeIndex(connect, "weightAsc", Direction.OUT, time);
fail();
} catch (SchemaViolationException ignored) {
}
// } catch (IllegalArgumentException e) {}
try {
// Not valid in this direction due to multiplicity constraint
mgmt.buildEdgeIndex(child, "blablub", Direction.IN, time);
fail();
} catch (IllegalArgumentException ignored) {
}
try {
// Not valid in this direction due to unidirectionality
mgmt.buildEdgeIndex(link, "blablub", Direction.BOTH, time);
fail();
} catch (IllegalArgumentException ignored) {
}
// ########## END INSPECTION ###########
finishSchema();
weight = mgmt.getPropertyKey("weight");
time = mgmt.getPropertyKey("time");
name = mgmt.getPropertyKey("name");
connect = mgmt.getEdgeLabel("connect");
child = mgmt.getEdgeLabel("child");
link = mgmt.getEdgeLabel("link");
// ########### INSPECTION & FAILURE (copied from above) ##############
assertTrue(mgmt.containsRelationIndex(name, "weightDesc"));
assertTrue(mgmt.containsRelationIndex(connect, "weightDesc"));
assertFalse(mgmt.containsRelationIndex(child, "weightDesc"));
assertEquals("time+weight", mgmt.getRelationIndex(connect, "time+weight").name());
assertNotNull(mgmt.getRelationIndex(link, "time"));
assertNull(mgmt.getRelationIndex(name, "time"));
assertEquals(1, Iterables.size(mgmt.getRelationIndexes(child)));
assertEquals(3, Iterables.size(mgmt.getRelationIndexes(connect)));
assertEquals(0, Iterables.size(mgmt.getRelationIndexes(weight)));
try {
// Name already exists
mgmt.buildEdgeIndex(connect, "weightAsc", Direction.OUT, time);
fail();
} catch (SchemaViolationException ignored) {
}
// } catch (IllegalArgumentException e) {}
try {
// Not valid in this direction due to multiplicity constraint
mgmt.buildEdgeIndex(child, "blablub", Direction.IN, time);
fail();
} catch (IllegalArgumentException ignored) {
}
try {
// Not valid in this direction due to unidirectionality
mgmt.buildEdgeIndex(link, "blablub", Direction.BOTH, time);
fail();
} catch (IllegalArgumentException ignored) {
}
// ########## END INSPECTION ###########
mgmt.rollback();
/*
########## TEST WITHIN TRANSACTION ##################
*/
weight = tx.getPropertyKey("weight");
time = tx.getPropertyKey("time");
final int numV = 100;
JanusGraphVertex v = tx.addVertex();
JanusGraphVertex[] ns = new JanusGraphVertex[numV];
for (int i = 0; i < numV; i++) {
double w = (i * 0.5) % 5;
long t = (i + 77) % numV;
VertexProperty p = v.property("name", "v" + i, "weight", w, "time", t);
ns[i] = tx.addVertex();
for (String label : new String[] { "connect", "child", "link" }) {
Edge e = v.addEdge(label, ns[i], "weight", w, "time", t);
}
}
JanusGraphVertex u = ns[0];
VertexList vl;
// ######### QUERIES ##########
v = getV(tx, v);
u = getV(tx, u);
evaluateQuery(v.query().keys("name").has("weight", Cmp.GREATER_THAN, 3.6), PROPERTY, 2 * numV / 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().keys("name").has("weight", Cmp.LESS_THAN, 0.9).orderBy("weight", incr), PROPERTY, 2 * numV / 10, 1, new boolean[] { true, true }, weight, Order.ASC);
evaluateQuery(v.query().keys("name").interval("weight", 1.1, 2.2).orderBy("weight", decr).limit(numV / 10), PROPERTY, numV / 10, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query().keys("name").has("time", Cmp.EQUAL, 5).orderBy("weight", decr), PROPERTY, 1, 1, new boolean[] { false, false }, weight, Order.DESC);
evaluateQuery(v.query().keys("name"), PROPERTY, numV, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(OUT).has("time", Cmp.EQUAL, 5), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(BOTH).has("time", Cmp.EQUAL, 5), EDGE, 1, 2, new boolean[0]);
evaluateQuery(v.query().labels("child").direction(OUT).interval("time", 10, 20).orderBy("weight", decr).limit(5), EDGE, 5, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query().labels("child").direction(BOTH).interval("weight", 0.0, 1.0).orderBy("weight", decr), EDGE, 2 * numV / 10, 2, new boolean[] { false, false }, weight, Order.DESC);
evaluateQuery(v.query().labels("child").direction(OUT).interval("weight", 0.0, 1.0), EDGE, 2 * numV / 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("child").direction(BOTH), EDGE, numV, 1, new boolean[] { true, true });
vl = v.query().labels("child").direction(BOTH).vertexIds();
assertEquals(numV, vl.size());
assertTrue(vl.isSorted());
assertTrue(isSortedByID(vl));
evaluateQuery(v.query().labels("child").interval("weight", 0.0, 1.0).direction(OUT), EDGE, 2 * numV / 10, 1, new boolean[] { false, true });
vl = v.query().labels("child").interval("weight", 0.0, 1.0).direction(OUT).vertexIds();
assertEquals(2 * numV / 10, vl.size());
assertTrue(vl.isSorted());
assertTrue(isSortedByID(vl));
evaluateQuery(v.query().labels("child").interval("time", 70, 80).direction(OUT).orderBy("time", incr), EDGE, 10, 1, new boolean[] { true, true }, time, Order.ASC);
vl = v.query().labels("child").interval("time", 70, 80).direction(OUT).orderBy("time", incr).vertexIds();
assertEquals(10, vl.size());
assertFalse(vl.isSorted());
assertFalse(isSortedByID(vl));
vl.sort();
assertTrue(vl.isSorted());
assertTrue(isSortedByID(vl));
evaluateQuery(v.query().labels("connect").has("time", Cmp.EQUAL, 5).interval("weight", 0.0, 5.0).direction(OUT), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("connect").has("time", Cmp.EQUAL, 5).interval("weight", 0.0, 5.0).direction(BOTH), EDGE, 1, 2, new boolean[0]);
evaluateQuery(v.query().labels("connect").interval("time", 10, 20).interval("weight", 0.0, 5.0).direction(OUT), EDGE, 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("connect").direction(OUT).orderBy("weight", incr).limit(10), EDGE, 10, 1, new boolean[] { true, true }, weight, Order.ASC);
evaluateQuery(v.query().labels("connect").direction(OUT).orderBy("weight", decr).limit(10), EDGE, 10, 1, new boolean[] { true, true }, weight, Order.DESC);
evaluateQuery(v.query().labels("connect").direction(OUT).interval("weight", 1.4, 2.75).orderBy("weight", decr), EDGE, 3 * numV / 10, 1, new boolean[] { true, true }, weight, Order.DESC);
evaluateQuery(v.query().labels("connect").direction(OUT).has("time", Cmp.EQUAL, 22).orderBy("weight", decr), EDGE, 1, 1, new boolean[] { true, true }, weight, Order.DESC);
evaluateQuery(v.query().labels("connect").direction(OUT).has("time", Cmp.EQUAL, 22).orderBy("weight", incr), EDGE, 1, 1, new boolean[] { true, false }, weight, Order.ASC);
evaluateQuery(v.query().labels("connect").direction(OUT).adjacent(u), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("connect").direction(OUT).has("weight", Cmp.EQUAL, 0.0).adjacent(u), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("connect").direction(OUT).interval("weight", 0.0, 1.0).adjacent(u), EDGE, 1, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("connect").direction(OUT).interval("time", 50, 100).adjacent(u), EDGE, 1, 1, new boolean[] { false, true });
evaluateQuery(v.query(), RELATION, numV * 4, 1, new boolean[] { true, true });
evaluateQuery(v.query().direction(OUT), RELATION, numV * 4, 1, new boolean[] { false, true });
// --------------
clopen();
weight = tx.getPropertyKey("weight");
time = tx.getPropertyKey("time");
// ######### QUERIES (copied from above) ##########
v = getV(tx, v);
u = getV(tx, u);
evaluateQuery(v.query().keys("name").has("weight", Cmp.GREATER_THAN, 3.6), PROPERTY, 2 * numV / 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().keys("name").has("weight", Cmp.LESS_THAN, 0.9).orderBy("weight", incr), PROPERTY, 2 * numV / 10, 1, new boolean[] { true, true }, weight, Order.ASC);
evaluateQuery(v.query().keys("name").interval("weight", 1.1, 2.2).orderBy("weight", decr).limit(numV / 10), PROPERTY, numV / 10, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query().keys("name").has("time", Cmp.EQUAL, 5).orderBy("weight", decr), PROPERTY, 1, 1, new boolean[] { false, false }, weight, Order.DESC);
evaluateQuery(v.query().keys("name"), PROPERTY, numV, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(OUT).has("time", Cmp.EQUAL, 5), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(BOTH).has("time", Cmp.EQUAL, 5), EDGE, 1, 2, new boolean[0]);
evaluateQuery(v.query().labels("child").direction(OUT).interval("time", 10, 20).orderBy("weight", decr).limit(5), EDGE, 5, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query().labels("child").direction(BOTH).interval("weight", 0.0, 1.0).orderBy("weight", decr), EDGE, 2 * numV / 10, 2, new boolean[] { false, false }, weight, Order.DESC);
evaluateQuery(v.query().labels("child").direction(OUT).interval("weight", 0.0, 1.0), EDGE, 2 * numV / 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("child").direction(BOTH), EDGE, numV, 1, new boolean[] { true, true });
vl = v.query().labels("child").direction(BOTH).vertexIds();
assertEquals(numV, vl.size());
assertTrue(vl.isSorted());
assertTrue(isSortedByID(vl));
evaluateQuery(v.query().labels("child").interval("weight", 0.0, 1.0).direction(OUT), EDGE, 2 * numV / 10, 1, new boolean[] { false, true });
vl = v.query().labels("child").interval("weight", 0.0, 1.0).direction(OUT).vertexIds();
assertEquals(2 * numV / 10, vl.size());
assertTrue(vl.isSorted());
assertTrue(isSortedByID(vl));
evaluateQuery(v.query().labels("child").interval("time", 70, 80).direction(OUT).orderBy("time", incr), EDGE, 10, 1, new boolean[] { true, true }, time, Order.ASC);
vl = v.query().labels("child").interval("time", 70, 80).direction(OUT).orderBy("time", incr).vertexIds();
assertEquals(10, vl.size());
assertFalse(vl.isSorted());
assertFalse(isSortedByID(vl));
vl.sort();
assertTrue(vl.isSorted());
assertTrue(isSortedByID(vl));
evaluateQuery(v.query().labels("connect").has("time", Cmp.EQUAL, 5).interval("weight", 0.0, 5.0).direction(OUT), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("connect").has("time", Cmp.EQUAL, 5).interval("weight", 0.0, 5.0).direction(BOTH), EDGE, 1, 2, new boolean[0]);
evaluateQuery(v.query().labels("connect").interval("time", 10, 20).interval("weight", 0.0, 5.0).direction(OUT), EDGE, 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("connect").direction(OUT).orderBy("weight", incr).limit(10), EDGE, 10, 1, new boolean[] { true, true }, weight, Order.ASC);
evaluateQuery(v.query().labels("connect").direction(OUT).orderBy("weight", decr).limit(10), EDGE, 10, 1, new boolean[] { true, true }, weight, Order.DESC);
evaluateQuery(v.query().labels("connect").direction(OUT).interval("weight", 1.4, 2.75).orderBy("weight", decr), EDGE, 3 * numV / 10, 1, new boolean[] { true, true }, weight, Order.DESC);
evaluateQuery(v.query().labels("connect").direction(OUT).has("time", Cmp.EQUAL, 22).orderBy("weight", decr), EDGE, 1, 1, new boolean[] { true, true }, weight, Order.DESC);
evaluateQuery(v.query().labels("connect").direction(OUT).has("time", Cmp.EQUAL, 22).orderBy("weight", incr), EDGE, 1, 1, new boolean[] { true, false }, weight, Order.ASC);
evaluateQuery(v.query().labels("connect").direction(OUT).adjacent(u), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("connect").direction(OUT).has("weight", Cmp.EQUAL, 0.0).adjacent(u), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("connect").direction(OUT).interval("weight", 0.0, 1.0).adjacent(u), EDGE, 1, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("connect").direction(OUT).interval("time", 50, 100).adjacent(u), EDGE, 1, 1, new boolean[] { false, true });
evaluateQuery(v.query(), RELATION, numV * 4, 1, new boolean[] { true, true });
evaluateQuery(v.query().direction(OUT), RELATION, numV * 4, 1, new boolean[] { false, true });
// Update in transaction
for (Object o : v.query().labels("name").properties()) {
JanusGraphVertexProperty<String> p = (JanusGraphVertexProperty<String>) o;
if (p.<Long>value("time") < (numV / 2))
p.remove();
}
for (Object o : v.query().direction(BOTH).edges()) {
JanusGraphEdge e = (JanusGraphEdge) o;
if (e.<Long>value("time") < (numV / 2))
e.remove();
}
ns = new JanusGraphVertex[numV * 3 / 2];
for (int i = numV; i < numV * 3 / 2; i++) {
double w = (i * 0.5) % 5;
v.property("name", "v" + i, "weight", w, "time", (long) i);
ns[i] = tx.addVertex();
for (String label : new String[] { "connect", "child", "link" }) {
JanusGraphEdge e = v.addEdge(label, ns[i], "weight", w, "time", (long) i);
}
}
// ######### UPDATED QUERIES ##########
evaluateQuery(v.query().keys("name").has("weight", Cmp.GREATER_THAN, 3.6), PROPERTY, 2 * numV / 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().keys("name").interval("time", numV / 2 - 10, numV / 2 + 10), PROPERTY, 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().keys("name").interval("time", numV / 2 - 10, numV / 2 + 10).orderBy("weight", decr), PROPERTY, 10, 1, new boolean[] { false, false }, weight, Order.DESC);
evaluateQuery(v.query().keys("name").interval("time", numV, numV + 10).limit(5), PROPERTY, 5, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("child").direction(OUT).has("time", Cmp.EQUAL, 5), EDGE, 0, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(OUT).has("time", Cmp.EQUAL, numV + 5), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(OUT).interval("time", 10, 20).orderBy("weight", decr).limit(5), EDGE, 0, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query().labels("child").direction(OUT).interval("time", numV + 10, numV + 20).orderBy("weight", decr).limit(5), EDGE, 5, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query(), RELATION, numV * 4, 1, new boolean[] { true, true });
evaluateQuery(v.query().direction(OUT), RELATION, numV * 4, 1, new boolean[] { false, true });
// ######### END UPDATED QUERIES ##########
newTx();
weight = tx.getPropertyKey("weight");
time = tx.getPropertyKey("time");
v = getV(tx, v);
u = getV(tx, u);
// ######### UPDATED QUERIES (copied from above) ##########
evaluateQuery(v.query().keys("name").has("weight", Cmp.GREATER_THAN, 3.6), PROPERTY, 2 * numV / 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().keys("name").interval("time", numV / 2 - 10, numV / 2 + 10), PROPERTY, 10, 1, new boolean[] { false, true });
evaluateQuery(v.query().keys("name").interval("time", numV / 2 - 10, numV / 2 + 10).orderBy("weight", decr), PROPERTY, 10, 1, new boolean[] { false, false }, weight, Order.DESC);
evaluateQuery(v.query().keys("name").interval("time", numV, numV + 10).limit(5), PROPERTY, 5, 1, new boolean[] { false, true });
evaluateQuery(v.query().labels("child").direction(OUT).has("time", Cmp.EQUAL, 5), EDGE, 0, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(OUT).has("time", Cmp.EQUAL, numV + 5), EDGE, 1, 1, new boolean[] { true, true });
evaluateQuery(v.query().labels("child").direction(OUT).interval("time", 10, 20).orderBy("weight", decr).limit(5), EDGE, 0, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query().labels("child").direction(OUT).interval("time", numV + 10, numV + 20).orderBy("weight", decr).limit(5), EDGE, 5, 1, new boolean[] { true, false }, weight, Order.DESC);
evaluateQuery(v.query(), RELATION, numV * 4, 1, new boolean[] { true, true });
evaluateQuery(v.query().direction(OUT), RELATION, numV * 4, 1, new boolean[] { false, true });
// ######### END UPDATED QUERIES ##########
}
use of org.janusgraph.core.JanusGraphEdge in project janusgraph by JanusGraph.
the class ManagementSystem method setTypeModifier.
private void setTypeModifier(final JanusGraphSchemaElement element, final ModifierType modifierType, final Object value) {
Preconditions.checkArgument(element != null, "null schema element");
TypeDefinitionCategory cat = modifierType.getCategory();
if (cat.hasDataType() && null != value) {
Preconditions.checkArgument(cat.getDataType().equals(value.getClass()), "modifier value is not of expected type " + cat.getDataType());
}
JanusGraphSchemaVertex typeVertex;
if (element instanceof JanusGraphSchemaVertex) {
typeVertex = (JanusGraphSchemaVertex) element;
} else if (element instanceof JanusGraphIndex) {
IndexType index = ((JanusGraphIndexWrapper) element).getBaseIndex();
assert index instanceof IndexTypeWrapper;
SchemaSource base = ((IndexTypeWrapper) index).getSchemaBase();
typeVertex = (JanusGraphSchemaVertex) base;
} else
throw new IllegalArgumentException("Invalid schema element: " + element);
// remove any pre-existing value for the modifier, or return if an identical value has already been set
for (JanusGraphEdge e : typeVertex.getEdges(TypeDefinitionCategory.TYPE_MODIFIER, Direction.OUT)) {
JanusGraphSchemaVertex v = (JanusGraphSchemaVertex) e.vertex(Direction.IN);
TypeDefinitionMap def = v.getDefinition();
Object existingValue = def.getValue(modifierType.getCategory());
if (null != existingValue) {
if (existingValue.equals(value)) {
// Already has the right value, don't need to do anything
return;
} else {
e.remove();
v.remove();
}
}
}
if (null != value) {
TypeDefinitionMap def = new TypeDefinitionMap();
def.setValue(cat, value);
JanusGraphSchemaVertex cVertex = transaction.makeSchemaVertex(JanusGraphSchemaCategory.TYPE_MODIFIER, null, def);
addSchemaEdge(typeVertex, cVertex, TypeDefinitionCategory.TYPE_MODIFIER, null);
}
updateSchemaVertex(typeVertex);
updatedTypes.add(typeVertex);
}
use of org.janusgraph.core.JanusGraphEdge in project janusgraph by JanusGraph.
the class ManagementSystem method addSchemaEdge.
private JanusGraphEdge addSchemaEdge(JanusGraphVertex out, JanusGraphVertex in, TypeDefinitionCategory def, Object modifier) {
assert def.isEdge();
JanusGraphEdge edge = transaction.addEdge(out, in, BaseLabel.SchemaDefinitionEdge);
TypeDefinitionDescription desc = new TypeDefinitionDescription(def, modifier);
edge.property(BaseKey.SchemaDefinitionDesc.name(), desc);
return edge;
}
use of org.janusgraph.core.JanusGraphEdge in project janusgraph by JanusGraph.
the class VertexMemoryHandler method receiveMessages.
public Stream<M> receiveMessages(MessageScope messageScope) {
if (messageScope instanceof MessageScope.Global) {
M message = vertexMemory.getMessage(vertexId, messageScope);
if (message == null)
return Stream.empty();
else
return Stream.of(message);
} else {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
final BiFunction<M, Edge, M> edgeFct = localMessageScope.getEdgeFunction();
final List<Edge> edges;
try (final Traversal<Vertex, Edge> reverseIncident = FulgoraUtil.getReverseElementTraversal(localMessageScope, vertex, vertex.tx())) {
edges = IteratorUtils.list(reverseIncident);
} catch (Exception e) {
throw new JanusGraphException("Unable to close traversal", e);
}
return edges.stream().map(e -> {
M msg = vertexMemory.getMessage(vertexMemory.getCanonicalId(((JanusGraphEdge) e).otherVertex(vertex).longId()), localMessageScope);
return msg == null ? null : edgeFct.apply(msg, e);
}).filter(Objects::nonNull);
}
}
use of org.janusgraph.core.JanusGraphEdge in project janusgraph by JanusGraph.
the class ManagementSystem method setStatusEdges.
private void setStatusEdges(JanusGraphSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) {
Preconditions.checkArgument(vertex.asIndexType().isMixedIndex());
for (JanusGraphEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) {
// Only address edges with matching keys
if (!keys.contains(edge.vertex(Direction.IN)))
continue;
TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);
assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD;
Parameter[] parameters = (Parameter[]) desc.getModifier();
assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName());
if (parameters[parameters.length - 1].value().equals(status))
continue;
Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length);
paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status);
edge.remove();
addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy);
}
for (PropertyKeyVertex prop : keys) prop.resetCache();
}
Aggregations