func (r *DropMeasurementRule) EndTSM() {
}
EndTSM implements Rule interface
package rules
import (
	"log"
	"github.com/Abc-Arbitrage/infix/filter"
	"github.com/Abc-Arbitrage/infix/logging"
	"github.com/Abc-Arbitrage/infix/storage"
	"github.com/influxdata/influxdb/models"
	"github.com/influxdata/influxdb/tsdb/engine/tsm1"
)
type DropMeasurementRule struct {
	filter filter.Filter
	check bool
	shard   storage.ShardInfo
	dropped map[string]bool
	logger *log.Logger
}
type DropMeasurementRuleConfig struct {
	DropFilter filter.Filter
}
func NewDropMeasurement(srcName string) *DropMeasurementRule {
	filter := filter.NewIncludeFilter([]string{srcName})
	return NewDropMeasurementWithFilter(filter)
}
func NewDropMeasurementWithPattern(pattern string) (*DropMeasurementRule, error) {
	filter, err := filter.NewPatternFilter(pattern)
	if err != nil {
		return nil, err
	}
	return NewDropMeasurementWithFilter(filter), nil
}
func NewDropMeasurementWithFilter(f filter.Filter) *DropMeasurementRule {
	measurementFilter := filter.NewMeasurementFilter(f)
	return &DropMeasurementRule{
		filter:  measurementFilter,
		dropped: make(map[string]bool),
		check:   false,
		logger:  logging.GetLogger("DropMeasurementRule"),
	}
}
func (r *DropMeasurementRule) CheckMode(check bool) {
	r.check = check
}
func (r *DropMeasurementRule) Flags() int {
	return Standard
}
func (r *DropMeasurementRule) WithLogger(logger *log.Logger) {
	r.logger = logger
}
func (r *DropMeasurementRule) FilterKey(key []byte) bool {
	return r.filter.Filter(key)
}
func (r *DropMeasurementRule) Start() {
}
func (r *DropMeasurementRule) End() {
}
func (r *DropMeasurementRule) StartShard(info storage.ShardInfo) bool {
	r.shard = info
	return true
}
func (r *DropMeasurementRule) EndShard() error {
	if len(r.dropped) > 0 {
		shard := r.shard
		if shard.FieldsIndex == nil {
			return nil
		}
		for d := range r.dropped {
			r.logger.Printf("Deleting fields in index for measurement '%s'", d)
			shard.FieldsIndex.Delete(d)
		}
		if !r.check {
			shard.FieldsIndex.Save()
		}
		r.dropped = make(map[string]bool)
	}
	return nil
}
func (r *DropMeasurementRule) StartTSM(path string) bool {
	return true
}