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(); }
private boolean hasNoEdgeLabels(SchemaTable schemaTable) { Optional<Schema> schemaOptional = sqlgGraph.getTopology().getSchema(schemaTable.getSchema()); Preconditions.checkState(schemaOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.getSchema()); Schema schema = schemaOptional.get(); boolean result = true; if (schemaTable.isVertexTable()) { //Need to delete any in/out edges. Optional<VertexLabel> vertexLabelOptional = schema.getVertexLabel(schemaTable.withOutPrefix().getTable()); Preconditions.checkState(vertexLabelOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.withOutPrefix().getTable()); VertexLabel vertexLabel = vertexLabelOptional.get(); Collection<EdgeLabel> outEdgeLabels = vertexLabel.getOutEdgeLabels().values(); Collection<EdgeLabel> inEdgeLabels = vertexLabel.getInEdgeLabels().values(); result = outEdgeLabels.isEmpty() && inEdgeLabels.isEmpty(); } return result; }
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(); }
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(); }
private boolean hasNoEdgeLabels(SchemaTable schemaTable) { Optional<Schema> schemaOptional = sqlgGraph.getTopology().getSchema(schemaTable.getSchema()); Preconditions.checkState(schemaOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.getSchema()); Schema schema = schemaOptional.get(); boolean result = true; if (schemaTable.isVertexTable()) { //Need to delete any in/out edges. Optional<VertexLabel> vertexLabelOptional = schema.getVertexLabel(schemaTable.withOutPrefix().getTable()); Preconditions.checkState(vertexLabelOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.withOutPrefix().getTable()); VertexLabel vertexLabel = vertexLabelOptional.get(); Collection<EdgeLabel> outEdgeLabels = vertexLabel.getOutEdgeLabels().values(); Collection<EdgeLabel> inEdgeLabels = vertexLabel.getInEdgeLabels().values(); result = outEdgeLabels.isEmpty() && inEdgeLabels.isEmpty(); } return result; }
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(); }
private Set<SchemaTableTree> calculatePathFromVertexToEdge(SchemaTableTree schemaTableTree, SchemaTable schemaTableTo, Direction direction, Map<SchemaTable, List<Multimap<BiPredicate, RecordId>>> groupedIds) { Set<SchemaTableTree> result = new HashSet<>(); //add the child for schemaTableTo to the tree SchemaTableTree schemaTableTree1 = schemaTableTree.addChild( schemaTableTo, direction, Vertex.class, this, this.labels ); SchemaTable schemaTable = SchemaTable.from(this.topology.getSqlgGraph(), schemaTableTo.toString()); List<Multimap<BiPredicate, RecordId>> biPredicateRecordIs = groupedIds.get(schemaTable.withOutPrefix()); addIdHasContainers(schemaTableTree1, biPredicateRecordIs); result.add(schemaTableTree1); return result; }
private Set<SchemaTableTree> calculatePathFromVertexToEdge(SchemaTableTree schemaTableTree, SchemaTable schemaTableTo, Direction direction, Map<SchemaTable, List<Multimap<BiPredicate, RecordId>>> groupedIds) { Set<SchemaTableTree> result = new HashSet<>(); //add the child for schemaTableTo to the tree SchemaTableTree schemaTableTree1 = schemaTableTree.addChild( schemaTableTo, direction, Vertex.class, this, this.labels ); SchemaTable schemaTable = SchemaTable.from(this.topology.getSqlgGraph(), schemaTableTo.toString()); List<Multimap<BiPredicate, RecordId>> biPredicateRecordIs = groupedIds.get(schemaTable.withOutPrefix()); addIdHasContainers(schemaTableTree1, biPredicateRecordIs); result.add(schemaTableTree1); return result; }
@SuppressWarnings("unchecked") Collection<String> predicateValues = (Collection<String>) predicateValue; SchemaTable schemaTableWithOutPrefix = SchemaTable.from(sqlgGraph, table).withOutPrefix(); for (String value : predicateValues) { if (!isVertex && !value.contains(".")) { if (!isVertex && !((String) predicateValue).contains(".")) { SchemaTable schemaTableWithOutPrefix = SchemaTable.from(sqlgGraph, table).withOutPrefix(); return biPredicate.test(schemaTableWithOutPrefix.getTable(), predicateValue); } else {
@SuppressWarnings("unchecked") Collection<String> predicateValues = (Collection<String>) predicateValue; SchemaTable schemaTableWithOutPrefix = SchemaTable.from(sqlgGraph, table).withOutPrefix(); for (String value : predicateValues) { if (!isVertex && !value.contains(".")) { if (!isVertex && !((String) predicateValue).contains(".")) { SchemaTable schemaTableWithOutPrefix = SchemaTable.from(sqlgGraph, table).withOutPrefix(); return biPredicate.test(schemaTableWithOutPrefix.getTable(), predicateValue); } else {
private boolean hasOnlyOneInOutEdgeLabel(SchemaTable schemaTable) { Optional<Schema> schemaOptional = sqlgGraph.getTopology().getSchema(schemaTable.getSchema()); Preconditions.checkState(schemaOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.getSchema()); Schema schema = schemaOptional.get(); boolean result = true; if (schemaTable.isVertexTable()) { //Need to delete any in/out edges. Optional<VertexLabel> vertexLabelOptional = schema.getVertexLabel(schemaTable.withOutPrefix().getTable()); Preconditions.checkState(vertexLabelOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.withOutPrefix().getTable()); VertexLabel vertexLabel = vertexLabelOptional.get(); Collection<EdgeLabel> outEdgeLabels = vertexLabel.getOutEdgeLabels().values(); for (EdgeLabel edgeLabel : outEdgeLabels) { result = edgeLabel.getOutVertexLabels().size() == 1; if (!result) { break; } } if (result) { Collection<EdgeLabel> inEdgeLabels = vertexLabel.getInEdgeLabels().values(); for (EdgeLabel edgeLabel : inEdgeLabels) { result = edgeLabel.getInVertexLabels().size() == 1; if (!result) { break; } } } } return result; }
private boolean hasOnlyOneInOutEdgeLabel(SchemaTable schemaTable) { Optional<Schema> schemaOptional = sqlgGraph.getTopology().getSchema(schemaTable.getSchema()); Preconditions.checkState(schemaOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.getSchema()); Schema schema = schemaOptional.get(); boolean result = true; if (schemaTable.isVertexTable()) { //Need to delete any in/out edges. Optional<VertexLabel> vertexLabelOptional = schema.getVertexLabel(schemaTable.withOutPrefix().getTable()); Preconditions.checkState(vertexLabelOptional.isPresent(), "BUG: %s not found in the topology.", schemaTable.withOutPrefix().getTable()); VertexLabel vertexLabel = vertexLabelOptional.get(); Collection<EdgeLabel> outEdgeLabels = vertexLabel.getOutEdgeLabels().values(); for (EdgeLabel edgeLabel : outEdgeLabels) { result = edgeLabel.getOutVertexLabels().size() == 1; if (!result) { break; } } if (result) { Collection<EdgeLabel> inEdgeLabels = vertexLabel.getInEdgeLabels().values(); for (EdgeLabel edgeLabel : inEdgeLabels) { result = edgeLabel.getInVertexLabels().size() == 1; if (!result) { break; } } } } return result; }
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))); }
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; } } }
List<Multimap<BiPredicate, RecordId>> biPredicateRecordIds = groupedIds.get(schemaTable.withOutPrefix()); if (biPredicateRecordIds != null) { for (Multimap<BiPredicate, RecordId> biPredicateRecordId : biPredicateRecordIds) {
this.labels ); List<Multimap<BiPredicate, RecordId>> biPredicateRecordIs = groupedIds.get(schemaTable.withOutPrefix()); addIdHasContainers(schemaTableTreeChild, biPredicateRecordIs); result.add(schemaTableTreeChild); this.labels ); List<Multimap<BiPredicate, RecordId>> biPredicateRecordIs = groupedIds.get(schemaTable.withOutPrefix()); addIdHasContainers(schemaTableTreeChild, biPredicateRecordIs); result.add(schemaTableTreeChild);
graph().getTopology().ensureEdgeLabelExist(Bdio.ObjectProperty.parent.name(), file.withOutPrefix(), file.withOutPrefix(), Maps.transformValues(traversalProperties, PropertyType::from)); .append(" (") .forEachAppend(traversalProperties.keySet().stream(), (k, s) -> s.maybeWrapInQuotes(k), ", ", "", ", ") .maybeWrapInQuotes(file.withOutPrefix() + IN_VERTEX_COLUMN_END) .append(", ") .maybeWrapInQuotes(file.withOutPrefix() + OUT_VERTEX_COLUMN_END) .append(")\n SELECT ") .forEachAppend(traversalProperties.values().stream(), (v, s) -> s.valueToValuesString(v), ", ", "", ", ")