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


Golang query.NewError函数代码示例

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


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


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