A VoltDB extension to support the assume unique attribute
337383
Statement compileAlterTableAddUniqueConstraint(Table table,
            HsqlName name, boolean assumeUnique) {
    /* disable 2 lines ...
    Statement compileAlterTableAddUniqueConstraint(Table table,
            HsqlName name) {
    ... disabled 2 lines */
    // End of VoltDB extension

        if (name == null) {
            name = database.nameManager.newAutoName("CT",
                    table.getSchemaName(), table.getName(),
                    SchemaObject.CONSTRAINT);
        }

        // A VoltDB extension to support indexed expressions.
        java.util.List<Expression> indexExprs = XreadExpressions(null);
        OrderedHashSet set = getSimpleColumnNames(indexExprs);
        int[] cols = getColumnList(set, table);
        if ((indexExprs != null) && (cols == null)) {
            // Not just indexing columns.
            // The meaning of cols shifts here to be
            // the set of unique base columns for the indexed expressions.
            set = getBaseColumnNames(indexExprs);
            cols = getColumnList(set, table);
        }
        /* disable 1 line ...
        int[] cols = this.readColumnList(table, false);
        ... disabled 1 line */
        // End of VoltDB extension
        String   sql  = getLastPart();
        //  and indexed expressions
        Object[] args = new Object[] {
            cols, name, indexExprs,
            Boolean.valueOf(assumeUnique)
        };
        /* disable 3 lines ...
        Object[] args = new Object[] {
            cols, name
        };
        .. disabled 3 lines */
        // End of VoltDB extension

        return new StatementSchema(sql, StatementTypes.ALTER_TABLE, args,
                                   null, table.getName());
    }
1191119
def ensure_attribute_uniqueness(associates_attribute_names, attribute_names)
      attribute_names.each do |attribute_name|
        if associates_attribute_names.include?(attribute_name)
          raise NameError, "already defined attribute name '#{attribute_name}' for #{name}(#{object_id})"
        end
      end
    end
1258940
private void buildAttributeValueObject(final String name) {
	attrval.name = name;
	attrval.quality = AttrQuality.ATTR_VALID;
	attrval.time = new TimeVal();
	attrval.r_dim = new AttributeDim();
	attrval.w_dim = new AttributeDim();
	attrval.r_dim.dim_x = 1;
	attrval.r_dim.dim_y = 0;
	attrval.w_dim.dim_x = 0;
	attrval.w_dim.dim_y = 0;
	try {
	    attrval.value = ApiUtil.get_orb().create_any();
	} catch (final DevFailed e) {
	}

	final long now = System.currentTimeMillis();
	attrval.time.tv_sec = (int) (now / 1000);
	attrval.time.tv_usec = (int) (now - attrval.time.tv_sec * 1000) * 1000;
	attrval.time.tv_nsec = 0;
	attrval.err_list = null;
    }
698975
private void validateUniqueAttribute(String entityType, String attributeName) throws AtlasException {
        ClassType type = typeSystem.getDataType(ClassType.class, entityType);
        AttributeInfo attribute = type.fieldMapping().fields.get(attributeName);
        if(attribute == null) {
            throw new IllegalArgumentException(
                String.format("%s is not an attribute in %s", attributeName, entityType));
        }
        if (!attribute.isUnique) {
            throw new IllegalArgumentException(
                    String.format("%s.%s is not a unique attribute", entityType, attributeName));
        }
    }
642317
def unique(iterable, key=identity):
    """"""
    seen = set()
    for item in iterable:
        item_key = key(item)
        if item_key not in seen:
            seen.add(item_key)
            yield item
1267206
VoltTable executePrecompiledSQL(Statement catStmt, Object[] params, boolean replicated)
            throws VoltAbortException {
        // Create a SQLStmt instance on the fly
        // This is unusual to do, as they are typically required to be final instance variables.
        // This only works because the SQL text and plan is identical from the borrowed procedure.
        SQLStmt stmt = new SQLStmt(catStmt.getSqltext());
        if (replicated) {
            stmt.setInCatalog(false);
        }
        m_runner.initSQLStmt(stmt, catStmt);

        voltQueueSQL(stmt, params);
        return voltExecuteSQL()[0];
    }
