• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang query.NewError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/couchbaselabs/tuqtng/query.NewError函数的典型用法代码示例。如果您正苦于以下问题:Golang NewError函数的具体用法?Golang NewError怎么用?Golang NewError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Compile

func (this *StandardCompiler) Compile(queryString string) (*plan.Plan, query.Error) {

	ast, err := this.parser.Parse(queryString)
	if err != nil {
		return nil, query.NewParseError(err, "Parse Error")
	}

	// perform semantic verification
	err = ast.VerifySemantics()
	if err != nil {
		return nil, query.NewSemanticError(err, "Semantic Error")
	}

	// simplify the statement
	err = ast.Simplify()
	if err != nil {
		return nil, query.NewError(err, "Error Simplifying Expression")
	}

	planChannel, planErrChannel := this.planner.Plan(ast)

	optimalPlan, err := this.optimizer.Optimize(planChannel, planErrChannel)
	if err != nil {
		return nil, query.NewError(err, "Optimizer Error")
	}

	return optimalPlan, nil
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:28,代码来源:standard.go


示例2: loadPools

func (s *site) loadPools() (e query.Error) {
	dirEntries, err := ioutil.ReadDir(s.path)
	if err != nil {
		return query.NewError(err, "")
	}

	s.pools = make(map[string]*pool)
	s.poolNames = make([]string, 0)

	var p *pool
	for _, dirEntry := range dirEntries {
		if dirEntry.IsDir() {
			s.poolNames = append(s.poolNames, dirEntry.Name())
			diru := strings.ToUpper(dirEntry.Name())
			if _, ok := s.pools[diru]; ok {
				return query.NewError(nil, "Duplicate pool name "+dirEntry.Name())
			}

			p, e = newPool(s, dirEntry.Name())
			if e != nil {
				return
			}

			s.pools[diru] = p
		}
	}

	return
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:29,代码来源:file.go


示例3: Lookup

func (pi *bucketIndex) Lookup(value catalog.LookupValue, ch catalog.EntryChannel, warnch, errch query.ErrorChannel) {
	defer close(ch)
	defer close(warnch)
	defer close(errch)

	if value == nil || len(value) != 1 || value[0].Type() != dparval.STRING {
		errch <- query.NewError(nil, "Invalid lookup value: string required.")
		return
	}

	val, ok := value[0].Value().(string)
	if !ok {
		errch <- query.NewError(nil, "Invalid lookup value: string required.")
		return
	}

	ids := strings.SplitN(val, "/", 2)
	if len(ids) != 2 {
		return
	}

	pool, _ := pi.bucket.pool.site.actualSite.PoolById(ids[0])
	if pool == nil {
		return
	}

	bucket, _ := pool.BucketById(ids[1])
	if bucket != nil {
		entry := catalog.IndexEntry{PrimaryKey: fmt.Sprintf("%s/%s", pool.Id(), bucket.Id())}
		ch <- &entry
	}
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:32,代码来源:system_bucket_buckets.go


示例4: Count

func (b *indexbucket) Count() (int64, query.Error) {
	count := int64(0)
	poolIds, err := b.pool.site.actualSite.PoolIds()
	if err == nil {
		for _, poolId := range poolIds {
			pool, err := b.pool.site.actualSite.PoolById(poolId)
			if err == nil {
				bucketIds, err := pool.BucketIds()
				if err == nil {
					for _, bucketId := range bucketIds {
						bucket, err := pool.BucketById(bucketId)
						if err == nil {
							indexIds, err := bucket.IndexIds()
							if err == nil {
								count += int64(len(indexIds))
							} else {
								return 0, query.NewError(err, "")
							}
						} else {
							return 0, query.NewError(err, "")
						}
					}
				} else {
					return 0, query.NewError(err, "")
				}
			} else {
				return 0, query.NewError(err, "")
			}
		}
		return count, nil
	}
	return 0, query.NewError(err, "")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:33,代码来源:system_bucket_indexes.go


示例5: Lookup

func (pi *primaryIndex) Lookup(value catalog.LookupValue, ch catalog.EntryChannel, warnch, errch query.ErrorChannel) {
	defer close(ch)
	defer close(warnch)
	defer close(errch)

	if value == nil || len(value) != 1 || value[0].Type() != dparval.STRING {
		errch <- query.NewError(nil, "Invalid lookup value: string required.")
		return
	}

	val, ok := value[0].Value().(string)
	if !ok {
		errch <- query.NewError(nil, "Invalid lookup value: string required.")
		return
	}

	fi, err := os.Lstat(filepath.Join(pi.bucket.path(), val+".json"))
	if err != nil && !os.IsNotExist(err) {
		errch <- query.NewError(err, "IO error during lookup.")
		return
	}

	if fi != nil {
		entry := catalog.IndexEntry{EntryKey: value, PrimaryKey: val}
		ch <- &entry
	}
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:27,代码来源:file.go


示例6: loadBuckets

func (p *pool) loadBuckets() (e query.Error) {
	dirEntries, err := ioutil.ReadDir(p.path())
	if err != nil {
		return query.NewError(err, "")
	}

	p.buckets = make(map[string]*bucket)
	p.bucketNames = make([]string, 0)

	var b *bucket
	for _, dirEntry := range dirEntries {
		if dirEntry.IsDir() {
			diru := strings.ToUpper(dirEntry.Name())
			if _, ok := p.buckets[diru]; ok {
				return query.NewError(nil, "Duplicate bucket name "+dirEntry.Name())
			}

			b, e = newBucket(p, dirEntry.Name())
			if e != nil {
				return
			}

			p.buckets[diru] = b
			p.bucketNames = append(p.bucketNames, b.Name())
		}
	}

	return
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:29,代码来源:file.go


示例7: newPool

func newPool(s *site, name string) (*pool, query.Error) {
	clog.To(catalog.CHANNEL, "Created New Pool %s", name)
	cbpool, err := s.client.GetPool(name)
	if err != nil {
		if name == "default" {
			// if default pool is not available, try reconnecting to the server
			url := s.URL()
			client, err := cb.Connect(url)
			if err != nil {
				return nil, query.NewError(nil, fmt.Sprintf("Pool %v not found.", name))
			}
			// check if the default pool exists
			cbpool, err = client.GetPool(name)
			if err != nil {
				return nil, query.NewError(nil, fmt.Sprintf("Pool %v not found.", name))
			}
			s.client = client
		}
	}
	rv := pool{
		site:        s,
		name:        name,
		cbpool:      cbpool,
		bucketCache: make(map[string]catalog.Bucket),
	}
	go keepPoolFresh(&rv)
	return &rv, nil
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:28,代码来源:couchbase.go


示例8: WalkViewInBatches

func WalkViewInBatches(result chan cb.ViewRow, errs query.ErrorChannel, bucket *cb.Bucket,
	ddoc string, view string, options map[string]interface{}, batchSize int64, limit int64) {

	if limit != 0 && limit < batchSize {
		batchSize = limit
	}

	defer close(result)
	defer close(errs)

	defer func() {
		r := recover()
		if r != nil {
			clog.Error(fmt.Errorf("View Walking Panic: %v\n%s", r, debug.Stack()))
			errs <- query.NewError(nil, "Panic In View Walking")
		}
	}()

	options["limit"] = batchSize + 1

	numRead := int64(0)
	ok := true
	for ok {

		logURL, err := bucket.ViewURL(ddoc, view, options)
		if err == nil {
			clog.To(NETWORK_CHANNEL, "Request View: %v", logURL)
		}
		vres, err := bucket.View(ddoc, view, options)
		if err != nil {
			errs <- query.NewError(err, "Unable to access view")
			return
		}

		for i, row := range vres.Rows {
			if int64(i) < batchSize {
				// dont process the last row, its just used to see if we
				// need to continue processing
				result <- row
				numRead += 1
			}
		}

		if (int64(len(vres.Rows)) > batchSize) && (limit == 0 || (limit != 0 && numRead < limit)) {
			// prepare for next run
			skey := vres.Rows[batchSize].Key
			skeydocid := vres.Rows[batchSize].ID
			options["startkey"] = skey
			options["startkey_docid"] = cb.DocID(skeydocid)
		} else {
			// stop
			ok = false
		}
	}
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:55,代码来源:view_util.go


示例9: Drop

func (vi *viewIndex) Drop() query.Error {
	bucket := vi.bucket
	if vi.IsPrimary() {
		return query.NewError(nil, "Primary index cannot be dropped.")
	}
	err := vi.DropViewIndex()
	if err != nil {
		return query.NewError(err, fmt.Sprintf("Cannot drop index %s", vi.Name()))
	}
	delete(bucket.indexes, vi.name)
	return nil
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:12,代码来源:view_index.go


示例10: CreatePrimaryIndex

func (b *bucket) CreatePrimaryIndex() (catalog.PrimaryIndex, query.Error) {

	if _, exists := b.indexes[PRIMARY_INDEX]; exists {
		return nil, query.NewError(nil, "Primary index already exists")
	}
	idx, err := newPrimaryIndex(b)
	if err != nil {
		return nil, query.NewError(err, "Error creating primary index")
	}
	b.indexes[idx.Name()] = idx
	return idx, nil
}
开发者ID:phonkee,项目名称:tuqtng,代码行数:12,代码来源:couchbase.go


示例11: IndexByName

func (b *bucket) IndexByName(name string) (catalog.Index, query.Error) {
	index, ok := b.indexes[name]
	if !ok {
		return nil, query.NewError(nil, fmt.Sprintf("Index %v not found.", name))
	}
	return index, nil
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:7,代码来源:mock.go


示例12: joinItems

func (this *KeyJoin) joinItems(item *dparval.Value, keyItem *dparval.Value) bool {

	if keyItem == nil {
		if this.Type == "LEFT" {
			return this.Base.SendItem(item)
		}
		return true
	}

	newItem := item.Duplicate()
	/* join the item and ship it */
	if this.Projection != nil {
		keyProj, Error := this.Base.Evaluate(this.Projection, keyItem)
		if Error != nil {
			switch err := Error.(type) {
			case *dparval.Undefined:
				return true
			default:
				return this.Base.SendError(query.NewError(err, "Internal error in KeyJoin"))
			}

		}
		newItem.SetPath(this.As, keyProj)
	} else {
		newItem.SetPath(this.As, keyItem)
	}
	this.rowsFetched += 1
	this.Base.SendItem(newItem)
	return true
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:30,代码来源:key_join.go


示例13: Count

func (b *bucket) Count() (int64, query.Error) {
	dirEntries, err := ioutil.ReadDir(b.path())
	if err != nil {
		return 0, query.NewError(err, "")
	}
	return int64(len(dirEntries)), nil
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:7,代码来源:file.go


示例14: BulkFetch

func (b *bucket) BulkFetch(ids []string) (map[string]*dparval.Value, query.Error) {
	rv := make(map[string]*dparval.Value, 0)

	bulkResponse, err := b.cbbucket.GetBulk(ids)
	if err != nil {
		return nil, query.NewError(err, "Error doing bulk get")
	}
	for k, v := range bulkResponse {

		doc := dparval.NewValueFromBytes(v.Body)
		meta_flags := (v.Extras[0]&0xff)<<24 | (v.Extras[1]&0xff)<<16 | (v.Extras[2]&0xff)<<8 | (v.Extras[3] & 0xff)
		meta_type := "json"
		if doc.Type() == dparval.NOT_JSON {
			meta_type = "base64"
		}
		doc.SetAttachment("meta", map[string]interface{}{
			"id":    k,
			"cas":   float64(v.Cas),
			"type":  meta_type,
			"flags": float64(meta_flags),
		})

		rv[k] = doc
	}

	return rv, nil
}
开发者ID:phonkee,项目名称:tuqtng,代码行数:27,代码来源:couchbase.go


示例15: CreatePrimaryIndex

func (b *bucket) CreatePrimaryIndex() (catalog.PrimaryIndex, query.Error) {
	if b.primary != nil {
		return b.primary, nil
	}

	return nil, query.NewError(nil, "Not supported.")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:7,代码来源:mock.go


示例16: RecoverPanic

func (this *FastCount) RecoverPanic() {
	r := recover()
	if r != nil {
		clog.Error(fmt.Errorf("Query Execution Panic: %v\n%s", r, debug.Stack()))
		this.SendError(query.NewError(nil, "Panic In Exeuction Pipeline"))
	}
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:7,代码来源:fast_count.go


示例17: processItem

func (this *Grouper) processItem(item *dparval.Value) bool {
	groupkey := dparval.NewValue(make([]interface{}, len(this.GroupBy)))
	for i, groupElement := range this.GroupBy {
		groupkeyval, err := this.Base.Evaluate(groupElement, item)
		if err == nil {
			groupkey.SetIndex(i, groupkeyval)
		} else {
			switch err := err.(type) {
			case *dparval.Undefined:
				// FIXME better way?
				groupkey.SetIndex(i, "__tuqtng__MISSING__")
			default:
				return this.Base.SendError(query.NewError(err, "error evaluating group by"))
			}
		}
	}
	// FIXME slow, but lets me use map to match same groups
	groupkeybytes := groupkey.Bytes()
	groupkeystring := string(groupkeybytes)

	group, ok := this.groups[groupkeystring]
	if !ok {
		// new group
		this.groups[groupkeystring] = item
		group = item
		this.setGroupDefaults(group)
	}
	this.updateGroup(group, item)
	return true
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:30,代码来源:grouper.go


示例18: BucketByName

func (p *pool) BucketByName(name string) (b catalog.Bucket, e query.Error) {
	b, ok := p.buckets[name]
	if !ok {
		return nil, query.NewError(nil, "Bucket "+name+" not found.")
	}
	return b, nil
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:7,代码来源:mock.go


示例19: Count

func (b *poolbucket) Count() (int64, query.Error) {
	poolIds, err := b.pool.site.actualSite.PoolIds()
	if err == nil {
		return int64(len(poolIds)), nil
	}
	return 0, query.NewError(err, "")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:7,代码来源:system_bucket_pools.go


示例20: newBucket

func newBucket(p *pool, name string) (*bucket, query.Error) {
	clog.To(catalog.CHANNEL, "Created New Bucket %s", name)
	cbbucket, err := p.cbpool.GetBucket(name)
	if err != nil {
		// go-couchbase caches the buckets
		// to be sure no such bucket exists right now
		// we trigger a refresh
		p.refresh()
		// and then check one more time
		cbbucket, err = p.cbpool.GetBucket(name)
		if err != nil {
			// really no such bucket exists
			return nil, query.NewError(nil, fmt.Sprintf("Bucket %v not found.", name))
		}
	}

	rv := &bucket{
		pool:     p,
		name:     name,
		cbbucket: cbbucket,
		indexes:  make(map[string]catalog.Index),
	}

	ierr := rv.loadIndexes()
	if err != nil {
		return nil, ierr
	}

	return rv, nil
}
开发者ID:phonkee,项目名称:tuqtng,代码行数:30,代码来源:couchbase.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang query.Error类代码示例发布时间:2022-05-23
下一篇:
Golang ast.Expression类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap