@Override public boolean containsVertex(final long vertexid) { verifyOpen(); if (vertexCache.contains(vertexid)) { if (!vertexCache.get(vertexid, vertexConstructor).isRemoved()) return true; else return false; } else if (vertexid > 0 && graph.containsVertexID(vertexid, txHandle)) return true; else return false; }
@Override public TitanVertex addVertex() { verifyWriteAccess(); StandardVertex vertex = new StandardVertex(this, temporaryID.decrementAndGet(), ElementLifeCycle.New); vertex.addProperty(SystemKey.VertexState, (byte) 0); if (config.hasAssignIDsImmediately()) graph.assignID(vertex); vertexCache.add(vertex, vertex.getID()); return vertex; }
public TitanLabel makeEdgeLabel(EdgeLabelDefinition definition) { verifyOpen(); TitanLabelVertex label = new TitanLabelVertex(this, temporaryID.decrementAndGet(), ElementLifeCycle.New); addProperty(label, SystemKey.TypeName, definition.getName()); addProperty(label, SystemKey.RelationTypeDefinition, definition); addProperty(label, SystemKey.TypeClass, TitanTypeClass.LABEL); graph.assignID(label); vertexCache.add(label, label.getID()); typeCache.put(definition.getName(), label); return label; }
public TitanKey makePropertyKey(PropertyKeyDefinition definition) { verifyOpen(); TitanKeyVertex prop = new TitanKeyVertex(this, temporaryID.decrementAndGet(), ElementLifeCycle.New); addProperty(prop, SystemKey.TypeName, definition.getName()); addProperty(prop, SystemKey.PropertyKeyDefinition, definition); addProperty(prop, SystemKey.TypeClass, TitanTypeClass.KEY); graph.assignID(prop); Preconditions.checkArgument(prop.getID() > 0); vertexCache.add(prop, prop.getID()); typeCache.put(definition.getName(), prop); return prop; }
@Override public Iterable<Vertex> getVertices() { if (!addedRelations.isEmpty()) { // There are possible new vertices List<Vertex> newVs = new ArrayList<Vertex>(); for (InternalVertex v : vertexCache.getAll()) { if (v.isNew() && !(v instanceof TitanType)) newVs.add(v); } return Iterables.concat(newVs, new VertexIterable(graph, this)); } else { return (Iterable) new VertexIterable(graph, this); } }
public InternalVertex getExistingVertex(final long id) { // return vertex no matter what, even if deleted InternalVertex vertex = vertexCache.get(id, vertexConstructor); return vertex; }