@Override public boolean equals(Object other) { if (!super.equals(other)) { return false; } if (!(other instanceof VertexLabel)) { return false; } VertexLabel otherVertexLabel = (VertexLabel) other; return this.schema.equals(otherVertexLabel.getSchema()) && super.equals(otherVertexLabel); }
@Override public boolean equals(Object other) { if (!super.equals(other)) { return false; } if (!(other instanceof VertexLabel)) { return false; } VertexLabel otherVertexLabel = (VertexLabel) other; return this.schema.equals(otherVertexLabel.getSchema()) && super.equals(otherVertexLabel); }
@Override public boolean equals(Object other) { if (!super.equals(other)) { return false; } if (!(other instanceof EdgeLabel)) { return false; } EdgeLabel otherEdgeLabel = (EdgeLabel) other; if (isValid()) { if (this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread() && !this.uncommittedInVertexLabels.isEmpty()) { VertexLabel vertexLabel = this.uncommittedOutVertexLabels.iterator().next(); VertexLabel otherVertexLabel = otherEdgeLabel.uncommittedOutVertexLabels.iterator().next(); return vertexLabel.getSchema().equals(otherVertexLabel.getSchema()) && otherEdgeLabel.getLabel().equals(this.getLabel()); } else { VertexLabel vertexLabel = this.outVertexLabels.iterator().next(); VertexLabel otherVertexLabel = otherEdgeLabel.outVertexLabels.iterator().next(); return vertexLabel.getSchema().equals(otherVertexLabel.getSchema()) && otherEdgeLabel.getLabel().equals(this.getLabel()); } } return otherEdgeLabel.getLabel().equals(this.getLabel()); }
@Override public boolean equals(Object other) { if (!super.equals(other)) { return false; } if (!(other instanceof EdgeLabel)) { return false; } EdgeLabel otherEdgeLabel = (EdgeLabel) other; if (isValid()) { if (this.getSchema().getTopology().isSqlWriteLockHeldByCurrentThread() && !this.uncommittedInVertexLabels.isEmpty()) { VertexLabel vertexLabel = this.uncommittedOutVertexLabels.iterator().next(); VertexLabel otherVertexLabel = otherEdgeLabel.uncommittedOutVertexLabels.iterator().next(); return vertexLabel.getSchema().equals(otherVertexLabel.getSchema()) && otherEdgeLabel.getLabel().equals(this.getLabel()); } else { VertexLabel vertexLabel = this.outVertexLabels.iterator().next(); VertexLabel otherVertexLabel = otherEdgeLabel.outVertexLabels.iterator().next(); return vertexLabel.getSchema().equals(otherVertexLabel.getSchema()) && otherEdgeLabel.getLabel().equals(this.getLabel()); } } return otherEdgeLabel.getLabel().equals(this.getLabel()); }
public void ensureEdgeVertexLabelExist(Direction direction, VertexLabel vertexLabel) { //if the direction is OUT then the vertexLabel must be in the same schema as the edgeLabel (this) if (direction == Direction.OUT) { Preconditions.checkState(vertexLabel.getSchema().equals(getSchema()), "For Direction.OUT the VertexLabel must be in the same schema as the edge. Found %s and %s", vertexLabel.getSchema().getName(), getSchema().getName()); } SchemaTable foreignKey = SchemaTable.of(vertexLabel.getSchema().getName(), vertexLabel.getLabel() + (direction == Direction.IN ? Topology.IN_VERTEX_COLUMN_END : Topology.OUT_VERTEX_COLUMN_END)); if (!foreignKeysContains(direction, vertexLabel)) { //Make sure the current thread/transaction owns the lock Schema schema = this.getSchema(); schema.getTopology().lock(); if (!foreignKeysContains(direction, vertexLabel)) { TopologyManager.addLabelToEdge(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), direction == Direction.IN, foreignKey); if (direction == Direction.IN) { this.uncommittedInVertexLabels.add(vertexLabel); vertexLabel.addToUncommittedInEdgeLabels(schema, this); } else { this.uncommittedOutVertexLabels.add(vertexLabel); vertexLabel.addToUncommittedOutEdgeLabels(schema, this); } SchemaTable vertexSchemaTable = SchemaTable.of(vertexLabel.getSchema().getName(), vertexLabel.getLabel()); addEdgeForeignKey(schema.getName(), EDGE_PREFIX + getLabel(), foreignKey, vertexSchemaTable); this.getSchema().getTopology().fire(this, vertexSchemaTable.toString(), TopologyChangeAction.ADD_IN_VERTEX_LABELTO_EDGE); } } }
public void ensureEdgeVertexLabelExist(Direction direction, VertexLabel vertexLabel) { //if the direction is OUT then the vertexLabel must be in the same schema as the edgeLabel (this) if (direction == Direction.OUT) { Preconditions.checkState(vertexLabel.getSchema().equals(getSchema()), "For Direction.OUT the VertexLabel must be in the same schema as the edge. Found %s and %s", vertexLabel.getSchema().getName(), getSchema().getName()); } SchemaTable foreignKey = SchemaTable.of(vertexLabel.getSchema().getName(), vertexLabel.getLabel() + (direction == Direction.IN ? Topology.IN_VERTEX_COLUMN_END : Topology.OUT_VERTEX_COLUMN_END)); if (!foreignKeysContains(direction, vertexLabel)) { //Make sure the current thread/transaction owns the lock Schema schema = this.getSchema(); schema.getTopology().lock(); if (!foreignKeysContains(direction, vertexLabel)) { TopologyManager.addLabelToEdge(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), direction == Direction.IN, foreignKey); if (direction == Direction.IN) { this.uncommittedInVertexLabels.add(vertexLabel); vertexLabel.addToUncommittedInEdgeLabels(schema, this); } else { this.uncommittedOutVertexLabels.add(vertexLabel); vertexLabel.addToUncommittedOutEdgeLabels(schema, this); } SchemaTable vertexSchemaTable = SchemaTable.of(vertexLabel.getSchema().getName(), vertexLabel.getLabel()); addEdgeForeignKey(schema.getName(), EDGE_PREFIX + getLabel(), foreignKey, vertexSchemaTable); this.getSchema().getTopology().fire(this, vertexSchemaTable.toString(), TopologyChangeAction.ADD_IN_VERTEX_LABELTO_EDGE); } } }