MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / ViewQueryWithStats

Method ViewQueryWithStats

db/query.go:403–425  ·  view source on GitHub ↗

ViewQueryWithStats is a wrapper for gocbBucket.Query that performs additional diagnostic processing (expvars, slow query logging)

(ctx context.Context, dataStore base.DataStore, ddoc string, viewName string, params map[string]interface{})

Source from the content-addressed store, hash-verified

401
402// ViewQueryWithStats is a wrapper for gocbBucket.Query that performs additional diagnostic processing (expvars, slow query logging)
403func (context *DatabaseContext) ViewQueryWithStats(ctx context.Context, dataStore base.DataStore, ddoc string, viewName string, params map[string]interface{}) (results sgbucket.QueryResultIterator, err error) {
404
405 startTime := time.Now()
406 if threshold := context.Options.SlowQueryWarningThreshold; threshold > 0 {
407 defer base.SlowQueryLog(ctx, startTime, threshold, "View Query (%s.%s)", ddoc, viewName)
408 }
409
410 queryStat := context.DbStats.Query(fmt.Sprintf(base.StatViewFormat, ddoc, viewName))
411
412 viewStore, ok := base.AsViewStore(dataStore)
413 if !ok {
414 return results, fmt.Errorf("Datastore does not support views")
415 }
416
417 results, err = viewStore.ViewQuery(ctx, ddoc, viewName, params)
418 if err != nil {
419 queryStat.QueryErrorCount.Add(1)
420 }
421 queryStat.QueryCount.Add(1)
422 queryStat.QueryTime.Add(time.Since(startTime).Nanoseconds())
423
424 return results, err
425}
426
427// Query to compute the set of channels granted to the specified user via the Sync Function
428func (c *DatabaseCollection) QueryAccess(ctx context.Context, username string) (sgbucket.QueryResultIterator, error) {

Callers 7

QueryPrincipalsMethod · 0.95
QueryRolesMethod · 0.95
QueryAccessMethod · 0.80
QueryRoleAccessMethod · 0.80
QueryChannelsMethod · 0.80
QueryAllDocsMethod · 0.80
QueryTombstonesMethod · 0.80

Calls 7

SlowQueryLogFunction · 0.92
AsViewStoreFunction · 0.92
ErrorfMethod · 0.80
QueryMethod · 0.65
ViewQueryMethod · 0.45
AddMethod · 0.45
SinceMethod · 0.45

Tested by

no test coverage detected