public VertexLabelDefinition(VertexLabel vl) { this(vl.name(),vl.longId(),vl.isPartitioned(),vl.isStatic()); }
private static IDManager.VertexIDType getVertexIDType(VertexLabel vertexLabel) { if (vertexLabel.isPartitioned()) { return IDManager.VertexIDType.PartitionedVertex; } else if (vertexLabel.isStatic()) { return IDManager.VertexIDType.UnmodifiableVertex; } else { return IDManager.VertexIDType.NormalVertex; } }
private String printVertexLabels(boolean calledDirectly) { StringBuilder sb = new StringBuilder(); String pattern = "%-30s | %-11s | %-50s |%n"; Iterable<VertexLabel> labels = getVertexLabels(); boolean hasResults = false; sb.append(FIRSTDASH); sb.append(String.format(pattern, "Vertex Label Name", "Partitioned", "Static")); sb.append(DASHBREAK); for(VertexLabel label: labels) { hasResults = true; sb.append(String.format(pattern, label.name(), label.isPartitioned(), label.isStatic())); } if (hasResults && calledDirectly) { sb.append(DASHBREAK); } return sb.toString(); }
/** * Returns the name of the vertex label for this vertex. * * @return */ @Override default String label() { return vertexLabel().name(); }
assertEquals("person",person.name()); assertEquals("uid",uid.name()); assertFalse(person.isPartitioned()); assertEquals(Integer.class,uid.dataType());
if (!vertex.hasId()) { assert !(vertex instanceof JanusGraphSchemaVertex); //Those are assigned ids immediately in the transaction if (vertex.vertexLabel().isPartitioned())
private void updateConnectionEdgeConstraints(JanusGraphSchemaVertex edgeLabel, String oldName, String newName) { if (!(edgeLabel instanceof EdgeLabel)) return; ((EdgeLabel) edgeLabel).mappedConnections().stream() .peek(s -> schemaCache.expireSchemaElement(s.getOutgoingVertexLabel().longId())) .map(Connection::getConnectionEdge) .forEach(edge -> { TypeDefinitionDescription desc = new TypeDefinitionDescription(TypeDefinitionCategory.CONNECTION_EDGE, newName); edge.property(BaseKey.SchemaDefinitionDesc.name(), desc); }); }
private void checkPropertyConstraintForVertexOrCreatePropertyConstraint(JanusGraphVertex vertex, PropertyKey key) { if (config.hasDisabledSchemaConstraints()) return; VertexLabel vertexLabel = vertex.vertexLabel(); if (vertexLabel instanceof BaseVertexLabel) return; Collection<PropertyKey> propertyKeys = vertexLabel.mappedProperties(); if (propertyKeys.contains(key)) return; config.getAutoSchemaMaker().makePropertyConstraintForVertex(vertexLabel, key, this); }
private void checkConnectionConstraintOrCreateConnectionConstraint(JanusGraphVertex outVertex, JanusGraphVertex inVertex, EdgeLabel edgeLabel) { if (config.hasDisabledSchemaConstraints()) return; VertexLabel outVertexLabel = outVertex.vertexLabel(); if (outVertexLabel instanceof BaseVertexLabel) return; VertexLabel inVertexLabel = inVertex.vertexLabel(); if (inVertexLabel instanceof BaseVertexLabel) return; Collection<Connection> connections = outVertexLabel.mappedConnections(); for (Connection connection : connections) { if (connection.getIncomingVertexLabel() != inVertexLabel) continue; if (connection.getEdgeLabel().equals(edgeLabel.name())) return; } config.getAutoSchemaMaker().makeConnectionConstraint(edgeLabel, outVertexLabel, inVertexLabel, this); }
assertEquals(3, Iterables.size(mgmt.getVertexLabels())); assertEquals("tweet", tweet.name()); assertTrue(mgmt.containsVertexLabel("person")); assertFalse(mgmt.containsVertexLabel("bla")); assertFalse(person.isPartitioned()); assertFalse(person.isStatic()); assertFalse(tag.isPartitioned()); assertTrue(tweet.isStatic()); assertEquals(3, Iterables.size(mgmt.getVertexLabels())); assertEquals("tweet", tweet.name()); assertTrue(mgmt.containsVertexLabel("person")); assertFalse(mgmt.containsVertexLabel("bla")); assertFalse(person.isPartitioned()); assertFalse(person.isStatic()); assertFalse(tag.isPartitioned()); assertTrue(tweet.isStatic());
@Override public String label() { return vertexLabel().name(); }
@Override public JanusGraphVertex addVertex(Long vertexId, VertexLabel label) { verifyWriteAccess(); if (label==null) label=BaseVertexLabel.DEFAULT_VERTEXLABEL; if (vertexId != null && !graph.getConfiguration().allowVertexIdSetting()) { log.info("Provided vertex id [{}] is ignored because vertex id setting is not enabled", vertexId); vertexId = null; } Preconditions.checkArgument(vertexId != null || !graph.getConfiguration().allowVertexIdSetting(), "Must provide vertex id"); Preconditions.checkArgument(vertexId == null || IDManager.VertexIDType.NormalVertex.is(vertexId), "Not a valid vertex id: %s", vertexId); Preconditions.checkArgument(vertexId == null || ((InternalVertexLabel)label).hasDefaultConfiguration(), "Cannot only use default vertex labels: %s",label); Preconditions.checkArgument(vertexId == null || !config.hasVerifyExternalVertexExistence() || !containsVertex(vertexId), "Vertex with given id already exists: %s", vertexId); StandardVertex vertex = new StandardVertex(this, IDManager.getTemporaryVertexID(IDManager.VertexIDType.NormalVertex, temporaryIds.nextID()), ElementLifeCycle.New); if (vertexId != null) { vertex.setId(vertexId); } else if (config.hasAssignIDsImmediately() || label.isPartitioned()) { graph.assignID(vertex,label); } addProperty(vertex, BaseKey.VertexExists, Boolean.TRUE); if (label!=BaseVertexLabel.DEFAULT_VERTEXLABEL) { //Add label Preconditions.checkArgument(label instanceof VertexLabelVertex); addEdge(vertex, label, BaseLabel.VertexLabelEdge); } vertexCache.add(vertex, vertex.longId()); return vertex; }
@Override public String label() { return vertexLabel().name(); }
@Test public void testVLabelOnOrderedStorage() { final String label = "pl"; mgmt.makeVertexLabel(label).partition().make(); mgmt.commit(); graph.tx().rollback(); graph.addVertex(label); graph.tx().commit(); mgmt = graph.openManagement(); VertexLabel vl = mgmt.getVertexLabel(label); assertTrue(vl.isPartitioned()); mgmt.rollback(); }
@Test public void testIndexQueryWithLabelsAndContainsIN() { // This test is based on the steps to reproduce #882 String labelName = "labelName"; VertexLabel label = mgmt.makeVertexLabel(labelName).make(); PropertyKey uid = mgmt.makePropertyKey("uid").dataType(String.class).make(); JanusGraphIndex uidCompositeIndex = mgmt.buildIndex("uidIndex", Vertex.class) .indexOnly(label).addKey(uid).unique().buildCompositeIndex(); mgmt.setConsistency(uidCompositeIndex, ConsistencyModifier.LOCK); finishSchema(); JanusGraphVertex foo = graph.addVertex(labelName); JanusGraphVertex bar = graph.addVertex(labelName); foo.property("uid", "foo"); bar.property("uid", "bar"); graph.tx().commit(); Iterable<JanusGraphVertex> vertexes = graph.query() .has("uid", Contain.IN, ImmutableList.of("foo", "bar")) .has(LABEL_NAME, labelName) .vertices(); assertEquals(2, Iterables.size(vertexes)); for (JanusGraphVertex v : vertexes) { assertEquals(labelName, v.vertexLabel().name()); } }
VertexLabel vl = mgmt.getVertexLabel("people"); mgmt.changeName(vl, "person"); assertEquals("person", vl.name());
VertexLabel vl = typeManager.getExistingVertexLabel(vertexLabelId); tv = getOrCreateVertex(vertexId, vl.name(), tg);
VertexLabel vl = typeManager.getExistingVertexLabel(vertexLabelId); tv = getOrCreateVertex(vertexId, vl.name(), tg);