// Or returns result of binary OR of two UUIDs.
965995
func Or(u1 UUID, u2 UUID) UUID {
	u := UUID{}
	for i := 0; i < 16; i++ {
		u[i] = u1[i] | u2[i]
	}
	return u
}
666506
func (l *LookupOptions) UUID() uuid.UUID {
	var buffer bytes.Buffer
	buffer.WriteString(l.String())
	return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
}
470460
func IsUUID(str string) bool {
	const uuidLen = 36
	if len(str) != uuidLen {
		return false
	}

	return validUUID.MatchString(str)
}
886128
func (like Like) Or(conds ...Cond) Cond {
	return Or(like, Or(conds...))
}
1005061
func (l *Literal) UUID() uuid.UUID {
	var buffer bytes.Buffer

	switch v := l.v.(type) {
	case bool:
		if v {
			buffer.WriteString("true")
		} else {
			buffer.WriteString("false")
		}
	case int64:
		b := make([]byte, 8)
		binary.PutVarint(b, v)
		buffer.Write(b)
	case float64:
		bs := math.Float64bits(v)
		b := make([]byte, 8)
		binary.LittleEndian.PutUint64(b, bs)
		buffer.Write(b)
	case string:
		buffer.Write([]byte(v))
	case []byte:
		buffer.Write(v)
	}

	return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
}
654389
func (q *Query) Or(query *Query) *Query {
	if query.skip != 0 || query.limit != 0 {
		panic("Or'd queries cannot contain skip or limit values")
	}
	q.ors = append(q.ors, query)
	return q
}
783544
func (sba *sparseBitArray) Or(other BitArray) BitArray {
	if ba, ok := other.(*sparseBitArray); ok {
		return orSparseWithSparseBitArray(sba, ba)
	}

	return orSparseWithDenseBitArray(sba, other.(*bitArray))
}
287142
func (u Uint32) If(fn func(uint32)) {
	if u.Present() {
		fn(*u.value)
	}
}
855921
func Or(inner ...Condition) Condition {
	if len(inner) == 1 {
		return inner[0]
	}

	return Condition{
		Type:  ConditionOr,
		Inner: inner,
	}
}
119005
func If(muxes ...*Mux) *Mux {
	mx := New()
	for _, mm := range muxes {
		mx.AddMatcher(mm.Matchers...)
	}
	return mx
}
918951
func IsBinaryLiteral(expr Expression) bool {
	con, ok := expr.(*Constant)
	return ok && con.Value.Kind() == types.KindBinaryLiteral
}
237054
func compare(t Type, a, b interface{}) int {
	switch t {
	case TUUID:
		// TODO: make sure if comparison for UUID like below makes sense.
		return strings.Compare(string(a.(UUID)), string(b.(UUID)))
	case Int64:
		return int(a.(int64) - b.(int64))
	case Int32:
		return int(a.(int32) - b.(int32))
	case String:
		return strings.Compare(a.(string), b.(string))
	case Blob:
		return bytes.Compare(a.([]byte), b.([]byte))
	case Bool:
		// TODO: we don't need to order bools for range query and should report error if people do dumb things
		var ia, ib int
		if a.(bool) {
			ia = 1
		}
		if b.(bool) {
			ib = 1
		}
		return ia - ib
	case Double:
		fa := a.(float64)
		fb := b.(float64)
		if fa < fb {
			return -1
		}
		if fa > fb {
			return 1
		}
		return 0
	case Timestamp:
		ta := a.(time.Time)
		tb := b.(time.Time)
		if ta.Before(tb) {
			return -1
		}
		if ta.After(tb) {
			return 1
		}
		return 0
	}
	panic("invalid type") // shouldn't reach here
}
378652
func Boolean(operator string, left Expr, right Expr) (Expr, error) {
	var bfn boolFN
	switch operator {
	case "AND":
		bfn = and
	case "OR":
		bfn = or
	default:
		return nil, fmt.Errorf("Unknown boolean operator %v", operator)
	}
	return &booleanExpr{operator, bfn, left, right}, nil
}
1119001
func IsUUID(input string) error {
	matched, err := regexp.MatchString("^"+UUIDRegex+"$", input)
	if err != nil {
		return err
	}
	if !matched {
		return fmt.Errorf("String '%s' is not a valid UUID", input)
	}
	return nil
}
478987
func And(u1 UUID, u2 UUID) UUID {
	u := UUID{}
	for i := 0; i < 16; i++ {
		u[i] = u1[i] & u2[i]
	}
	return u
}
898647
func (b *Bool) BoolOr(or bool) bool {
	if b == nil {
		return or
	}
	if !b.Valid {
		return or
	}

	return b.Bool
}
327247
func (o Immutable) UUID() UUID {
	id := UUID{}
	id.unmarshal(o.Bytes())
	return id
}