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


Golang clog.To函数代码示例

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


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

示例1: Optimize

// simplest possible implementation
// 1.  read all plans off plan channel
// 2.  return last plan
func (this *SimpleOptimizer) Optimize(planChannel plan.PlanChannel, errChannel query.ErrorChannel) (*plan.Plan, query.Error) {

	plans := make([]plan.Plan, 0)

	var p plan.Plan
	var err query.Error
	ok := true
	for ok {
		select {
		case p, ok = <-planChannel:
			if ok {
				clog.To(optimizer.CHANNEL, "See plan %v", p)
				plans = append(plans, p)
			}
		case err, ok = <-errChannel:
			if err != nil {
				return nil, err
			}
		}
	}

	if len(plans) > 0 {
		chosenPlan := plans[len(plans)-1]
		clog.To(optimizer.CHANNEL, "Choosing plan %v", chosenPlan)
		return &chosenPlan, nil
	}

	return nil, query.NewError(nil, "No plans produced for optimizer to choose from")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:32,代码来源:simple.go

示例2: Process

func (this *HttpQuery) Process() {
	err := this.response.Process()
	if err != nil {
		clog.To(CHANNEL, "error writing to client, aborting query")
		this.StopProcessing()
	} else {
		clog.To(CHANNEL, "response complete")
	}
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:9,代码来源:http_query.go

示例3: Run

func (this *KeyJoin) Run(stopChannel misc.StopChannel) {
	clog.To(CHANNEL, "key join operator starting")
	if this.Base.Source != nil {
		this.Base.RunOperator(this, stopChannel)
	} else {
		this.Base.SendError(query.NewError(fmt.Errorf("missing source operator"), ""))
	}

	clog.To(CHANNEL, "key join operator finished, fetched %d", this.rowsFetched)
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:10,代码来源:key_join.go

示例4: Run

func (this *StubSource) Run(stopChannel misc.StopChannel) {
	clog.To(CHANNEL, "stub source operator starting")
	defer close(this.itemChannel)
	defer close(this.supportChannel)

	for _, item := range this.data {
		this.itemChannel <- item
	}

	clog.To(CHANNEL, "stub source operator finished")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:11,代码来源:pipeline_test.go

示例5: executeInternal

func (this *InterpretedExecutor) executeInternal(optimalPlan *plan.Plan, q network.Query, timeoutStopChannel misc.StopChannel) {

	clog.To(executor.CHANNEL, "simple executor started")

	// first make the plan excutable
	executablePipeline, berr := this.xpipelinebuilder.Build(optimalPlan, q)
	if berr != nil {
		q.Response().SendError(query.NewError(berr, ""))
		return
	}
	root := executablePipeline.Root

	// create a stop channel
	stopChannel := make(misc.StopChannel)
	// set it on the query object, so HTTP layer can
	// stop us if the client goes away
	q.SetStopChannel(stopChannel)
	go root.Run(stopChannel)

	// now execute it
	var item *dparval.Value
	var obj interface{}
	sourceItemChannel, supportChannel := root.GetChannels()
	ok := true
	for ok {
		select {
		case item, ok = <-sourceItemChannel:
			if ok {
				ok = this.processItem(q, item)
				clog.To(executor.CHANNEL, "simple executor sent client item: %v", item)
			}
		case obj, ok = <-supportChannel:
			if ok {
				switch obj := obj.(type) {
				case query.Error:
					q.Response().SendError(obj)
					clog.To(executor.CHANNEL, "simple executor sent client error: %v", obj)
					if obj.IsFatal() {
						return
					}
				}
			}
		case _, ok = <-timeoutStopChannel:
			clog.To(executor.CHANNEL, "simple execution aborted, timeout")
			return
		}
	}

	q.Response().NoMoreResults()
	clog.To(executor.CHANNEL, "simple executor finished")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:51,代码来源:interpreted.go

示例6: afterItems

func (this *EliminateDuplicates) afterItems() {
	// write the output
	for pos, item := range this.buffer {
		// we will nil out duplicates and then skip over those entries in the buffer
		if item != nil {
			if pos < len(this.buffer) {
				// look to see if the exact same item appears later in the buffer
				for nextpos, nextitem := range this.buffer[pos+1:] {
					itemProj, ok := item.GetAttachment("projection").(*dparval.Value)
					if ok {
						itemVal := itemProj.Value()
						if nextitem != nil {
							nextItemProj, ok := nextitem.GetAttachment("projection").(*dparval.Value)
							if ok {
								nextItemVal := nextItemProj.Value()
								comp := ast.CollateJSON(itemVal, nextItemVal)
								if comp == 0 {
									this.buffer[pos+nextpos+1] = nil
								}
							}
						}
					}
				}
			}
			clog.To(DEBUG_DUP_CHANNEL, "distinct: %v", item)
			this.Base.SendItem(item)
		}
	}
}
开发者ID:phonkee,项目名称:tuqtng,代码行数:29,代码来源:eliminate_duplicates.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: 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

示例9: ServeHTTP

func (this *HttpEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	clog.To(CHANNEL, "request received")
	q := NewHttpQuery(w, r)
	if q != nil {
		this.queryChannel <- q
		q.Process()
	}
}
开发者ID:phonkee,项目名称:tuqtng,代码行数:8,代码来源:http.go

示例10: Run

func (this *Fetch) Run(stopChannel misc.StopChannel) {
	clog.To(CHANNEL, "fetch operator starting")
	if this.Base.Source != nil {
		this.Base.RunOperator(this, stopChannel)
	} else {
		defer close(this.Base.itemChannel)
		defer close(this.Base.supportChannel)
		defer close(this.Base.upstreamStopChannel)
		for _, id := range this.ids {
			doc := dparval.NewValue(map[string]interface{}{})
			doc.SetAttachment("meta", map[string]interface{}{"id": id})
			this.processItem(doc)
		}
		this.afterItems()
	}
	clog.To(CHANNEL, "fetch operator finished, fetched %d", this.rowsFetched)
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:17,代码来源:fetch.go

示例11: Run

func (this *KeyScan) Run(stopChannel misc.StopChannel) {
	defer close(this.itemChannel)
	defer close(this.supportChannel)
	// this MUST be here so that it runs before the channels are closed
	defer this.RecoverPanic()

	clog.To(CHANNEL, "key scan operator starting")

	for _, item := range this.keylist {
		this.rowsKeyScanned += 1
		// rematerialize an object from the data returned by this index entry
		doc := dparval.NewValue(map[string]interface{}{})
		// attach metadata
		doc.SetAttachment("meta", map[string]interface{}{"id": item})
		this.SendItem(doc)
	}

	clog.To(CHANNEL, "key scan operator finished, scanned %d", this.rowsKeyScanned)
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:19,代码来源:scan.go

示例12: refresh

func (p *pool) refresh() {
	// trigger refresh of this pool
	clog.To(catalog.CHANNEL, "Refreshing Pool %s", p.name)
	newpool, err := p.site.client.GetPool(p.name)
	if err != nil {
		clog.Warnf("Error updating pool: %v", err)
		return
	}
	p.cbpool = newpool
}
开发者ID:phonkee,项目名称:tuqtng,代码行数:10,代码来源:couchbase.go

示例13: 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

示例14: Run

func (this *DropIndex) Run(stopChannel misc.StopChannel) {
	defer close(this.itemChannel)
	defer close(this.supportChannel)
	// this MUST be here so that it runs before the channels are closed
	defer this.RecoverPanic()

	this.downstreamStopChannel = stopChannel
	clog.To(CHANNEL, "drop_index operator starting")
	err := this.index.Drop()
	if err != nil {
		this.SendError(err)
	} else {
		item := dparval.NewValue(map[string]interface{}{})
		item.SetAttachment("projection", map[string]interface{}{
			"dropped": true,
		})
		this.SendItem(item)
	}
	clog.To(CHANNEL, "drop_index operator finished")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:20,代码来源:drop_index.go

示例15: Run

func (this *CreateIndex) Run(stopChannel misc.StopChannel) {
	defer close(this.itemChannel)
	defer close(this.supportChannel)
	// this MUST be here so that it runs before the channels are closed
	defer this.RecoverPanic()

	indexType := catalog.IndexType(strings.ToLower(this.index_type))
	indexOn := make(catalog.IndexKey, len(this.on))
	for pos, key := range this.on {
		indexOn[pos] = key
	}

	this.downstreamStopChannel = stopChannel

	var index catalog.Index
	var err query.Error

	if this.primary {
		clog.To(CHANNEL, "create_index (primary) operator starting")
		index, err = this.bucket.CreatePrimaryIndex()
	} else {
		clog.To(CHANNEL, "create_index (secondary) operator starting")
		index, err = this.bucket.CreateIndex(this.name, indexOn, indexType)
	}

	if err != nil {
		this.SendError(err)
	} else {
		if index != nil {
			item := dparval.NewValue(map[string]interface{}{})
			item.SetAttachment("projection", map[string]interface{}{
				"id":   index.Id(),
				"name": index.Name(),
			})
			this.SendItem(item)
		} else {
			clog.Warn("Successfully created index, but index was nil")
		}
	}
	clog.To(CHANNEL, "create_index operator finished")
}
开发者ID:latinojoel,项目名称:tuqtng,代码行数:41,代码来源:create_index.go


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