feedback: Changes in response to PR feedback
parent
904c91aecc
commit
972cda1775
|
@ -17,7 +17,8 @@ func (e *Engine) TagKeys(ctx context.Context, orgID, bucketID influxdb.ID, start
|
||||||
// * All tag keys;
|
// * 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.
|
// * 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
|
// 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)
|
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>"
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1109,8 +1109,7 @@ func (a *TimestampArray) Exclude(min, max int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains returns true if values exist between min and max inclusive. The
|
// Contains returns true if values exist between min and max inclusive. The
|
||||||
// values must be deduplicated and sorted before calling Contains or the
|
// values must be sorted before calling Contains or the results are undefined.
|
||||||
// results are undefined.
|
|
||||||
func (a *TimestampArray) Contains(min, max int64) bool {
|
func (a *TimestampArray) Contains(min, max int64) bool {
|
||||||
rmin, rmax := a.FindRange(min, max)
|
rmin, rmax := a.FindRange(min, max)
|
||||||
if rmin == -1 && rmax == -1 {
|
if rmin == -1 && rmax == -1 {
|
||||||
|
|
|
@ -238,8 +238,7 @@ func (a *{{ $typename }}) Exclude(min, max int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains returns true if values exist between min and max inclusive. The
|
// Contains returns true if values exist between min and max inclusive. The
|
||||||
// values must be deduplicated and sorted before calling Contains or the
|
// values must be sorted before calling Contains or the results are undefined.
|
||||||
// results are undefined.
|
|
||||||
func (a *{{ $typename }}) Contains(min, max int64) bool {
|
func (a *{{ $typename }}) Contains(min, max int64) bool {
|
||||||
rmin, rmax := a.FindRange(min, max)
|
rmin, rmax := a.FindRange(min, max)
|
||||||
if rmin == -1 && rmax == -1 {
|
if rmin == -1 && rmax == -1 {
|
||||||
|
|
|
@ -115,8 +115,8 @@ func (a Values) Encode(buf []byte) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains returns true if values exist for the time interval [min, max]
|
// Contains returns true if values exist for the time interval [min, max]
|
||||||
// inclusive. The values must be deduplicated and sorted before calling
|
// inclusive. The values must be sorted before calling Contains or the
|
||||||
// Contains or the results are undefined.
|
// results are undefined.
|
||||||
func (a Values) Contains(min, max int64) bool {
|
func (a Values) Contains(min, max int64) bool {
|
||||||
rmin, rmax := a.FindRange(min, max)
|
rmin, rmax := a.FindRange(min, max)
|
||||||
if rmin == -1 && rmax == -1 {
|
if rmin == -1 && rmax == -1 {
|
||||||
|
|
|
@ -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) {
|
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)
|
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 {
|
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) {
|
func (e *Engine) tagValuesNoPredicate(ctx context.Context, orgBucket, tagKeyBytes []byte, start, end int64) (cursors.StringIterator, error) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/influxdata/influxdb"
|
"github.com/influxdata/influxdb"
|
||||||
|
"github.com/influxdata/influxdb/models"
|
||||||
"github.com/influxdata/influxdb/tsdb/cursors"
|
"github.com/influxdata/influxdb/tsdb/cursors"
|
||||||
"github.com/influxdata/influxdb/tsdb/tsm1"
|
"github.com/influxdata/influxdb/tsdb/tsm1"
|
||||||
"github.com/influxdata/influxql"
|
"github.com/influxdata/influxql"
|
||||||
|
@ -164,12 +165,12 @@ memB,host=EB,os=macOS value=1.3 201`)
|
||||||
exp: nil,
|
exp: nil,
|
||||||
},
|
},
|
||||||
|
|
||||||
// _measurement tag
|
// models.MeasurementTagKey tag
|
||||||
{
|
{
|
||||||
name: "_measurement/all",
|
name: "_measurement/all",
|
||||||
args: args{
|
args: args{
|
||||||
org: 0,
|
org: 0,
|
||||||
key: "_measurement",
|
key: models.MeasurementTagKey,
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 399,
|
max: 399,
|
||||||
},
|
},
|
||||||
|
@ -179,7 +180,7 @@ memB,host=EB,os=macOS value=1.3 201`)
|
||||||
name: "_measurement/some",
|
name: "_measurement/some",
|
||||||
args: args{
|
args: args{
|
||||||
org: 0,
|
org: 0,
|
||||||
key: "_measurement",
|
key: models.MeasurementTagKey,
|
||||||
min: 205,
|
min: 205,
|
||||||
max: 399,
|
max: 399,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package tsm1
|
package tsm1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errKeyCountChanged = errors.New("TSMIndexIterator: key count changed during iteration")
|
||||||
|
|
||||||
// TSMIndexIterator allows one to iterate over the TSM index.
|
// TSMIndexIterator allows one to iterate over the TSM index.
|
||||||
type TSMIndexIterator struct {
|
type TSMIndexIterator struct {
|
||||||
b *faultBuffer
|
b *faultBuffer
|
||||||
|
@ -31,7 +33,7 @@ type TSMIndexIterator struct {
|
||||||
func (t *TSMIndexIterator) Next() bool {
|
func (t *TSMIndexIterator) Next() bool {
|
||||||
t.d.mu.RLock()
|
t.d.mu.RLock()
|
||||||
if n := len(t.d.ro.offsets); t.n != n {
|
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 {
|
if !t.ok || t.err != nil {
|
||||||
t.d.mu.RUnlock()
|
t.d.mu.RUnlock()
|
||||||
|
@ -65,7 +67,7 @@ func (t *TSMIndexIterator) Next() bool {
|
||||||
func (t *TSMIndexIterator) Seek(key []byte) (exact, ok bool) {
|
func (t *TSMIndexIterator) Seek(key []byte) (exact, ok bool) {
|
||||||
t.d.mu.RLock()
|
t.d.mu.RLock()
|
||||||
if n := len(t.d.ro.offsets); t.n != n {
|
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 {
|
if t.err != nil {
|
||||||
t.d.mu.RUnlock()
|
t.d.mu.RUnlock()
|
||||||
|
|
Loading…
Reference in New Issue