feat(storage): Provide public MeasurementFields API

pull/17737/head
Stuart Carnie 2020-04-14 10:49:16 -07:00
parent a3dec4b120
commit fe0ed6cb7e
No known key found for this signature in database
GPG Key ID: 848D9C9718D78B4F
2 changed files with 26 additions and 0 deletions

View File

@ -60,3 +60,21 @@ func (e *Engine) MeasurementTagKeys(ctx context.Context, orgID, bucketID influxd
return e.engine.MeasurementTagKeys(ctx, orgID, bucketID, measurement, start, end, predicate)
}
// MeasurementFields returns an iterator which enumerates the field schema for the given
// bucket and measurement, filtered using the optional the predicate and limited to the
//// time range (start, end].
//
// MeasurementFields will always return a MeasurementFieldsIterator if there is no error.
//
// If the context is canceled before MeasurementFields has finished processing, a non-nil
// error will be returned along with statistics for the already scanned data.
func (e *Engine) MeasurementFields(ctx context.Context, orgID, bucketID influxdb.ID, measurement string, start, end int64, predicate influxql.Expr) (cursors.MeasurementFieldsIterator, error) {
e.mu.RLock()
defer e.mu.RUnlock()
if e.closing == nil {
return cursors.EmptyMeasurementFieldsIterator, nil
}
return e.engine.MeasurementFields(ctx, orgID, bucketID, measurement, start, end, predicate)
}

View File

@ -159,6 +159,14 @@ func (e *Engine) MeasurementTagKeys(ctx context.Context, orgID, bucketID influxd
return e.tagKeysPredicate(ctx, orgID, bucketID, []byte(measurement), start, end, predicate)
}
// MeasurementFields returns an iterator which enumerates the field schema for the given
// bucket and measurement, filtered using the optional the predicate and limited to the
//// time range (start, end].
//
// MeasurementFields will always return a MeasurementFieldsIterator if there is no error.
//
// If the context is canceled before MeasurementFields has finished processing, a non-nil
// error will be returned along with statistics for the already scanned data.
func (e *Engine) MeasurementFields(ctx context.Context, orgID, bucketID influxdb.ID, measurement string, start, end int64, predicate influxql.Expr) (cursors.MeasurementFieldsIterator, error) {
if predicate == nil {
return e.fieldsNoPredicate(ctx, orgID, bucketID, []byte(measurement), start, end)