Exemplo n.º 1
0
// NewVolume new a volume and init it.
func NewVolume(id int32, bfile, ifile string, c *Config) (v *Volume, err error) {
	v = &Volume{}
	v.Id = id
	v.conf = c
	v.closed = false
	v.Stats = &stat.Stats{}
	v.needles = make(map[int64]int64, c.VolumeNeedleCache)
	v.ch = make(chan uint32, c.VolumeDelChan)
	v.compactKeys = []int64{}
	if v.Block, err = block.NewSuperBlock(bfile, block.Options{
		BufferSize:    c.NeedleMaxSize * c.BatchMaxNum,
		SyncAtWrite:   c.SuperBlockSync,
		Syncfilerange: c.SuperBlockSyncfilerange,
	}); err != nil {
		return nil, err
	}
	if v.Indexer, err = index.NewIndexer(ifile, index.Options{
		MergeAtTime:   c.IndexMergeTime,
		MergeAtWrite:  c.IndexMerge,
		RingBuffer:    c.IndexRingBuffer,
		BufferSize:    c.IndexBufferio,
		SyncAtWrite:   c.IndexSync,
		Syncfilerange: c.IndexSyncfilerange,
	}); err != nil {
		v.Close()
		return nil, err
	}
	if err = v.init(); err != nil {
		v.Close()
		return nil, err
	}
	v.wg.Add(1)
	go v.del()
	return
}
Exemplo n.º 2
0
// NewVolume new a volume and init it.
func NewVolume(id int32, bfile, ifile string, vo Options, bo block.Options, io index.Options) (v *Volume, err error) {
	v = &Volume{}
	v.Id = id
	v.Options = vo
	v.closed = false
	v.Stats = &stat.Stats{}
	v.needles = make(map[int64]int64, vo.NeedleCache)
	v.ch = make(chan uint32, vo.DeleteChan)
	v.compactKeys = []int64{}
	v.checkCurIdx = 0
	v.checkMaxIdx = vo.CheckSize - 1
	v.check = 0
	v.CheckNeedles = make([]CheckNeedle, vo.CheckSize)
	if v.Block, err = block.NewSuperBlock(bfile, bo); err != nil {
		return nil, err
	}
	if v.Indexer, err = index.NewIndexer(ifile, io); err != nil {
		v.Close()
		return nil, err
	}
	if err = v.init(); err != nil {
		v.Close()
		return nil, err
	}
	v.wg.Add(1)
	go v.delproc()
	return
}
Exemplo n.º 3
0
// NewVolume new a volume and init it.
func NewVolume(id int32, bfile, ifile string, c *Config) (v *Volume, err error) {
	v = &Volume{}
	v.Id = id
	v.conf = c
	v.closed = false
	v.Stats = &stat.Stats{}
	v.needles = make(map[int64]int64, c.VolumeNeedleCache)
	v.ch = make(chan uint32, c.VolumeDelChan)
	v.compactKeys = []int64{}
	if v.Block, err = block.NewSuperBlock(bfile, c.NeedleMaxSize*c.BatchMaxNum); err != nil {
		return nil, err
	}
	if v.Indexer, err = index.NewIndexer(ifile, c.IndexSigTime, c.IndexSigCnt, c.IndexRingBuffer, c.IndexBufferio); err != nil {
		v.Close()
		return nil, err
	}
	if err = v.init(); err != nil {
		v.Close()
		return nil, err
	}
	v.wg.Add(1)
	go v.del()
	return
}