// Here's the non-boilerplate part of the ValueComparison iterator. Given a value
// and our operator, determine whether or not we meet the requirement.
971303
func (it *Comparison) doComparison(val graph.Value) bool {
	qval := it.qs.NameOf(val)
	switch cVal := it.val.(type) {
	case quad.Int:
		if cVal2, ok := qval.(quad.Int); ok {
			return RunIntOp(cVal2, it.op, cVal)
		}
		return false
	case quad.Float:
		if cVal2, ok := qval.(quad.Float); ok {
			return RunFloatOp(cVal2, it.op, cVal)
		}
		return false
	case quad.String:
		if cVal2, ok := qval.(quad.String); ok {
			return RunStrOp(string(cVal2), it.op, string(cVal))
		}
		return false
	case quad.BNode:
		if cVal2, ok := qval.(quad.BNode); ok {
			return RunStrOp(string(cVal2), it.op, string(cVal))
		}
		return false
	case quad.IRI:
		if cVal2, ok := qval.(quad.IRI); ok {
			return RunStrOp(string(cVal2), it.op, string(cVal))
		}
		return false
	case quad.Time:
		if cVal2, ok := qval.(quad.Time); ok {
			return RunTimeOp(time.Time(cVal2), it.op, time.Time(cVal))
		}
		return false
	default:
		return RunStrOp(quad.StringOf(qval), it.op, quad.StringOf(it.val))
	}
}
1318671
func (it *RangeIter) Value() Range {
	if it.cur == nil {
		return Range{}
	}
	return it.cur.Value.(Range)
}
872572
func (sv *StringVisitor) AcceptComparison(v Comparison) {
	sv.result = fmt.Sprintf("%s(%s ", sv.result, ComparisonSymbols[v.Op])
	v.Left.Accept(sv)
	sv.result += " "
	v.Right.Accept(sv)
	sv.result += ")"
}
1170225
func (node *ComparisonExpr) IsImpossible() bool {
	var left, right *SQLVal
	var ok bool
	if left, ok = node.Left.(*SQLVal); !ok {
		return false
	}
	if right, ok = node.Right.(*SQLVal); !ok {
		return false
	}
	if node.Operator == NotEqualStr && left.Type == right.Type {
		if len(left.Val) != len(right.Val) {
			return false
		}

		for i := range left.Val {
			if left.Val[i] != right.Val[i] {
				return false
			}
		}
		return true
	}
	return false
}
318420
func (iter *bitArrayIterator) Value() (uint64, block) {
	return uint64(iter.index), iter.ba.blocks[iter.index]
}
286595
func Eq(expectedValue interface{}) *eqMatcher {
	matcher := new(eqMatcher)
	matcher.expectedValue = expectedValue
	return matcher
}
458343
func isByteComparable(v Value) bool {
	if v.IsBinary() {
		return true
	}
	switch v.Type() {
	case Timestamp, Date, Time, Datetime:
		return true
	}
	return false
}
357643
func (s *MetricAlarm) SetComparisonOperator(v string) *MetricAlarm {
	s.ComparisonOperator = &v
	return s
}
559675
func (it *EntryInfoIterator) Value() (EntryInfo, error) {
	it.mutex.Lock()

	if !it.valid {
		it.mutex.Unlock()
		return emptyEntryInfo, ErrInvalidIteratorState
	}

	entry, err := it.cache.shards[it.currentShard].getEntry(int(it.elements[it.currentIndex]))

	if err != nil {
		it.mutex.Unlock()
		return emptyEntryInfo, ErrCannotRetrieveEntry
	}
	it.mutex.Unlock()

	return EntryInfo{
		timestamp: readTimestampFromEntry(entry),
		hash:      readHashFromEntry(entry),
		key:       readKeyFromEntry(entry),
		value:     readEntry(entry),
	}, nil
}
977881
func IsValue(v interface{}) bool {
	if IsScanValue(v) {
		return true
	}
	if _, ok := v.(string); ok {
		return true
	}
	return false
}
341403
func (s *Notification) SetComparisonOperator(v string) *Notification {
	s.ComparisonOperator = &v
	return s
}
419897
func Is(s SkipT, requirements ...Test) {
	for _, r := range requirements {
		isValid := r()
		if !isValid {
			requirementFunc := runtime.FuncForPC(reflect.ValueOf(r).Pointer()).Name()
			s.Skip(fmt.Sprintf("unmatched requirement %s", extractRequirement(requirementFunc)))
		}
	}
}
1260175
func (e *Engine) IteratorCost(measurement string, opt query.IteratorOptions) (query.IteratorCost, error) {
	// Determine if this measurement exists. If it does not, then no shards are
	// accessed to begin with.
	if exists, err := e.index.MeasurementExists([]byte(measurement)); err != nil {
		return query.IteratorCost{}, err
	} else if !exists {
		return query.IteratorCost{}, nil
	}

	tagSets, err := e.index.TagSets([]byte(measurement), opt)
	if err != nil {
		return query.IteratorCost{}, err
	}

	// Attempt to retrieve the ref from the main expression (if it exists).
	var ref *influxql.VarRef
	if opt.Expr != nil {
		if v, ok := opt.Expr.(*influxql.VarRef); ok {
			ref = v
		} else if call, ok := opt.Expr.(*influxql.Call); ok {
			if len(call.Args) > 0 {
				ref, _ = call.Args[0].(*influxql.VarRef)
			}
		}
	}

	// Count the number of series concatenated from the tag set.
	cost := query.IteratorCost{NumShards: 1}
	for _, t := range tagSets {
		cost.NumSeries += int64(len(t.SeriesKeys))
		for i, key := range t.SeriesKeys {
			// Retrieve the cost for the main expression (if it exists).
			if ref != nil {
				c := e.seriesCost(key, ref.Val, opt.StartTime, opt.EndTime)
				cost = cost.Combine(c)
			}

			// Retrieve the cost for every auxiliary field since these are also
			// iterators that we may have to look through.
			// We may want to separate these though as we are unlikely to incur
			// anywhere close to the full costs of the auxiliary iterators because
			// many of the selected values are usually skipped.
			for _, ref := range opt.Aux {
				c := e.seriesCost(key, ref.Val, opt.StartTime, opt.EndTime)
				cost = cost.Combine(c)
			}

			// Retrieve the expression names in the condition (if there is a condition).
			// We will also create cursors for these too.
			if t.Filters[i] != nil {
				refs := influxql.ExprNames(t.Filters[i])
				for _, ref := range refs {
					c := e.seriesCost(key, ref.Val, opt.StartTime, opt.EndTime)
					cost = cost.Combine(c)
				}
			}
		}
	}
	return cost, nil
}
1026313
func (sv *EvaluatorVisitor) AcceptComparison(v Comparison) {
	v.Left.Accept(sv)
	v.Right.Accept(sv)

	right := sv.popNumeric()
	left := sv.popNumeric()

	switch v.Op {
	case EQL:
		sv.pushBoolean(left == right)
	case NEQL:
		sv.pushBoolean(left != right)
	case GT:
		sv.pushBoolean(left > right)
	case GTE:
		sv.pushBoolean(left >= right)
	case LT:
		sv.pushBoolean(left < right)
	case LTE:
		sv.pushBoolean(left <= right)
	}
}
470034
func (iter *Iterator) Value() []byte {
	if iter.node == nil {
		return nil
	}
	return iter.node.value
}
433131
func valuesSDKEquivalentMappings(a, b cty.Value) bool {
	as := a.AsValueMap()
	bs := b.AsValueMap()
	if len(as) != len(bs) {
		return false
	}

	for k, av := range as {
		bv, ok := bs[k]
		if !ok {
			return false
		}
		if !ValuesSDKEquivalent(av, bv) {
			return false
		}
	}
	return true
}
426772
func (s *comparisonSimplifier) AcceptComparison(a tree.Comparison) {
	l := s.Transform(a.Left)
	r := s.Transform(a.Right)

	pl, ok1 := potentialExtractValue(l)
	pr, ok2 := potentialExtractValue(r)

	if ok1 && ok2 {
		switch a.Op {
		case tree.EQL:
			s.Result = tree.BooleanLiteral{pl == pr}
			return
		case tree.NEQL:
			s.Result = tree.BooleanLiteral{pl != pr}
			return
		case tree.GT:
			s.Result = tree.BooleanLiteral{pl > pr}
			return
		case tree.GTE:
			s.Result = tree.BooleanLiteral{pl >= pr}
			return
		case tree.LT:
			s.Result = tree.BooleanLiteral{pl < pr}
			return
		case tree.LTE:
			s.Result = tree.BooleanLiteral{pl <= pr}
			return
		case tree.BITSET:
			s.Result = tree.BooleanLiteral{pl&pr != 0}
			return
		}
	}
	s.Result = tree.Comparison{Op: a.Op, Left: l, Right: r}
}