Returns the UNIQUE constraint with the given expression signature -- a VoltDB extension.
550767
Constraint getUniqueConstraintForExprs(Expression[] indexExprs) {
        for (int i = 0, size = constraintList.length; i < size; i++) {
            Constraint exprc = constraintList[i];

            if (exprc.isUniqueWithExprs(indexExprs)) {
                return exprc;
            }
        }
        return null;
    }
715278
public static <T> ConstraintViolation<T> forReturnValueValidation(final String messageTemplate,
      final Map<String, Object> messageParameters, final Map<String, Object> expressionVariables,
      final String interpolatedMessage, final Class<T> rootBeanClass, final T rootBean,
      final Object leafBeanInstance, final Object value, final Path propertyPath,
      final ConstraintDescriptor<?> constraintDescriptor, final ElementType elementType,
      final Object executableReturnValue, final Object dynamicPayload) {
    return new ConstraintViolationImpl<>(messageTemplate, messageParameters, expressionVariables,
        interpolatedMessage, rootBeanClass, rootBean, leafBeanInstance, value, propertyPath,
        constraintDescriptor, elementType, null, executableReturnValue, dynamicPayload);
  }
408514
private void addUniqueConstraintForTableBasedSequence(List<Statement> statements, IdSourceKeyMetadata generatorKeyMetadata) {
		Statement statement = createUniqueConstraintStatement( generatorKeyMetadata.getKeyColumnName(), generatorKeyMetadata.getName() );
		statements.add( statement );
	}
450427
public function getSchemaUniqueConstraints($conn = null)
    {
        $command = $this->invoke('neo.get_constraints_command', $conn);
        $httpResponse = $command->execute();

        $responseO = $this->handleHttpResponse($httpResponse);
        $response = $responseO->getBody();
        $constraints = [];
        foreach ($response as $constraint) {
            foreach ($constraint['property_keys'] as $key) {
                $constraints[] = new UniqueConstraint($constraint['label'], $key);
            }
        }

        return $constraints;
    }
1270970
def create_query_constraint():
    
    op = oneOf("= < > >= <= != <>", caseless=True).setName("operator")
    basic_constraint = (var + op + var_val).setResultsName("operator")
    between = (
        var + Suppress(upkey("between")) + value + Suppress(and_) + value
    ).setResultsName("between")
    is_in = (var + Suppress(upkey("in")) + set_).setResultsName("in")
    fxn = (
        function("attribute_exists", var)
        | function("attribute_not_exists", var)
        | function("attribute_type", var, types)
        | function("begins_with", var, Group(string))
        | function("contains", var, value)
        | (function("size", var) + op + value)
    ).setResultsName("function")
    all_constraints = between | basic_constraint | is_in | fxn
    return Group(all_constraints).setName("constraint")
