@Override AbstractLabel getAbstractLabel(Schema schema) { return schema.getEdgeLabel(this.table).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel %s not found.", this.table))); } }
@Override AbstractLabel getAbstractLabel(Schema schema) { return schema.getEdgeLabel(this.table).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel %s not found.", this.table))); } }
public Optional<EdgeLabel> getEdgeLabel(String schemaName, String edgeLabelName) { Preconditions.checkArgument(!edgeLabelName.startsWith(EDGE_PREFIX), "edge label name may not start with %s", EDGE_PREFIX); Optional<Schema> schemaOptional = getSchema(schemaName); if (schemaOptional.isPresent()) { Schema schema = schemaOptional.get(); return schema.getEdgeLabel(edgeLabelName); } else { return Optional.empty(); } }
public Optional<EdgeLabel> getEdgeLabel(String schemaName, String edgeLabelName) { Preconditions.checkArgument(!edgeLabelName.startsWith(EDGE_PREFIX), "edge label name may not start with %s", EDGE_PREFIX); Optional<Schema> schemaOptional = getSchema(schemaName); if (schemaOptional.isPresent()) { Schema schema = schemaOptional.get(); return schema.getEdgeLabel(edgeLabelName); } else { return Optional.empty(); } }
void ensureEdgeColumnsExist(String label, Map<String, PropertyType> columns) { Preconditions.checkArgument(!label.startsWith(EDGE_PREFIX), "label may not start with \"%s\"", EDGE_PREFIX); Preconditions.checkState(!isSqlgSchema(), "Schema.ensureEdgePropertiesExist may not be called for \"%s\"", SQLG_SCHEMA); Optional<EdgeLabel> edgeLabel = getEdgeLabel(label); Preconditions.checkState(edgeLabel.isPresent(), "BUG: edgeLabel \"%s\" must exist", label); //noinspection OptionalGetWithoutIsPresent edgeLabel.get().ensurePropertiesExist(columns); }
void ensureEdgeColumnsExist(String label, Map<String, PropertyType> columns) { Preconditions.checkArgument(!label.startsWith(EDGE_PREFIX), "label may not start with \"%s\"", EDGE_PREFIX); Preconditions.checkState(!isSqlgSchema(), "Schema.ensureEdgePropertiesExist may not be called for \"%s\"", SQLG_SCHEMA); Optional<EdgeLabel> edgeLabel = getEdgeLabel(label); Preconditions.checkState(edgeLabel.isPresent(), "BUG: edgeLabel \"%s\" must exist", label); //noinspection OptionalGetWithoutIsPresent edgeLabel.get().ensurePropertiesExist(columns); }
Map<String, PropertyColumn> getPropertiesFor(SchemaTable schemaTable) { Preconditions.checkArgument(schemaTable.getTable().startsWith(VERTEX_PREFIX) || schemaTable.getTable().startsWith(EDGE_PREFIX), "label must start with \"%s\" or \"%s\"", Topology.VERTEX_PREFIX, Topology.EDGE_PREFIX); if (schemaTable.isVertexTable()) { Optional<VertexLabel> vertexLabelOptional = getVertexLabel(schemaTable.withOutPrefix().getTable()); if (vertexLabelOptional.isPresent()) { return vertexLabelOptional.get().getProperties(); } } else { Optional<EdgeLabel> edgeLabelOptional = getEdgeLabel(schemaTable.withOutPrefix().getTable()); if (edgeLabelOptional.isPresent()) { return edgeLabelOptional.get().getProperties(); } } return Collections.emptyMap(); }
Map<String, PropertyType> getTableFor(SchemaTable schemaTable) { Preconditions.checkArgument(schemaTable.getTable().startsWith(VERTEX_PREFIX) || schemaTable.getTable().startsWith(EDGE_PREFIX), "label must start with \"%s\" or \"%s\"", VERTEX_PREFIX, EDGE_PREFIX); if (schemaTable.isVertexTable()) { Optional<VertexLabel> vertexLabelOptional = getVertexLabel(schemaTable.withOutPrefix().getTable()); if (vertexLabelOptional.isPresent()) { return vertexLabelOptional.get().getPropertyTypeMap(); } } else { Optional<EdgeLabel> edgeLabelOptional = getEdgeLabel(schemaTable.withOutPrefix().getTable()); if (edgeLabelOptional.isPresent()) { return edgeLabelOptional.get().getPropertyTypeMap(); } } return Collections.emptyMap(); }
Map<String, PropertyColumn> getPropertiesWithGlobalUniqueIndexFor(SchemaTable schemaTable) { Preconditions.checkArgument(schemaTable.getTable().startsWith(VERTEX_PREFIX) || schemaTable.getTable().startsWith(EDGE_PREFIX), "label must start with \"%s\" or \"%s\"", VERTEX_PREFIX, EDGE_PREFIX); if (schemaTable.isVertexTable()) { Optional<VertexLabel> vertexLabelOptional = getVertexLabel(schemaTable.withOutPrefix().getTable()); if (vertexLabelOptional.isPresent()) { return vertexLabelOptional.get().getGlobalUniqueIndexProperties(); } } else { Optional<EdgeLabel> edgeLabelOptional = getEdgeLabel(schemaTable.withOutPrefix().getTable()); if (edgeLabelOptional.isPresent()) { return edgeLabelOptional.get().getGlobalUniqueIndexProperties(); } } return Collections.emptyMap(); }
Map<String, PropertyType> getTableFor(SchemaTable schemaTable) { Preconditions.checkArgument(schemaTable.getTable().startsWith(VERTEX_PREFIX) || schemaTable.getTable().startsWith(EDGE_PREFIX), "label must start with \"%s\" or \"%s\"", VERTEX_PREFIX, EDGE_PREFIX); if (schemaTable.isVertexTable()) { Optional<VertexLabel> vertexLabelOptional = getVertexLabel(schemaTable.withOutPrefix().getTable()); if (vertexLabelOptional.isPresent()) { return vertexLabelOptional.get().getPropertyTypeMap(); } } else { Optional<EdgeLabel> edgeLabelOptional = getEdgeLabel(schemaTable.withOutPrefix().getTable()); if (edgeLabelOptional.isPresent()) { return edgeLabelOptional.get().getPropertyTypeMap(); } } return Collections.emptyMap(); }
Map<String, PropertyColumn> getPropertiesFor(SchemaTable schemaTable) { Preconditions.checkArgument(schemaTable.getTable().startsWith(VERTEX_PREFIX) || schemaTable.getTable().startsWith(EDGE_PREFIX), "label must start with \"%s\" or \"%s\"", Topology.VERTEX_PREFIX, Topology.EDGE_PREFIX); if (schemaTable.isVertexTable()) { Optional<VertexLabel> vertexLabelOptional = getVertexLabel(schemaTable.withOutPrefix().getTable()); if (vertexLabelOptional.isPresent()) { return vertexLabelOptional.get().getProperties(); } } else { Optional<EdgeLabel> edgeLabelOptional = getEdgeLabel(schemaTable.withOutPrefix().getTable()); if (edgeLabelOptional.isPresent()) { return edgeLabelOptional.get().getProperties(); } } return Collections.emptyMap(); }
Map<String, PropertyColumn> getPropertiesWithGlobalUniqueIndexFor(SchemaTable schemaTable) { Preconditions.checkArgument(schemaTable.getTable().startsWith(VERTEX_PREFIX) || schemaTable.getTable().startsWith(EDGE_PREFIX), "label must start with \"%s\" or \"%s\"", VERTEX_PREFIX, EDGE_PREFIX); if (schemaTable.isVertexTable()) { Optional<VertexLabel> vertexLabelOptional = getVertexLabel(schemaTable.withOutPrefix().getTable()); if (vertexLabelOptional.isPresent()) { return vertexLabelOptional.get().getGlobalUniqueIndexProperties(); } } else { Optional<EdgeLabel> edgeLabelOptional = getEdgeLabel(schemaTable.withOutPrefix().getTable()); if (edgeLabelOptional.isPresent()) { return edgeLabelOptional.get().getGlobalUniqueIndexProperties(); } } return Collections.emptyMap(); }
Optional<EdgeLabel> edgeLabelOptional = this.getEdgeLabel(edgeLabelName); if (!edgeLabelOptional.isPresent()) { this.topology.lock(); edgeLabelOptional = this.getEdgeLabel(edgeLabelName); if (!edgeLabelOptional.isPresent()) { edgeLabel = this.createPartitionedEdgeLabel(
Optional<EdgeLabel> edgeLabelOptional = this.getEdgeLabel(edgeLabelName); if (!edgeLabelOptional.isPresent()) { this.topology.lock(); edgeLabelOptional = this.getEdgeLabel(edgeLabelName); if (!edgeLabelOptional.isPresent()) { edgeLabel = this.createEdgeLabel(edgeLabelName, outVertexLabel, inVertexLabel, columns, identifiers);
Optional<EdgeLabel> edgeLabelOptional = this.getEdgeLabel(edgeLabelName); if (!edgeLabelOptional.isPresent()) { this.topology.lock(); edgeLabelOptional = this.getEdgeLabel(edgeLabelName); if (!edgeLabelOptional.isPresent()) { edgeLabel = this.createEdgeLabel(edgeLabelName, outVertexLabel, inVertexLabel, columns, identifiers);
if (!vertexLabel.isPresent()) { Optional<EdgeLabel> edgeLabel = sqlgGraph.getTopology().getSchema(schemaTable.getSchema()).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found.", schemaTable.getSchema()))) .getEdgeLabel(schemaTable.getTable()); if (!edgeLabel.isPresent()) { throw new IllegalStateException(String.format("SchemaTable %s not found", schemaTable.toString()));
if (!vertexLabel.isPresent()) { Optional<EdgeLabel> edgeLabel = sqlgGraph.getTopology().getSchema(schemaTable.getSchema()).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found.", schemaTable.getSchema()))) .getEdgeLabel(schemaTable.getTable()); if (!edgeLabel.isPresent()) { throw new IllegalStateException(String.format("SchemaTable %s not found", schemaTable.toString()));
@SuppressWarnings("OptionalGetWithoutIsPresent") private EdgeLabel createEdgeLabel( final String edgeLabelName, final VertexLabel outVertexLabel, final VertexLabel inVertexLabel, final Map<String, PropertyType> columns, final ListOrderedSet<String> identifiers) { Preconditions.checkArgument(this.topology.isSqlWriteLockHeldByCurrentThread(), "Lock must be held by the thread to call createEdgeLabel"); Preconditions.checkArgument(!edgeLabelName.startsWith(EDGE_PREFIX), "edgeLabelName may not start with " + EDGE_PREFIX); Preconditions.checkState(!this.isSqlgSchema(), "createEdgeLabel may not be called for \"%s\"", SQLG_SCHEMA); Schema inVertexSchema = inVertexLabel.getSchema(); //Edge may not already exist. Preconditions.checkState(!getEdgeLabel(edgeLabelName).isPresent(), "BUG: Edge \"%s\" already exists!", edgeLabelName); SchemaTable foreignKeyOut = SchemaTable.of(this.name, outVertexLabel.getLabel()); SchemaTable foreignKeyIn = SchemaTable.of(inVertexSchema.name, inVertexLabel.getLabel()); TopologyManager.addEdgeLabel(this.sqlgGraph, this.getName(), EDGE_PREFIX + edgeLabelName, foreignKeyOut, foreignKeyIn, columns, identifiers); if (this.sqlgGraph.getSqlDialect().needsSchemaCreationPrecommit()) { try { this.sqlgGraph.tx().getConnection().commit(); } catch (SQLException e) { throw new RuntimeException(e); } } return outVertexLabel.addEdgeLabel(edgeLabelName, inVertexLabel, columns, identifiers); }
@SuppressWarnings("OptionalGetWithoutIsPresent") private EdgeLabel createEdgeLabel( final String edgeLabelName, final VertexLabel outVertexLabel, final VertexLabel inVertexLabel, final Map<String, PropertyType> columns, final ListOrderedSet<String> identifiers) { Preconditions.checkArgument(this.topology.isSqlWriteLockHeldByCurrentThread(), "Lock must be held by the thread to call createEdgeLabel"); Preconditions.checkArgument(!edgeLabelName.startsWith(EDGE_PREFIX), "edgeLabelName may not start with " + EDGE_PREFIX); Preconditions.checkState(!this.isSqlgSchema(), "createEdgeLabel may not be called for \"%s\"", SQLG_SCHEMA); Schema inVertexSchema = inVertexLabel.getSchema(); //Edge may not already exist. Preconditions.checkState(!getEdgeLabel(edgeLabelName).isPresent(), "BUG: Edge \"%s\" already exists!", edgeLabelName); SchemaTable foreignKeyOut = SchemaTable.of(this.name, outVertexLabel.getLabel()); SchemaTable foreignKeyIn = SchemaTable.of(inVertexSchema.name, inVertexLabel.getLabel()); TopologyManager.addEdgeLabel(this.sqlgGraph, this.getName(), EDGE_PREFIX + edgeLabelName, foreignKeyOut, foreignKeyIn, columns, identifiers); if (this.sqlgGraph.getSqlDialect().needsSchemaCreationPrecommit()) { try { this.sqlgGraph.tx().getConnection().commit(); } catch (SQLException e) { throw new RuntimeException(e); } } return outVertexLabel.addEdgeLabel(edgeLabelName, inVertexLabel, columns, identifiers); }
Preconditions.checkState(!getEdgeLabel(edgeLabelName).isPresent(), "BUG: Edge \"%s\" already exists!", edgeLabelName);