6675
function idUnique(a) {
  var i,j,l=a.length,p,
      guid=(Math.random()*1E10).toString(32)+(+new Date).toString(32);
  for (i=j=0;i<l;i++) {
    p = a[i];
    if (p==null) continue;
    if (p.hasOwnProperty(guid)) continue;
    Object.defineProperty(p,guid,{
      value:1,enumerable:false
    });
    a[j++]=p;
  }
  i=j;
  while (i--) {//clean guid
    a[i][guid]=undefined;
  }
  a.length=j;
  return a;
}
131239
def unique(self, e, **kwargs):
        
        if not isinstance(e, claripy.ast.Base):
            return True

        # if we don't want to do symbolic checks, assume symbolic variables are multivalued
        if o.SYMBOLIC not in self.state.options and self.symbolic(e):
            return False

        r = self.eval_upto(e, 2, **kwargs)
        if len(r) == 1:
            self.add(e == r[0])
            return True
        elif len(r) == 0:
            raise SimValueError("unsatness during uniqueness check(ness)")
        else:
            return False
526643
private void updateUnique(EntityType entityType, Attribute attr, Attribute updatedAttr) {
    if (attr.isUnique() && !updatedAttr.isUnique()) {
      Attribute idAttr = entityType.getIdAttribute();
      if (idAttr != null && idAttr.getName().equals(attr.getName())) {
        throw new MolgenisDataException(
            format(
                "ID attribute [%s] of entity [%s] must be unique",
                attr.getName(), entityType.getId()));
      }

      dropUniqueKey(entityType, updatedAttr);
    } else if (!attr.isUnique() && updatedAttr.isUnique()) {
      createUniqueKey(entityType, updatedAttr);
    }
  }
793859
void readColumnConstraints(Table table, ColumnSchema column,
                               HsqlArrayList constraintList) {

        boolean end = false;
        boolean isAutogeneratedName = true;

        while (true) {
            HsqlName constName = null;

            if (token.tokenType == Tokens.CONSTRAINT) {
                read();

                constName = readNewDependentSchemaObjectName(table.getName(),
                        SchemaObject.CONSTRAINT);
                isAutogeneratedName = false;
            }

            // A VoltDB extension to support indexed expressions and the assume unique attribute
            boolean assumeUnique = false; // For VoltDB
            // End of VoltDB extension
            switch (token.tokenType) {

                case Tokens.PRIMARY : {
                    read();
                    readThis(Tokens.KEY);

                    Constraint existingConst =
                        (Constraint) constraintList.get(0);

                    if (existingConst.constType == Constraint.PRIMARY_KEY) {
                        throw Error.error(ErrorCode.X_42532);
                    }

                    OrderedHashSet set = new OrderedHashSet();

                    set.add(column.getName().name);

                    if (constName == null) {
                        constName = database.nameManager.newAutoName("PK",
                                table.getSchemaName(), table.getName(),
                                SchemaObject.CONSTRAINT);
                    }

                    Constraint c = new Constraint(constName, isAutogeneratedName, set,
                                                  Constraint.PRIMARY_KEY);

                    constraintList.set(0, c);
                    column.setPrimaryKey(true);

                    break;
                }
                // A VoltDB extension to support indexed expressions and the assume unique attribute
                case Tokens.ASSUMEUNIQUE :
                    assumeUnique = true;
                    // $FALL-THROUGH$
                // End of VoltDB extension
                case Tokens.UNIQUE : {
                    read();

                    OrderedHashSet set = new OrderedHashSet();

                    set.add(column.getName().name);

                    if (constName == null) {
                        constName = database.nameManager.newAutoName("CT",
                                table.getSchemaName(), table.getName(),
                                SchemaObject.CONSTRAINT);
                    }

                    Constraint c = new Constraint(constName, isAutogeneratedName, set,
                                                  Constraint.UNIQUE);
                    // A VoltDB extension to support indexed expressions and the assume unique attribute
                    c.setAssumeUnique(assumeUnique);
                    // End of VoltDB extension

                    constraintList.add(c);

                    break;
                }
                case Tokens.FOREIGN : {
                    read();
                    readThis(Tokens.KEY);
                }

                // $FALL-THROUGH$
                case Tokens.REFERENCES : {
                    OrderedHashSet set = new OrderedHashSet();

                    set.add(column.getName().name);

                    Constraint c = readFKReferences(table, constName, set);

                    constraintList.add(c);

                    break;
                }
                case Tokens.CHECK : {
                    read();

                    if (constName == null) {
                        constName = database.nameManager.newAutoName("CT",
                                table.getSchemaName(), table.getName(),
                                SchemaObject.CONSTRAINT);
                    }

                    Constraint c = new Constraint(constName, isAutogeneratedName, null,
                                                  Constraint.CHECK);

                    readCheckConstraintCondition(c);

                    OrderedHashSet set = c.getCheckColumnExpressions();

                    for (int i = 0; i < set.size(); i++) {
                        ExpressionColumn e = (ExpressionColumn) set.get(i);

                        if (column.getName().name.equals(e.getColumnName())) {
                            if (e.getSchemaName() != null
                                    && e.getSchemaName()
                                       != table.getSchemaName().name) {
                                throw Error.error(ErrorCode.X_42505);
                            }
                        } else {
                            throw Error.error(ErrorCode.X_42501);
                        }
                    }

                    constraintList.add(c);

                    break;
                }
                case Tokens.NOT : {
                    read();
                    readThis(Tokens.NULL);

                    if (constName == null) {
                        constName = database.nameManager.newAutoName("CT",
                                table.getSchemaName(), table.getName(),
                                SchemaObject.CONSTRAINT);
                    }

                    Constraint c = new Constraint(constName, isAutogeneratedName, null,
                                                  Constraint.CHECK);

                    c.check = new ExpressionLogical(column);

                    constraintList.add(c);

                    break;
                }
                default :
                    end = true;
                    break;
            }

            if (end) {
                break;
            }
        }
    }
