Documentation ¶
Index ¶
- Constants
- Variables
- func EcShardBaseFileName(collection string, id int) (baseFileName string)
- func EcShardFileName(collection string, dir string, id int) (fileName string)
- func FindDatFileSize(dataBaseFileName, indexBaseFileName string) (datSize int64, err error)
- func RebuildEcFiles(baseFileName string) ([]uint32, error)
- func RebuildEcxFile(baseFileName string) error
- func SearchNeedleFromSortedIndex(ecxFile *os.File, ecxFileSize int64, needleId types.NeedleId, ...) (offset types.Offset, size types.Size, err error)
- func ToExt(ecIndex int) string
- func WriteDatFile(baseFileName string, datFileSize int64) error
- func WriteEcFiles(baseFileName string) error
- func WriteIdxFileFromEcIndex(baseFileName string) (err error)
- func WriteSortedFileFromIdx(baseFileName string, ext string) (e error)
- type EcVolume
- func (ev *EcVolume) AddEcVolumeShard(ecVolumeShard *EcVolumeShard) bool
- func (ev *EcVolume) Close()
- func (ev *EcVolume) CreatedAt() time.Time
- func (ev *EcVolume) DataBaseFileName() string
- func (ev *EcVolume) DeleteEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolumeShard, deleted bool)
- func (ev *EcVolume) DeleteNeedleFromEcx(needleId types.NeedleId) (err error)
- func (ev *EcVolume) Destroy()
- func (ev *EcVolume) FileName(ext string) string
- func (ev *EcVolume) FindEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolumeShard, found bool)
- func (ev *EcVolume) FindNeedleFromEcx(needleId types.NeedleId) (offset types.Offset, size types.Size, err error)
- func (ev *EcVolume) IndexBaseFileName() string
- func (ev *EcVolume) LocateEcShardNeedle(needleId types.NeedleId, version needle.Version) (offset types.Offset, size types.Size, intervals []Interval, err error)
- func (ev *EcVolume) ShardIdList() (shardIds []ShardId)
- func (ev *EcVolume) ShardSize() uint64
- func (ev *EcVolume) Size() (size int64)
- func (ev *EcVolume) ToVolumeEcShardInformationMessage() (messages []*master_pb.VolumeEcShardInformationMessage)
- type EcVolumeInfo
- func (ecInfo *EcVolumeInfo) AddShardId(id ShardId)
- func (ecInfo *EcVolumeInfo) HasShardId(id ShardId) bool
- func (ecInfo *EcVolumeInfo) Minus(other *EcVolumeInfo) *EcVolumeInfo
- func (ecInfo *EcVolumeInfo) RemoveShardId(id ShardId)
- func (ecInfo *EcVolumeInfo) ShardIdCount() (count int)
- func (ecInfo *EcVolumeInfo) ShardIds() (ret []ShardId)
- func (ecInfo *EcVolumeInfo) ToVolumeEcShardInformationMessage() (ret *master_pb.VolumeEcShardInformationMessage)
- type EcVolumeShard
- type Interval
- type ShardBits
- func (b ShardBits) AddShardId(id ShardId) ShardBits
- func (b ShardBits) HasShardId(id ShardId) bool
- func (b ShardBits) Minus(other ShardBits) ShardBits
- func (b ShardBits) MinusParityShards() ShardBits
- func (b ShardBits) Plus(other ShardBits) ShardBits
- func (b ShardBits) RemoveShardId(id ShardId) ShardBits
- func (b ShardBits) ShardIdCount() (count int)
- func (b ShardBits) ShardIds() (ret []ShardId)
- func (b ShardBits) ToUint32Slice() (ret []uint32)
- type ShardId
Constants ¶
View Source
const ( DataShardsCount = 10 ParityShardsCount = 4 TotalShardsCount = DataShardsCount + ParityShardsCount ErasureCodingLargeBlockSize = 1024 * 1024 * 1024 // 1GB ErasureCodingSmallBlockSize = 1024 * 1024 // 1MB )
Variables ¶
View Source
var ( MarkNeedleDeleted = func(file *os.File, offset int64) error { b := make([]byte, types.SizeSize) types.SizeToBytes(b, types.TombstoneFileSize) n, err := file.WriteAt(b, offset+types.NeedleIdSize+types.OffsetSize) if err != nil { return fmt.Errorf("sorted needle write error: %v", err) } if n != types.SizeSize { return fmt.Errorf("sorted needle written %d bytes, expecting %d", n, types.SizeSize) } return nil } )
View Source
var (
NotFoundError = errors.New("needle not found")
)
Functions ¶
func EcShardBaseFileName ¶
func EcShardFileName ¶
func FindDatFileSize ¶
FindDatFileSize calculate .dat file size from max offset entry there may be extra deletions after that entry but they are deletions anyway
func RebuildEcFiles ¶
func RebuildEcxFile ¶
func WriteDatFile ¶
WriteDatFile generates .dat from from .ec00 ~ .ec09 files
func WriteEcFiles ¶
WriteEcFiles generates .ec00 ~ .ec13 files
func WriteIdxFileFromEcIndex ¶
write .idx file from .ecx and .ecj files
func WriteSortedFileFromIdx ¶
WriteSortedFileFromIdx generates .ecx file from existing .idx file all keys are sorted in ascending order
Types ¶
type EcVolume ¶
type EcVolume struct { VolumeId needle.VolumeId Collection string Shards []*EcVolumeShard ShardLocations map[ShardId][]pb.ServerAddress ShardLocationsRefreshTime time.Time ShardLocationsLock sync.RWMutex Version needle.Version // contains filtered or unexported fields }
func NewEcVolume ¶
func (*EcVolume) AddEcVolumeShard ¶
func (ev *EcVolume) AddEcVolumeShard(ecVolumeShard *EcVolumeShard) bool
func (*EcVolume) DataBaseFileName ¶
func (*EcVolume) DeleteEcVolumeShard ¶
func (ev *EcVolume) DeleteEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolumeShard, deleted bool)
func (*EcVolume) DeleteNeedleFromEcx ¶
func (*EcVolume) FindEcVolumeShard ¶
func (ev *EcVolume) FindEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolumeShard, found bool)
func (*EcVolume) FindNeedleFromEcx ¶
func (*EcVolume) IndexBaseFileName ¶
func (*EcVolume) LocateEcShardNeedle ¶
func (*EcVolume) ShardIdList ¶
func (*EcVolume) ToVolumeEcShardInformationMessage ¶
func (ev *EcVolume) ToVolumeEcShardInformationMessage() (messages []*master_pb.VolumeEcShardInformationMessage)
type EcVolumeInfo ¶
type EcVolumeInfo struct { VolumeId needle.VolumeId Collection string ShardBits ShardBits DiskType string }
data structure used in master
func NewEcVolumeInfo ¶
func (*EcVolumeInfo) AddShardId ¶
func (ecInfo *EcVolumeInfo) AddShardId(id ShardId)
func (*EcVolumeInfo) HasShardId ¶
func (ecInfo *EcVolumeInfo) HasShardId(id ShardId) bool
func (*EcVolumeInfo) Minus ¶
func (ecInfo *EcVolumeInfo) Minus(other *EcVolumeInfo) *EcVolumeInfo
func (*EcVolumeInfo) RemoveShardId ¶
func (ecInfo *EcVolumeInfo) RemoveShardId(id ShardId)
func (*EcVolumeInfo) ShardIdCount ¶
func (ecInfo *EcVolumeInfo) ShardIdCount() (count int)
func (*EcVolumeInfo) ShardIds ¶
func (ecInfo *EcVolumeInfo) ShardIds() (ret []ShardId)
func (*EcVolumeInfo) ToVolumeEcShardInformationMessage ¶
func (ecInfo *EcVolumeInfo) ToVolumeEcShardInformationMessage() (ret *master_pb.VolumeEcShardInformationMessage)
type EcVolumeShard ¶
type EcVolumeShard struct { VolumeId needle.VolumeId ShardId ShardId Collection string DiskType types.DiskType // contains filtered or unexported fields }
func NewEcVolumeShard ¶
func (*EcVolumeShard) Close ¶
func (shard *EcVolumeShard) Close()
func (*EcVolumeShard) Destroy ¶
func (shard *EcVolumeShard) Destroy()
func (*EcVolumeShard) FileName ¶
func (shard *EcVolumeShard) FileName() (fileName string)
func (*EcVolumeShard) ReadAt ¶
func (shard *EcVolumeShard) ReadAt(buf []byte, offset int64) (int, error)
func (*EcVolumeShard) Size ¶
func (shard *EcVolumeShard) Size() int64
func (*EcVolumeShard) String ¶
func (shard *EcVolumeShard) String() string
type Interval ¶
type Interval struct { BlockIndex int InnerBlockOffset int64 Size types.Size IsLargeBlock bool LargeBlockRowsCount int }
func LocateData ¶
type ShardBits ¶
type ShardBits uint32 // use bits to indicate the shard id, use 32 bits just for possible future extension
func (ShardBits) AddShardId ¶
func (ShardBits) HasShardId ¶
func (ShardBits) MinusParityShards ¶
func (ShardBits) RemoveShardId ¶
func (ShardBits) ShardIdCount ¶
func (ShardBits) ToUint32Slice ¶
Click to show internal directories.
Click to hide internal directories.