@ -10,7 +10,6 @@ import (
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/seaweedfs/seaweedfs/weed/storage/idx"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/syndtr/goleveldb/leveldb"
@ -56,7 +55,7 @@ func NewLevelDbNeedleMap(dbFileName string, indexFile *os.File, opts *opt.Option
}
}
glog . V ( 0 ) . Infof ( "Loading %s... , watermark: %d" , dbFileName , getWatermark ( m . db ) )
m . recordCount = uint64 ( m . indexFileOffset / types . NeedleMapEntrySize )
m . recordCount = uint64 ( m . indexFileOffset / NeedleMapEntrySize )
watermark := ( m . recordCount / watermarkBatchSize ) * watermarkBatchSize
err = setWatermark ( m . db , watermark )
if err != nil {
@ -100,10 +99,10 @@ func generateLevelDbFile(dbFileName string, indexFile *os.File) error {
glog . Fatalf ( "stat file %s: %v" , indexFile . Name ( ) , err )
return err
} else {
if watermark * types . NeedleMapEntrySize > uint64 ( stat . Size ( ) ) {
if watermark * NeedleMapEntrySize > uint64 ( stat . Size ( ) ) {
glog . Warningf ( "wrong watermark %d for filesize %d" , watermark , stat . Size ( ) )
}
glog . V ( 0 ) . Infof ( "generateLevelDbFile %s, watermark %d, num of entries:%d" , dbFileName , watermark , ( uint64 ( stat . Size ( ) ) - watermark * types . NeedleMapEntrySize ) / types . NeedleMapEntrySize )
glog . V ( 0 ) . Infof ( "generateLevelDbFile %s, watermark %d, num of entries:%d" , dbFileName , watermark , ( uint64 ( stat . Size ( ) ) - watermark * NeedleMapEntrySize ) / NeedleMapEntrySize )
}
return idx . WalkIndexFile ( indexFile , watermark , func ( key NeedleId , offset Offset , size Size ) error {
if ! offset . IsZero ( ) && size . IsValid ( ) {
@ -270,7 +269,7 @@ func (m *LevelDbNeedleMap) UpdateNeedleMap(v *Volume, indexFile *os.File, opts *
return e
}
m . indexFileOffset = stat . Size ( )
m . recordCount = uint64 ( stat . Size ( ) / types . NeedleMapEntrySize )
m . recordCount = uint64 ( stat . Size ( ) / NeedleMapEntrySize )
//set watermark
watermark := ( m . recordCount / watermarkBatchSize ) * watermarkBatchSize