feedback: Changes in response to PR feedback

pull/13426/head
Stuart Carnie 2019-04-18 07:31:15 -07:00
parent 904c91aecc
commit 972cda1775
No known key found for this signature in database
GPG Key ID: 848D9C9718D78B4F
7 changed files with 17 additions and 32 deletions

View File

@ -17,7 +17,8 @@ func (e *Engine) TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start
// * All tag keys;
// * All tag keys filtered by an arbitrary predicate, e.g., tag keys for a measurement or tag keys appearing alongside another tag key pair.
//
return cursors.EmptyStringIterator
return cursors.NewStringSliceIterator([]string{"\x00", "arch", "cluster_id", "datacenter", "hostname", "os", "rack", "region", "service", "service_environment", "service_version", "\xff"})
}
// TagValues returns an iterator which enumerates the values for the specific
@ -31,12 +32,4 @@ func (e *Engine) TagValues(ctx context.Context, orgID, bucketID influxdb.ID, tag
}
return e.engine.TagValues(ctx, orgID, bucketID, tagKey, start, end, predicate)
// This method would be invoked when the consumer wants to get the following schema information for an arbitrary
// time range in a single bucket:
//
// * All measurement names, i.e. tagKey == _measurement);
// * All field names for a specific measurement using a predicate
// * i.e. tagKey is "_field", predicate _measurement == "<measurement>"
//
}

View File

@ -1109,8 +1109,7 @@ func (a *TimestampArray) Exclude(min, max int64) {
}
// Contains returns true if values exist between min and max inclusive. The
// values must be deduplicated and sorted before calling Contains or the
// results are undefined.
// values must be sorted before calling Contains or the results are undefined.
func (a *TimestampArray) Contains(min, max int64) bool {
rmin, rmax := a.FindRange(min, max)
if rmin == -1 && rmax == -1 {

View File

@ -238,8 +238,7 @@ func (a *{{ $typename }}) Exclude(min, max int64) {
}
// Contains returns true if values exist between min and max inclusive. The
// values must be deduplicated and sorted before calling Contains or the
// results are undefined.
// values must be sorted before calling Contains or the results are undefined.
func (a *{{ $typename }}) Contains(min, max int64) bool {
rmin, rmax := a.FindRange(min, max)
if rmin == -1 && rmax == -1 {

View File

@ -115,8 +115,8 @@ func (a Values) Encode(buf []byte) ([]byte, error) {
}
// Contains returns true if values exist for the time interval [min, max]
// inclusive. The values must be deduplicated and sorted before calling
// Contains or the results are undefined.
// inclusive. The values must be sorted before calling Contains or the
// results are undefined.
func (a Values) Contains(min, max int64) bool {
rmin, rmax := a.FindRange(min, max)
if rmin == -1 && rmax == -1 {

View File

@ -20,20 +20,11 @@ import (
func (e *Engine) TagValues(ctx context.Context, orgID, bucketID influxdb.ID, tagKey string, start, end int64, predicate influxql.Expr) (cursors.StringIterator, error) {
encoded := tsdb.EncodeName(orgID, bucketID)
var tagKeyBytes []byte
if tagKey == "_measurement" {
tagKeyBytes = models.MeasurementTagKeyBytes
} else if tagKey == "_field" {
tagKeyBytes = models.FieldKeyTagKeyBytes
} else {
tagKeyBytes = []byte(tagKey)
}
if predicate == nil {
return e.tagValuesNoPredicate(ctx, encoded[:], tagKeyBytes, start, end)
return e.tagValuesNoPredicate(ctx, encoded[:], []byte(tagKey), start, end)
}
return e.tagValuesPredicate(ctx, encoded[:], tagKeyBytes, start, end, predicate)
return e.tagValuesPredicate(ctx, encoded[:], []byte(tagKey), start, end, predicate)
}
func (e *Engine) tagValuesNoPredicate(ctx context.Context, orgBucket, tagKeyBytes []byte, start, end int64) (cursors.StringIterator, error) {

View File

@ -6,6 +6,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/models"
"github.com/influxdata/influxdb/tsdb/cursors"
"github.com/influxdata/influxdb/tsdb/tsm1"
"github.com/influxdata/influxql"
@ -164,12 +165,12 @@ memB,host=EB,os=macOS value=1.3 201`)
exp: nil,
},
// _measurement tag
// models.MeasurementTagKey tag
{
name: "_measurement/all",
args: args{
org: 0,
key: "_measurement",
key: models.MeasurementTagKey,
min: 0,
max: 399,
},
@ -179,7 +180,7 @@ memB,host=EB,os=macOS value=1.3 201`)
name: "_measurement/some",
args: args{
org: 0,
key: "_measurement",
key: models.MeasurementTagKey,
min: 205,
max: 399,
},

View File

@ -1,9 +1,11 @@
package tsm1
import (
"fmt"
"errors"
)
var errKeyCountChanged = errors.New("TSMIndexIterator: key count changed during iteration")
// TSMIndexIterator allows one to iterate over the TSM index.
type TSMIndexIterator struct {
b *faultBuffer
@ -31,7 +33,7 @@ type TSMIndexIterator struct {
func (t *TSMIndexIterator) Next() bool {
t.d.mu.RLock()
if n := len(t.d.ro.offsets); t.n != n {
t.err, t.ok = fmt.Errorf("Key count changed during iteration"), false
t.err, t.ok = errKeyCountChanged, false
}
if !t.ok || t.err != nil {
t.d.mu.RUnlock()
@ -65,7 +67,7 @@ func (t *TSMIndexIterator) Next() bool {
func (t *TSMIndexIterator) Seek(key []byte) (exact, ok bool) {
t.d.mu.RLock()
if n := len(t.d.ro.offsets); t.n != n {
t.err, t.ok = fmt.Errorf("Key count changed during iteration"), false
t.err, t.ok = errKeyCountChanged, false
}
if t.err != nil {
t.d.mu.RUnlock()