/** * Inserts the specified element at the specified position if it is not yet * contained in this ordered set (optional operation). Shifts the element * currently at this position and any subsequent elements to the right. * * @param index the index at which the element is to be inserted * @param object the element to be inserted * @see List#add(int, Object) */ public void add(final int index, final E object) { if (!contains(object)) { decorated().add(object); setOrder.add(index, object); } }
/** * Inserts all elements in the specified collection not yet contained in the * ordered set at the specified position (optional operation). Shifts the * element currently at the position and all subsequent elements to the * right. * * @param index the position to insert the elements * @param coll the collection containing the elements to be inserted * @return {@code true} if this ordered set changed as a result of the call * @see List#addAll(int, Collection) */ public boolean addAll(final int index, final Collection<? extends E> coll) { boolean changed = false; // collect all elements to be added for performance reasons final List<E> toAdd = new ArrayList<>(); for (final E e : coll) { if (contains(e)) { continue; } decorated().add(e); toAdd.add(e); changed = true; } if (changed) { setOrder.addAll(index, toAdd); } return changed; }
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); }
private static void printFromClauseFor(SchemaTableTree lastSchemaTableTree, ColumnList cols) { Map<String, PropertyType> propertyTypeMap = lastSchemaTableTree.getFilteredAllTables().get(lastSchemaTableTree.getSchemaTable().toString()); ListOrderedSet<String> identifiers = lastSchemaTableTree.getIdentifiers(); for (String identifier : identifiers) { PropertyType propertyType = propertyTypeMap.get(identifier); String alias = lastSchemaTableTree.calculateAliasPropertyName(identifier); cols.add(lastSchemaTableTree, identifier, alias); for (String postFix : propertyType.getPostFixes()) { alias = lastSchemaTableTree.calculateAliasPropertyName(identifier + postFix); cols.add(lastSchemaTableTree, identifier + postFix, alias); } } for (Map.Entry<String, PropertyType> propertyTypeMapEntry : propertyTypeMap.entrySet()) { if (!identifiers.contains(propertyTypeMapEntry.getKey())) { if (lastSchemaTableTree.shouldSelectProperty(propertyTypeMapEntry.getKey())) { String alias = lastSchemaTableTree.calculateAliasPropertyName(propertyTypeMapEntry.getKey()); cols.add(lastSchemaTableTree, propertyTypeMapEntry.getKey(), alias); for (String postFix : propertyTypeMapEntry.getValue().getPostFixes()) { alias = lastSchemaTableTree.calculateAliasPropertyName(propertyTypeMapEntry.getKey() + postFix); cols.add(lastSchemaTableTree, propertyTypeMapEntry.getKey() + postFix, alias); } } } } }
private static void printFromClauseFor(SchemaTableTree lastSchemaTableTree, ColumnList cols) { Map<String, PropertyType> propertyTypeMap = lastSchemaTableTree.getFilteredAllTables().get(lastSchemaTableTree.getSchemaTable().toString()); ListOrderedSet<String> identifiers = lastSchemaTableTree.getIdentifiers(); for (String identifier : identifiers) { PropertyType propertyType = propertyTypeMap.get(identifier); String alias = lastSchemaTableTree.calculateAliasPropertyName(identifier); cols.add(lastSchemaTableTree, identifier, alias); for (String postFix : propertyType.getPostFixes()) { alias = lastSchemaTableTree.calculateAliasPropertyName(identifier + postFix); cols.add(lastSchemaTableTree, identifier + postFix, alias); } } for (Map.Entry<String, PropertyType> propertyTypeMapEntry : propertyTypeMap.entrySet()) { if (!identifiers.contains(propertyTypeMapEntry.getKey())) { if (lastSchemaTableTree.shouldSelectProperty(propertyTypeMapEntry.getKey())) { String alias = lastSchemaTableTree.calculateAliasPropertyName(propertyTypeMapEntry.getKey()); cols.add(lastSchemaTableTree, propertyTypeMapEntry.getKey(), alias); for (String postFix : propertyTypeMapEntry.getValue().getPostFixes()) { alias = lastSchemaTableTree.calculateAliasPropertyName(propertyTypeMapEntry.getKey() + postFix); cols.add(lastSchemaTableTree, propertyTypeMapEntry.getKey() + postFix, alias); } } } } }
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; } } }
Preconditions.checkState(columns.containsKey(identifier), "The identifiers must be in the specified columns. \"%s\" not found", identifier); Preconditions.checkArgument(identifiers.contains(distributionColumn), "The distribution column must be an identifier.");
Preconditions.checkState(columns.containsKey(identifier), "The identifiers must be in the specified columns. \"%s\" not found", identifier); Preconditions.checkArgument(identifiers.contains(distributionColumn), "The distribution column must be an identifier.");