907299
@Override
    public VoltXMLElement voltGetIndexXML(Session session, String tableName,
            Map<String, VoltXMLElement> indexConstraintMapping)
                    throws org.hsqldb_voltpatches.HSQLInterface.HSQLParseException {
        org.hsqldb_voltpatches.VoltXMLElement index = new org.hsqldb_voltpatches.VoltXMLElement("index");

        // Add any expressions to the XML representation of the index,
        // and compute a hash that will help uniquify the generated name,
        // if a name was not provided.
        int exprHash = 0;
        if (exprs != null) {
            org.hsqldb_voltpatches.VoltXMLElement indexedExprs = new org.hsqldb_voltpatches.VoltXMLElement("exprs");
            index.children.add(indexedExprs);
            String hashExprString = new String();
            String sep = "";
            for (org.hsqldb_voltpatches.Expression expression : exprs) {
                org.hsqldb_voltpatches.VoltXMLElement xml = expression.voltGetExpressionXML(session, (Table) table);
                indexedExprs.children.add(xml);
                hashExprString += sep + expression.getSQL();
                sep = ",";
            }

            byte[] bytes = hashExprString.getBytes();
            for (int ii = 0; ii < bytes.length; ii++) {
                exprHash = 31 * exprHash + bytes[ii];
            }
        }

        String hsqlIndexName = getName().name;
        String voltdbIndexName = null;
        boolean isHashIndex = false;

        if (indexConstraintMapping.containsKey(hsqlIndexName)) {
            // This is an index backing a constraint.
            VoltXMLElement constraintXml = indexConstraintMapping.get(hsqlIndexName);
            indexConstraintMapping.remove(hsqlIndexName);

            boolean isAutoName = constraintXml.attributes.get("nameisauto").equals("true");

            // This is either a [ASSUME]UNIQUE constraint or a PK.
            String constraintType = constraintXml.attributes.get("constrainttype");
            String hsqlConstraintName = constraintXml.attributes.get("name");

            if (!isAutoName) {
                isHashIndex = isNameRequestingHashIndex(hsqlConstraintName);
                voltdbIndexName = HSQLInterface.AUTO_GEN_NAMED_CONSTRAINT_IDX + hsqlConstraintName;
            }
            else {
                String prefix = null;
                boolean isPrimaryKey = constraintType.equals("PRIMARY_KEY");
                if (isPrimaryKey) {
                    prefix = HSQLInterface.AUTO_GEN_PRIMARY_KEY_PREFIX;
                }
                else {
                    prefix = HSQLInterface.AUTO_GEN_UNIQUE_IDX_PREFIX;
                }

                String namePart = tableName + "_" + StringUtils.join(getColumnNameList().toArray(), "_");
                if (exprs != null) {
                    namePart += "_" + java.lang.Math.abs(exprHash % 100000);
                }

                voltdbIndexName = prefix + namePart;

                // Also name the constraint here based on our naming scheme.
                String voltdbConstraintName = null;
                if (isPrimaryKey) {
                    voltdbConstraintName = HSQLInterface.AUTO_GEN_CONSTRAINT_PREFIX + "_PK_" + namePart;
                }
                else {
                    voltdbConstraintName = HSQLInterface.AUTO_GEN_CONSTRAINT_PREFIX + "_CT_" + namePart;

                }

                constraintXml.attributes.put("name", voltdbConstraintName);
            }

            // Update the index name in the constraint.
            constraintXml.attributes.put("index", voltdbIndexName);
        }
        else {
            // This is an index created via CREATE INDEX
            isHashIndex = isNameRequestingHashIndex(hsqlIndexName);
            voltdbIndexName = hsqlIndexName;
        }

        index.attributes.put("name", voltdbIndexName);
        index.attributes.put("ishashindex", isHashIndex ? "true" : "false");

        index.attributes.put("assumeunique", isAssumeUnique() ? "true" : "false");
        index.attributes.put("unique", isUnique() ? "true" : "false");
        index.attributes.put("migrating", isMigrating() ? "true" : "false");
        assert ! (isMigrating() && (isUnique() || isAssumeUnique())) :
                "Cannot create a MIGRATING index that is also UNIQUE or ASSUMEUNIQUE";

        Object[] columnList = getColumnNameList().toArray();
        index.attributes.put("columns", StringUtils.join(columnList, ","));

        if (predicate != null) {
            org.hsqldb_voltpatches.VoltXMLElement partialExpr = new org.hsqldb_voltpatches.VoltXMLElement("predicate");
            index.children.add(partialExpr);
            org.hsqldb_voltpatches.VoltXMLElement xml = predicate.voltGetExpressionXML(session, (Table) table);
            partialExpr.children.add(xml);
        }

        return index;
    }
1275437
private void createUUIDConstraint() {

		// add UUID uniqueness constraint
		try (final Session session = driver.session()) {

			// this call may fail silently (e.g. if the index does not exist yet)
			try (final org.neo4j.driver.v1.Transaction tx = session.beginTransaction()) {

				tx.run("DROP INDEX ON :NodeInterface(id)");
				tx.success();

			} catch (Throwable t) { }

			// this call may NOT fail silently, hence we don't catch any exceptions
			try (final org.neo4j.driver.v1.Transaction tx = session.beginTransaction()) {

				tx.run("CREATE CONSTRAINT ON (node:NodeInterface) ASSERT node.id IS UNIQUE");
				tx.success();
			}
		}
	}
