本文整理汇总了Golang中github.com/couchbase/query/expression/parser.Parse函数的典型用法代码示例。如果您正苦于以下问题:Golang Parse函数的具体用法?Golang Parse怎么用?Golang Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UnmarshalJSON
func (this *InitialGroup) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string "#operator"
Keys []string "group_keys"
Aggs []string "aggregates"
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
this.keys = make(expression.Expressions, len(_unmarshalled.Keys))
for i, key := range _unmarshalled.Keys {
key_expr, err := parser.Parse(key)
if err != nil {
return err
}
this.keys[i] = key_expr
}
this.aggregates = make(algebra.Aggregates, len(_unmarshalled.Aggs))
for i, agg := range _unmarshalled.Aggs {
agg_expr, err := parser.Parse(agg)
if err != nil {
return err
}
this.aggregates[i], _ = agg_expr.(algebra.Aggregate)
}
return nil
}
示例2: init
func init() {
qpServer = startQueryport("localhost:9998", serverCallb)
ns := &namespace{
name: "default",
keyspaceCache: make(map[string]datastore.Keyspace),
}
ks := &keyspace{
namespace: ns,
name: "default",
indexes: make(map[string]datastore.Index),
}
expr, err := parser.Parse(`gender`)
if err != nil {
log.Fatal(err)
}
equalKey := expression.Expressions{expr}
expr, err = parser.Parse(`name`)
if err != nil {
log.Fatal(err)
}
rangeKey := expression.Expressions{expr}
whereKey, err := parser.Parse("(30 < `age`)")
if err != nil {
log.Fatal(err)
}
index, _ = new2iIndex(
"testindex", equalKey, rangeKey, whereKey, "gsi", ks)
index.setHost([]string{"localhost:9998"})
}
示例3: UnmarshalJSON
func (this *SendUpsert) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
KeyExpr string `json:"key"`
ValueExpr string `json:"value"`
Keys string `json:"keyspace"`
Names string `json:"namespace"`
Alias string `json:"alias"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
if _unmarshalled.KeyExpr != "" {
this.key, err = parser.Parse(_unmarshalled.KeyExpr)
if err != nil {
return err
}
}
if _unmarshalled.ValueExpr != "" {
this.value, err = parser.Parse(_unmarshalled.ValueExpr)
if err != nil {
return err
}
}
this.alias = _unmarshalled.Alias
this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
return nil
}
示例4: UnmarshalJSON
func (this *Range) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
Low []string
High []string
Inclusion datastore.Inclusion
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
if _unmarshalled.Low != nil {
this.Low = make(expression.Expressions, len(_unmarshalled.Low))
for l, lowExpr := range _unmarshalled.Low {
this.Low[l], err = parser.Parse(lowExpr)
if err != nil {
return err
}
}
}
if _unmarshalled.High != nil {
this.High = make(expression.Expressions, len(_unmarshalled.High))
for h, hiExpr := range _unmarshalled.High {
this.High[h], err = parser.Parse(hiExpr)
if err != nil {
return err
}
}
}
this.Inclusion = _unmarshalled.Inclusion
return nil
}
示例5: UnmarshalJSON
func (this *IndexScan) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
Index string `json:"index"`
Namespace string `json:"namespace"`
Keyspace string `json:"keyspace"`
Using datastore.IndexType `json:"using"`
Spans Spans `json:"spans"`
Distinct bool `json:"distinct"`
Limit string `json:"limit"`
Covers []string `json:"covers"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
k, err := datastore.GetKeyspace(_unmarshalled.Namespace, _unmarshalled.Keyspace)
if err != nil {
return err
}
this.term = algebra.NewKeyspaceTerm(
_unmarshalled.Namespace, _unmarshalled.Keyspace,
nil, "", nil, nil)
this.spans = _unmarshalled.Spans
this.distinct = _unmarshalled.Distinct
if _unmarshalled.Limit != "" {
this.limit, err = parser.Parse(_unmarshalled.Limit)
if err != nil {
return err
}
}
if _unmarshalled.Covers != nil {
this.covers = make(expression.Covers, len(_unmarshalled.Covers))
for i, c := range _unmarshalled.Covers {
expr, err := parser.Parse(c)
if err != nil {
return err
}
this.covers[i] = expression.NewCover(expr)
}
}
indexer, err := k.Indexer(_unmarshalled.Using)
if err != nil {
return err
}
this.index, err = indexer.IndexByName(_unmarshalled.Index)
return err
}
示例6: Condition
// Condition implement Index{} interface.
func (si *secondaryIndex) Condition() expression.Expression {
if si != nil && si.whereExpr != "" {
expr, _ := parser.Parse(si.whereExpr)
return expr
}
return nil
}
示例7: UnmarshalJSON
func (this *SendUpdate) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
Keys string `json:"keyspace"`
Names string `json:"namespace"`
Alias string `json:"alias"`
Limit string `json:"limit"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
this.alias = _unmarshalled.Alias
if _unmarshalled.Limit != "" {
this.limit, err = parser.Parse(_unmarshalled.Limit)
if err != nil {
return err
}
}
this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
return err
}
示例8: UnmarshalJSON
func (this *Let) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
Bindings []struct {
_ string `json:"type"`
Var string `json:"variable"`
Expr string `json:"variable"`
Desc bool `json:"descend"`
} `json:"bindings"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
this.bindings = make(expression.Bindings, len(_unmarshalled.Bindings))
for i, binding := range _unmarshalled.Bindings {
expr, err := parser.Parse(binding.Expr)
if err != nil {
return err
}
if binding.Desc {
this.bindings[i] = expression.NewDescendantBinding(binding.Var, expr)
} else {
this.bindings[i] = expression.NewBinding(binding.Var, expr)
}
}
return nil
}
示例9: UnmarshalUpdateFor
/*
Unmarshals byte array.
*/
func UnmarshalUpdateFor(body []byte) (*algebra.UpdateFor, error) {
var _unmarshalled struct {
Bindings json.RawMessage `json:"bindings"`
When string `json:"when"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return nil, err
}
bindings, err := unmarshal.UnmarshalBindings(_unmarshalled.Bindings)
if err != nil {
return nil, err
}
var when expression.Expression
if _unmarshalled.When != "" {
when, err = parser.Parse(_unmarshalled.When)
if err != nil {
return nil, err
}
}
return algebra.NewUpdateFor(bindings, when), nil
}
示例10: UnmarshalJSON
func (this *Unnest) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
Outer bool `json:"outer"`
Expr string `json:"expr"`
As string `json:"as"`
}
var expr expression.Expression
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
if _unmarshalled.Expr != "" {
expr, err = parser.Parse(_unmarshalled.Expr)
if err != nil {
return err
}
}
this.term = algebra.NewUnnest(nil, _unmarshalled.Outer, expr, _unmarshalled.As)
this.alias = _unmarshalled.As
return err
}
示例11: UnmarshalJSON
func (this *ValueScan) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
Values string `json:"values"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
if _unmarshalled.Values == "" {
return nil
}
expr, err := parser.Parse(_unmarshalled.Values)
if err != nil {
return err
}
array, ok := expr.(*expression.ArrayConstruct)
if !ok {
return fmt.Errorf("Invalid VALUES expression %s", _unmarshalled.Values)
}
this.values, err = algebra.NewPairs(array)
return err
}
示例12: UnmarshalBindings
func UnmarshalBindings(body []byte) (expression.Bindings, error) {
var _unmarshalled []struct {
Var string `json:"variable"`
Expr string `json:"expr"`
Desc bool `json:"descend"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return nil, err
}
bindings := make(expression.Bindings, len(_unmarshalled))
for i, binding := range _unmarshalled {
expr, err := parser.Parse(binding.Expr)
if err != nil {
return nil, err
}
if binding.Desc {
bindings[i] = expression.NewDescendantBinding(binding.Var, expr)
} else {
bindings[i] = expression.NewBinding(binding.Var, expr)
}
}
return bindings, nil
}
示例13: UnmarshalJSON
func (this *Fetch) UnmarshalJSON(body []byte) error {
var _unmarshalled struct {
_ string `json:"#operator"`
Proj string `json:"projection"`
Names string `json:"namespace"`
Keys string `json:"keyspace"`
As string `json:"as"`
}
var proj_expr expression.Path
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return err
}
if _unmarshalled.Proj != "" {
expr, err := parser.Parse(_unmarshalled.Proj)
if err != nil {
return err
}
_proj_expr, is_path := expr.(expression.Path)
if !is_path {
return fmt.Errorf("Fetch.UnmarshalJSON: cannot resolve path expression from %s", _unmarshalled.Proj)
}
proj_expr = _proj_expr
}
this.term = algebra.NewKeyspaceTerm(_unmarshalled.Names, _unmarshalled.Keys,
proj_expr, _unmarshalled.As, nil, nil)
this.keyspace, err = datastore.GetKeyspace(_unmarshalled.Names, _unmarshalled.Keys)
return err
}
示例14: SeekKey
// SeekKey implement Index{} interface.
func (si *secondaryIndex) SeekKey() expression.Expressions {
if si != nil && si.partnExpr != "" {
expr, _ := parser.Parse(si.partnExpr)
return expression.Expressions{expr}
}
return nil
}
示例15: UnmarshalUnsetTerm
/*
Unmarshals byte array.
*/
func UnmarshalUnsetTerm(body []byte) (*algebra.UnsetTerm, error) {
var _unmarshalled struct {
Path string `json:"path"`
For json.RawMessage `json:"path_for"`
}
err := json.Unmarshal(body, &_unmarshalled)
if err != nil {
return nil, err
}
path_expr, err := parser.Parse(_unmarshalled.Path)
if err != nil {
return nil, err
}
path, is_path := path_expr.(expression.Path)
if !is_path {
return nil, fmt.Errorf("UnmarshalUnsetTerm: cannot resolve path expression from %s",
_unmarshalled.Path)
}
var updateFor *algebra.UpdateFor
if len(_unmarshalled.For) > 0 {
updateFor, err = UnmarshalUpdateFor(_unmarshalled.For)
if err != nil {
return nil, err
}
}
return algebra.NewUnsetTerm(path, updateFor), nil
}