generate ec01~ec14, generate ecx file with sorted needle values

This commit is contained in:
Chris Lu
2019-05-18 22:46:24 -07:00
parent 12dc6608f0
commit 87f63b9c08
8 changed files with 189 additions and 48 deletions

View File

@@ -2,6 +2,7 @@ package needle_map
import (
. "github.com/chrislusf/seaweedfs/weed/storage/types"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/google/btree"
)
@@ -15,3 +16,15 @@ func (this NeedleValue) Less(than btree.Item) bool {
that := than.(NeedleValue)
return this.Key < that.Key
}
func (nv NeedleValue) ToBytes() []byte {
return ToBytes(nv.Key, nv.Offset, nv.Size)
}
func ToBytes(key NeedleId, offset Offset, size uint32) []byte {
bytes := make([]byte, NeedleIdSize+OffsetSize+SizeSize)
NeedleIdToBytes(bytes[0:NeedleIdSize], key)
OffsetToBytes(bytes[NeedleIdSize:NeedleIdSize+OffsetSize], offset)
util.Uint32toBytes(bytes[NeedleIdSize+OffsetSize:NeedleIdSize+OffsetSize+SizeSize], size)
return bytes
}