func NewIndex(sfile *tsdb.SeriesFile, database string, options ...IndexOption) *Index {
	idx := &Index{
		maxLogFileSize: tsdb.DefaultMaxIndexLogFileSize,
		logger:         zap.NewNop(),
		version:        Version,
		sfile:          sfile,
		database:       database,
		PartitionN:     DefaultPartitionN,
	}
	for _, option := range options {
		option(idx)
	}
	return idx
}
NewIndex returns a new instance of Index.
package tsi1
import (
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"regexp"
	"runtime"
	"strconv"
	"sync"
	"sync/atomic"
	"github.com/cespare/xxhash"
	"github.com/influxdata/influxdb/models"
	"github.com/influxdata/influxdb/pkg/estimator"
	"github.com/influxdata/influxdb/pkg/estimator/hll"
	"github.com/influxdata/influxdb/pkg/slices"
	"github.com/influxdata/influxdb/tsdb"
	"github.com/influxdata/influxql"
	"go.uber.org/zap"
)
const IndexName = "tsi1"
var ErrCompactionInterrupted = errors.New("tsi1: compaction interrupted")
func init() {
	if os.Getenv("TSI_PARTITIONS") != "" {
		i, err := strconv.Atoi(os.Getenv("TSI_PARTITIONS"))
		if err != nil {
			panic(err)
		}
		DefaultPartitionN = uint64(i)
	}
	tsdb.RegisterIndex(IndexName, func(_ uint64, db, path string, _ *tsdb.SeriesIDSet, sfile *tsdb.SeriesFile, opt tsdb.EngineOptions) tsdb.Index {
		idx := NewIndex(sfile, db, WithPath(path), WithMaximumLogFileSize(int64(opt.Config.MaxIndexLogFileSize)))
		return idx
	})
}
var DefaultPartitionN uint64 = 8
type IndexOption func(i *Index)
var WithPath = func(path string) IndexOption {
	return func(i *Index) {
		i.path = path
	}
}
var DisableCompactions = func() IndexOption {
	return func(i *Index) {
		i.disableCompactions = true
	}
}
var WithLogger = func(l zap.Logger) IndexOption {
	return func(i *Index) {
		i.logger = l.With(zap.String("index", "tsi"))
	}
}
var WithMaximumLogFileSize = func(size int64) IndexOption {
	return func(i *Index) {
		i.maxLogFileSize = size
	}
}
type Index struct {
	mu         sync.RWMutex
	partitions []*Partition
	opened     bool
	path               string       
	disableCompactions bool         
	maxLogFileSize     int64        
	logger             *zap.Logger  
	sfile    *tsdb.SeriesFile  
	database string            
	version int
	PartitionN uint64
}