private void distribute(int shard_count, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); Connection conn = sqlgGraph.tx().getConnection(); if (shard_count > -1) { try (Statement stmt = conn.createStatement()) { String sql = "SET citus.shard_count = " + shard_count + ";"; logger.debug(sql); stmt.execute(sql); } catch (SQLException e) { throw new RuntimeException(e); } } distribute(conn, distributionPropertyColumn, colocate); }
private void distribute(int shard_count, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); Connection conn = sqlgGraph.tx().getConnection(); if (shard_count > -1) { try (Statement stmt = conn.createStatement()) { String sql = "SET citus.shard_count = " + shard_count + ";"; logger.debug(sql); stmt.execute(sql); } catch (SQLException e) { throw new RuntimeException(e); } } distribute(conn, distributionPropertyColumn, colocate); }
abstractLabel = vertexLabel.get(); Preconditions.checkArgument(abstractLabel.getIdentifiers().size() == identifiers.length, "%d identifiers expected in the RecordId. Found %d. given id = %s", abstractLabel.getIdentifiers().size(), identifiers.length, label + id); ListOrderedSet<Comparable> identifierValues = new ListOrderedSet<>(); int count = 0; for (String identifier : abstractLabel.getIdentifiers()) { Optional<PropertyColumn> propertyColumn = abstractLabel.getProperty(identifier); if (propertyColumn.isPresent()) {
abstractLabel = vertexLabel.get(); Preconditions.checkArgument(abstractLabel.getIdentifiers().size() == identifiers.length, "%d identifiers expected in the RecordId. Found %d. given id = %s", abstractLabel.getIdentifiers().size(), identifiers.length, label + id); ListOrderedSet<Comparable> identifierValues = new ListOrderedSet<>(); int count = 0; for (String identifier : abstractLabel.getIdentifiers()) { Optional<PropertyColumn> propertyColumn = abstractLabel.getProperty(identifier); if (propertyColumn.isPresent()) {
Schema schema = this.sqlgGraph.getTopology().getSchema(this.schema).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found.", this.schema))); AbstractLabel abstractLabel = getAbstractLabel(schema); for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(identifier)); sql.append(" = ?");
Schema schema = this.sqlgGraph.getTopology().getSchema(this.schema).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found.", this.schema))); AbstractLabel abstractLabel = getAbstractLabel(schema); for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(identifier)); sql.append(" = ?");
Schema schema = this.sqlgGraph.getTopology().getSchema(this.schema).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found.", this.schema))); abstractLabel = getAbstractLabel(schema); for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.schema + "." + this.table + "." + identifier + (direction == Direction.OUT ? Topology.OUT_VERTEX_COLUMN_END : Topology.IN_VERTEX_COLUMN_END))); sql.append(" = ?");
Schema schema = this.sqlgGraph.getTopology().getSchema(this.schema).orElseThrow(() -> new IllegalStateException(String.format("Schema %s not found.", this.schema))); abstractLabel = getAbstractLabel(schema); for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.schema + "." + this.table + "." + identifier + (direction == Direction.OUT ? Topology.OUT_VERTEX_COLUMN_END : Topology.IN_VERTEX_COLUMN_END))); sql.append(" = ?");
} else { int count = 1; for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(identifier)); sql.append(" = ?"); if (count++ < abstractLabel.getIdentifiers().size()) { sql.append(" AND ");
} else { int count = 1; for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(identifier)); sql.append(" = ?"); if (count++ < abstractLabel.getIdentifiers().size()) { sql.append(" AND ");
public void ensureDistributed(int shardCount, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).isPresent(), "distributionPropertyColumn \"%s\" not found.", distributionPropertyColumn.getName()); Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).get().equals(distributionPropertyColumn), "distributionPropertyColumn \"%s\" must be a property of \"%s\"", distributionPropertyColumn.getName(), this.getFullName()); Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); if (!this.isDistributed()) { this.getSchema().getTopology().lock(); if (!this.isDistributed()) { TopologyManager.distributeAbstractLabel(this.sqlgGraph, this, shardCount, distributionPropertyColumn, colocate); distribute(shardCount, distributionPropertyColumn, colocate); this.uncommittedDistributionPropertyColumn = distributionPropertyColumn; this.uncommittedDistributionColocateAbstractLabel = colocate; this.uncommittedShardCount = shardCount; } } }
} else { int count = 1; for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(identifier)); sql.append(" = ?"); if (count++ < abstractLabel.getIdentifiers().size()) { sql.append(" AND "); preparedStatement.setLong(idx, ((RecordId) this.id()).sequenceId()); } else { for (String identifier : abstractLabel.getIdentifiers()) { keyValue = new HashMap<>(abstractLabel.getIdentifiers().size()); keyValue.put(identifier, value(identifier)); idx = setKeyValuesAsParameter(this.sqlgGraph, idx, preparedStatement, keyValue);
} else { int count = 1; for (String identifier : abstractLabel.getIdentifiers()) { sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(identifier)); sql.append(" = ?"); if (count++ < abstractLabel.getIdentifiers().size()) { sql.append(" AND "); preparedStatement.setLong(idx, ((RecordId) this.id()).sequenceId()); } else { for (String identifier : abstractLabel.getIdentifiers()) { keyValue = new HashMap<>(abstractLabel.getIdentifiers().size()); keyValue.put(identifier, value(identifier)); idx = setKeyValuesAsParameter(this.sqlgGraph, idx, preparedStatement, keyValue);
public void ensureDistributed(int shardCount, PropertyColumn distributionPropertyColumn, AbstractLabel colocate) { Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).isPresent(), "distributionPropertyColumn \"%s\" not found.", distributionPropertyColumn.getName()); Preconditions.checkState(getProperty(distributionPropertyColumn.getName()).get().equals(distributionPropertyColumn), "distributionPropertyColumn \"%s\" must be a property of \"%s\"", distributionPropertyColumn.getName(), this.getFullName()); Preconditions.checkArgument(getIdentifiers().contains(distributionPropertyColumn.getName()), "The distribution column must be part of the primary key"); if (!this.isDistributed()) { this.getSchema().getTopology().lock(); if (!this.isDistributed()) { TopologyManager.distributeAbstractLabel(this.sqlgGraph, this, shardCount, distributionPropertyColumn, colocate); distribute(shardCount, distributionPropertyColumn, colocate); this.uncommittedDistributionPropertyColumn = distributionPropertyColumn; this.uncommittedDistributionColocateAbstractLabel = colocate; this.uncommittedShardCount = shardCount; } } }