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); }
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; } } }
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; } } }