@Override public void flushRemovedEdges(SqlgGraph sqlgGraph, Map<SchemaTable, List<SqlgEdge>> removeEdgeCache) { if (!removeEdgeCache.isEmpty()) { //split the list of edges, postgres existVertexLabel a 2 byte limit in the in clause for (Map.Entry<SchemaTable, List<SqlgEdge>> schemaEdges : removeEdgeCache.entrySet()) { SchemaTable schemaTable = schemaEdges.getKey(); EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(schemaTable.getSchema(), schemaTable.getTable()) .orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", schemaTable.getSchema(), schemaTable.getTable()))); //TODO refacor to remove looping. List<RecordId.ID> ids = new ArrayList<>(); for (SqlgEdge edge : schemaEdges.getValue()) { ids.add(((RecordId) edge.id()).getID()); } String sql = drop(edgeLabel, ids); if (logger.isDebugEnabled()) { logger.debug(sql); } Connection conn = sqlgGraph.tx().getConnection(); try (PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } } } }
@Override public void flushRemovedEdges(SqlgGraph sqlgGraph, Map<SchemaTable, List<SqlgEdge>> removeEdgeCache) { if (!removeEdgeCache.isEmpty()) { //split the list of edges, postgres existVertexLabel a 2 byte limit in the in clause for (Map.Entry<SchemaTable, List<SqlgEdge>> schemaEdges : removeEdgeCache.entrySet()) { SchemaTable schemaTable = schemaEdges.getKey(); EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(schemaTable.getSchema(), schemaTable.getTable()) .orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", schemaTable.getSchema(), schemaTable.getTable()))); //TODO refacor to remove looping. List<RecordId.ID> ids = new ArrayList<>(); for (SqlgEdge edge : schemaEdges.getValue()) { ids.add(((RecordId) edge.id()).getID()); } String sql = drop(edgeLabel, ids); if (logger.isDebugEnabled()) { logger.debug(sql); } Connection conn = sqlgGraph.tx().getConnection(); try (PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } } } }
this.tx().readWrite(); String[] schemaTable = labelUmlgParameter.getValue().split("\\."); Optional<EdgeLabel> edgeLabelOptional = this.sqlG.getTopology().getEdgeLabel(schemaTable[0], schemaTable[1]); Preconditions.checkState(edgeLabelOptional.isPresent()); edgeLabelOptional.get()
VertexLabel outVertexLabel = sqlgGraph.getTopology().getVertexLabel(outVertexLabelSchemaTable.getSchema(), outVertexLabelSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", outVertexLabelSchemaTable.getSchema(), outVertexLabelSchemaTable.getTable()))); VertexLabel inVertexLabel = sqlgGraph.getTopology().getVertexLabel(inSchemaTable.getSchema(), inSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", inSchemaTable.getSchema(), inSchemaTable.getTable()))); EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(outSchemaTable.getSchema(), sqlgEdge.getTable()).orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", outSchemaTable.getSchema(), sqlgEdge.getTable()))); MetaEdge metaEdge = MetaEdge.from(outSchemaTable, outVertex, inVertex); if (!streaming) {
for (MetaEdge metaEdge : edgeCache.keySet()) { SchemaTable schemaTable = metaEdge.getSchemaTable(); EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(schemaTable.getSchema(), schemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", schemaTable.getSchema(), schemaTable.getTable()))); Pair<SortedSet<String>, Map<SqlgEdge, Triple<SqlgVertex, SqlgVertex, Map<String, Object>>>> triples = edgeCache.get(metaEdge); try {
VertexLabel outVertexLabel = sqlgGraph.getTopology().getVertexLabel(outVertexLabelSchemaTable.getSchema(), outVertexLabelSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", outVertexLabelSchemaTable.getSchema(), outVertexLabelSchemaTable.getTable()))); VertexLabel inVertexLabel = sqlgGraph.getTopology().getVertexLabel(inSchemaTable.getSchema(), inSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", inSchemaTable.getSchema(), inSchemaTable.getTable()))); EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(outSchemaTable.getSchema(), sqlgEdge.getTable()).orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", outSchemaTable.getSchema(), sqlgEdge.getTable()))); MetaEdge metaEdge = MetaEdge.from(outSchemaTable, outVertex, inVertex); if (!streaming) {
private void process(SchemaTableTree rootSchemaTableTree) { SchemaTable table = rootSchemaTableTree.getSchemaTable(); Optional<? extends AbstractLabel> label; if (table.isVertexTable()) { label = sqlgGraph.getTopology().getVertexLabel(table.getSchema(), table.withOutPrefix().getTable()); } else if (table.isEdgeTable()) { label = sqlgGraph.getTopology().getEdgeLabel(table.getSchema(), table.withOutPrefix().getTable()); } else { label = Optional.empty(); } process(sqlgGraph, rootSchemaTableTree, label.orElseThrow(illegalState("unknown table: %s", table))); }
Preconditions.checkState(inSchemaVertex != null, "BUG: In schema vertex not found for edge \"%s\"", edgeLabelName); Optional<EdgeLabel> outEdgeLabelOptional = this.topology.getEdgeLabel(getName(), edgeLabelName); Preconditions.checkState(outEdgeLabelOptional.isPresent(), "BUG: EdgeLabel for \"%s\" should already be loaded", getName() + "." + edgeLabelName);
Preconditions.checkState(inSchemaVertex != null, "BUG: In schema vertex not found for edge \"%s\"", edgeLabelName); Optional<EdgeLabel> outEdgeLabelOptional = this.topology.getEdgeLabel(getName(), edgeLabelName); Preconditions.checkState(outEdgeLabelOptional.isPresent(), "BUG: EdgeLabel for \"%s\" should already be loaded", getName() + "." + edgeLabelName);
private void setIdentifiersAndDistributionColumn() { if (this.schemaTable.isVertexTable()) { VertexLabel vertexLabel = this.sqlgGraph.getTopology().getVertexLabel( this.schemaTable.withOutPrefix().getSchema(), this.schemaTable.withOutPrefix().getTable() ).orElseThrow(() -> new IllegalStateException(String.format("Label %s must ne present.", this.schemaTable.toString()))); this.identifiers = vertexLabel.getIdentifiers(); if (vertexLabel.isDistributed()) { this.distributionColumn = vertexLabel.getDistributionPropertyColumn().getName(); } else { this.distributionColumn = null; } } else { EdgeLabel edgeLabel = this.sqlgGraph.getTopology().getEdgeLabel( this.schemaTable.withOutPrefix().getSchema(), this.schemaTable.withOutPrefix().getTable() ).orElseThrow(() -> new IllegalStateException(String.format("Label %s must ne present.", this.schemaTable.toString()))); this.identifiers = edgeLabel.getIdentifiers(); if (edgeLabel.isDistributed()) { this.distributionColumn = edgeLabel.getDistributionPropertyColumn().getName(); } else { this.distributionColumn = null; } } }
private void setIdentifiersAndDistributionColumn() { if (this.schemaTable.isVertexTable()) { VertexLabel vertexLabel = this.sqlgGraph.getTopology().getVertexLabel( this.schemaTable.withOutPrefix().getSchema(), this.schemaTable.withOutPrefix().getTable() ).orElseThrow(() -> new IllegalStateException(String.format("Label %s must ne present.", this.schemaTable.toString()))); this.identifiers = vertexLabel.getIdentifiers(); if (vertexLabel.isDistributed()) { this.distributionColumn = vertexLabel.getDistributionPropertyColumn().getName(); } else { this.distributionColumn = null; } } else { EdgeLabel edgeLabel = this.sqlgGraph.getTopology().getEdgeLabel( this.schemaTable.withOutPrefix().getSchema(), this.schemaTable.withOutPrefix().getTable() ).orElseThrow(() -> new IllegalStateException(String.format("Label %s must ne present.", this.schemaTable.toString()))); this.identifiers = edgeLabel.getIdentifiers(); if (edgeLabel.isDistributed()) { this.distributionColumn = edgeLabel.getDistributionPropertyColumn().getName(); } else { this.distributionColumn = null; } } }
EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(metaEdge.getSchemaTable().getSchema(), metaEdge.getSchemaTable().getTable()).orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", metaEdge.getSchemaTable().getSchema(), metaEdge.getSchemaTable().getTable()))); VertexLabel outVertexLabel = sqlgGraph.getTopology().getVertexLabel(outSchemaTable.getSchema(), outSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", outSchemaTable.getSchema(), outSchemaTable.getTable()))); VertexLabel inVertexLabel = sqlgGraph.getTopology().getVertexLabel(inSchemaTable.getSchema(), inSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", inSchemaTable.getSchema(), inSchemaTable.getTable())));
EdgeLabel edgeLabel = sqlgGraph.getTopology().getEdgeLabel(metaEdge.getSchemaTable().getSchema(), metaEdge.getSchemaTable().getTable()).orElseThrow(() -> new IllegalStateException(String.format("EdgeLabel not found for %s.%s", metaEdge.getSchemaTable().getSchema(), metaEdge.getSchemaTable().getTable()))); VertexLabel outVertexLabel = sqlgGraph.getTopology().getVertexLabel(outSchemaTable.getSchema(), outSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", outSchemaTable.getSchema(), outSchemaTable.getTable()))); VertexLabel inVertexLabel = sqlgGraph.getTopology().getVertexLabel(inSchemaTable.getSchema(), inSchemaTable.getTable()).orElseThrow(() -> new IllegalStateException(String.format("VertexLabel not found for %s.%s", inSchemaTable.getSchema(), inSchemaTable.getTable())));
Edge edge = edges.next(); SchemaTable schemaTableEdge = ((SqlgEdge)edge).getSchemaTablePrefixed().withOutPrefix(); Optional<EdgeLabel> edgeLabelOptional = this.sqlgGraph.getTopology().getEdgeLabel(schemaTableEdge.getSchema(), schemaTableEdge.getTable()); Preconditions.checkState(edgeLabelOptional.isPresent()); added = this.edgesToDelete.put(edgeLabelOptional.get(), ((RecordId)edge.id()).getID()); Edge edge = edges.next(); SchemaTable schemaTableEdge = ((SqlgEdge)edge).getSchemaTablePrefixed().withOutPrefix(); Optional<EdgeLabel> edgeLabelOptional = this.sqlgGraph.getTopology().getEdgeLabel(schemaTableEdge.getSchema(), schemaTableEdge.getTable()); Preconditions.checkState(edgeLabelOptional.isPresent()); added = this.edgesToDelete.put(edgeLabelOptional.get(), ((RecordId)edge.id()).getID()); Optional<EdgeLabel> edgeLabelOptional = this.sqlgGraph.getTopology().getEdgeLabel(schemaTable.getSchema(), schemaTable.getTable()); Preconditions.checkState(edgeLabelOptional.isPresent()); boolean added = this.edgesToDelete.put(edgeLabelOptional.get(), id);
Edge edge = edges.next(); SchemaTable schemaTableEdge = ((SqlgEdge)edge).getSchemaTablePrefixed().withOutPrefix(); Optional<EdgeLabel> edgeLabelOptional = this.sqlgGraph.getTopology().getEdgeLabel(schemaTableEdge.getSchema(), schemaTableEdge.getTable()); Preconditions.checkState(edgeLabelOptional.isPresent()); added = this.edgesToDelete.put(edgeLabelOptional.get(), ((RecordId)edge.id()).getID()); Edge edge = edges.next(); SchemaTable schemaTableEdge = ((SqlgEdge)edge).getSchemaTablePrefixed().withOutPrefix(); Optional<EdgeLabel> edgeLabelOptional = this.sqlgGraph.getTopology().getEdgeLabel(schemaTableEdge.getSchema(), schemaTableEdge.getTable()); Preconditions.checkState(edgeLabelOptional.isPresent()); added = this.edgesToDelete.put(edgeLabelOptional.get(), ((RecordId)edge.id()).getID()); Optional<EdgeLabel> edgeLabelOptional = this.sqlgGraph.getTopology().getEdgeLabel(schemaTable.getSchema(), schemaTable.getTable()); Preconditions.checkState(edgeLabelOptional.isPresent()); boolean added = this.edgesToDelete.put(edgeLabelOptional.get(), id);