当前位置: 首页>>代码示例>>Golang>>正文


Golang Value.Collate方法代码示例

本文整理汇总了Golang中github.com/couchbaselabs/query/value.Value.Collate方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.Collate方法的具体用法?Golang Value.Collate怎么用?Golang Value.Collate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/couchbaselabs/query/value.Value的用法示例。


在下文中一共展示了Value.Collate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Apply

/*
This method evaluates the less than equal to condition and
returns a value representing if the two operands satisfy the
condition or not. If either of the input operands are
missing, return missing value, and if they are null, then
return null value. For all other types call the Collate
method and check if it is less than equal to 0 for the
two values. If it is, then return true.
*/
func (this *LE) Apply(context Context, first, second value.Value) (value.Value, error) {
	if first.Type() == value.MISSING || second.Type() == value.MISSING {
		return value.MISSING_VALUE, nil
	} else if first.Type() == value.NULL || second.Type() == value.NULL {
		return value.NULL_VALUE, nil
	}

	return value.NewValue(first.Collate(second) <= 0), nil
}
开发者ID:amarantha-k,项目名称:query,代码行数:18,代码来源:comp_le.go

示例2: Apply

/*
This method evaluates the between comparison operation and returns a
value representing if item value is in between low and high. If any of
the input operands are missing, return missing, and if null return null.
For all other types, check if the item is greater in terms of the N1QL
collation order, than the low value and smaller than high value, and return
true. If not return false.
*/
func (this *Between) Apply(context Context, item, low, high value.Value) (value.Value, error) {
	if item.Type() == value.MISSING || low.Type() == value.MISSING || high.Type() == value.MISSING {
		return value.MISSING_VALUE, nil
	} else if item.Type() == value.NULL || low.Type() == value.NULL || high.Type() == value.NULL {
		return value.NULL_VALUE, nil
	}

	return value.NewValue(item.Collate(low) >= 0 && item.Collate(high) <= 0), nil
}
开发者ID:amarantha-k,项目名称:query,代码行数:17,代码来源:comp_between.go

示例3: cumulatePart

/*
Aggregate input partial values into cumulative result value.
If partial result is null return the current cumulative value,
and if the cumulative result is null, return the partial value.
For non null partial and cumulative values, call Collate and
return the smaller value depending on the N1QL collation order.
*/
func (this *Min) cumulatePart(part, cumulative value.Value, context Context) (value.Value, error) {
	if part == value.NULL_VALUE {
		return cumulative, nil
	} else if cumulative == value.NULL_VALUE {
		return part, nil
	} else if part.Collate(cumulative) < 0 {
		return part, nil
	} else {
		return cumulative, nil
	}
}
开发者ID:amarantha-k,项目名称:query,代码行数:18,代码来源:agg_min.go

示例4: Less

func (this *Order) Less(i, j int) bool {
	v1 := this.values[i]
	v2 := this.values[j]

	var ev1, ev2 value.Value
	var c int
	var e error

	for i, term := range this.plan.Terms() {
		s := strconv.Itoa(i)

		sv1 := v1.GetAttachment(s)
		switch sv1 := sv1.(type) {
		case value.Value:
			ev1 = sv1
		default:
			ev1, e = term.Expression().Evaluate(v1, this.context)
			if e != nil {
				this.context.Error(errors.NewError(e, "Error evaluating ORDER BY."))
				return false
			}

			v1.SetAttachment(s, ev1)
		}

		sv2 := v2.GetAttachment(s)
		switch sv2 := sv2.(type) {
		case value.Value:
			ev2 = sv2
		default:
			ev2, e = term.Expression().Evaluate(v2, this.context)
			if e != nil {
				this.context.Error(errors.NewError(e, "Error evaluating ORDER BY."))
				return false
			}

			v2.SetAttachment(s, ev2)
		}

		c = ev1.Collate(ev2)

		if c == 0 {
			continue
		} else if term.Descending() {
			return c > 0
		} else {
			return c < 0
		}
	}

	return false
}
开发者ID:amarantha-k,项目名称:query,代码行数:52,代码来源:order.go


注:本文中的github.com/couchbaselabs/query/value.Value.Collate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。