61466
Constraint getUniqueConstraintForColumns(int[] cols) {

        for (int i = 0, size = constraintList.length; i < size; i++) {
            Constraint c = constraintList[i];

            if (c.isUniqueWithColumns(cols)) {
                return c;
            }
        }

        return null;
    }
1062910
private void addUniqueConstraintForTableBasedSequence(Statements statements, IdSourceKeyMetadata generatorKeyMetadata) {
		Statement statement = createUniqueConstraintStatement( generatorKeyMetadata.getKeyColumnName(), generatorKeyMetadata.getName() );
		statements.addStatement( statement );
	}
399626
public static Constraint modificationConstraint(String modifTerm)
	{
		return new FieldOfMultiple(new MappedConst(new LinkedPE(LinkedPE.Type.TO_SPECIFIC), 0),
			"PhysicalEntity/feature:ModificationFeature/modificationType/term",
			Field.Operation.INTERSECT, modifTerm);
	}
1056357
function UniqueConstraintError(message, innerMessage, model) {
    UniqueConstraintError.super_.bind(this)('EUNQ', message || 'A unique constraint violated', innerMessage, model);
}
478347
public <T> JDOQuery<T> selectDistinct(Expression<T> expr) {
        return query().select(expr).distinct();
    }
700875
def xorc_constraint(v=0, sense="maximize"):
    
    assert v in [0,1], "v must be 0 or 1 instead of %s" % v.__repr__()
    model, x, y, z = _init()
    r = model.addVar("r", "B")
    n = model.addVar("n", "I") # auxiliary
    model.addCons(r+quicksum([x,y,z]) == 2*n)
    model.addCons(x==v)
    model.setObjective(r, sense=sense)
    _optimize("Custom XOR (as variable)", model)
590396
public DruidQuerySignature asAggregateSignature(RowSignature sourceSignature)
  {
    return new DruidQuerySignature(
        sourceSignature,
        virtualColumnPrefix,
        virtualColumnsByExpression,
        virtualColumnsByName,
        true
    );
  }
677637
private static String getSqlColumnConstraints(
      EntityType entityType, Attribute attr, ColumnMode columnConstraintsMode) {
    StringBuilder sqlBuilder = new StringBuilder();
    if (!attr.getName().equals(entityType.getIdAttribute().getName()) && !attr.isNillable()) {
      sqlBuilder.append("NOT NULL");
    }
    if (columnConstraintsMode == INCLUDE_DEFAULT_CONSTRAINT
        && generateSqlColumnDefaultConstraint(attr)) {
      if (sqlBuilder.length() > 0) {
        sqlBuilder.append(' ');
      }
      sqlBuilder.append("DEFAULT ").append(getSqlDefaulValue(attr));
    }
    return sqlBuilder.toString();
  }
884425
public boolean isUniqueWithExprs(Expression[] indexExprs2) {
        if (constType != UNIQUE || (indexExprs == null) || ! indexExprs.equals(indexExprs2)) {
            return false;
        }
        return true;
    }
392678
private static Constraint loadConstraint(Annotation context) {
        Constraint constraint = null;
        final ServiceLoader<Constraint> constraints = ServiceLoader.load(Constraint.class);

        for (Constraint aConstraint : constraints) {
            try {
                aConstraint.getClass().getDeclaredMethod("check", context.annotationType());
                constraint = aConstraint;
                break;
            } catch (NoSuchMethodException e) {
                // Look for next implementation if method not found with required signature.
            }
        }

        if (constraint == null) {
            throw new IllegalStateException("Couldn't found any implementation of " + Constraint.class.getName());
        }
        return constraint;
    }