741984
function getUniqueIdentifier( root, libs, com ) {
  var id = root.attribs.id || ( com.name + ID++ );
  com.attr.id = id;
}
573656
private Integer getUniqueId(Object object) {
    Integer id = idCache.get(object);
    if (id == null) {
      id = uidGenerator.incrementAndGet();
      Integer existing = idCache.putIfAbsent(object, id);
      if (existing != null) {
        return existing;
      }
    }
    return id;
  }
486097
def attribute_invoked(self, sender, name, args, kwargs):
        ""
        return ExpectationBuilder(self.sender, self.delegate, self.add_invocation, self.add_expectations, '__call__')(*args, **kwargs)
163647
function(key, value, options) {
            var attrs, subattrs, scope, changes, newattributes, diffs;

            // Handle both `"key", value` and `{key: value}` -style arguments.
            if (typeof key === 'object') {
                attrs = key;
                options = value;
            } else {
                attrs = {};
                scope = key.split(".");
                subattrs = attrs;
                for (var i in scope) {
                    var key = scope[i];
                    if (i == (scope.length - 1)) {
                        subattrs[key] = value;
                    } else {
                        subattrs[key] = {};
                        subattrs = subattrs[key];
                    }
                }
            }

            // Define options
            options = _.defaults(options || {}, {
                silent: false
            });

            // Calcul new attributes
            newattributes = _.deepExtend({}, this.attributes || {}, attrs);
            if (!options.silent) {
                diffs = jsondiffpatch.diff(this._prevAttributes || {}, newattributes);
            }
            this.attributes = newattributes;
            this._prevAttributes = _.deepClone(this.attributes);

            // New unique id
            var oldId = this.id;
            if (this.idAttribute in this.attributes) {
                this.id = this.attributes[this.idAttribute];
            } else {
                this.id = this.cid;
            }
            if (oldId != this.id) this.trigger("id", this.id, oldId);

            // Calcul diffs
            if (!options.silent) {
                diffs = _.diffkeys(diffs);
                _.each(diffs, function(tag) {
                    this.trigger("change:"+tag, tag);
                }, this);
                if (diffs.length > 0) this.trigger("set", diffs);
            }

            return this;
        }
33893
def _handle_exists(self, node, scope, ctxt, stream):
        
        res = fields.Int()
        try:
            self._handle_node(node.expr, scope, ctxt, stream)
            res._pfp__set_value(1)
        except AttributeError:
            res._pfp__set_value(0)
        return res
431038
def set(attribute_name, value, &block)
      # Assign, without the =
      attribute_name = attribute_name.to_sym

      check_valid_field_name(attribute_name)

      old_value = @attributes[attribute_name]
      new_value = wrap_value(value, [attribute_name])

      if old_value != new_value
        # Track the old value, skip if we are in no_validate
        attribute_will_change!(attribute_name, old_value) unless Volt.in_mode?(:no_change_tracking)

        # Assign the new value
        @attributes[attribute_name] = new_value

        @deps.changed!(attribute_name)

        @size_dep.changed! if old_value.nil? || new_value.nil?

        # TODO: Can we make this so it doesn't need to be handled for non store collections
        # (maybe move it to persistor, though thats weird since buffers don't have a persistor)
        clear_server_errors(attribute_name) if @server_errors.present?

        # Save the changes
        run_changed(attribute_name) unless Volt.in_mode?(:no_change_tracking)
      end

      new_value
    end
785812
private AttributeUpdate generateBackpointerRemoval(long fromOffset) {
        return new AttributeUpdate(getBackpointerAttributeKey(fromOffset), AttributeUpdateType.Replace, Attributes.NULL_ATTRIBUTE_VALUE);
    }