storge

package
v0.0.0-...-46d5ffc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

*

  • Copyright 2017 wfs Author. All Rights Reserved.
  • email: donnie4w@gmail.com

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(f *os.File, bs []byte, offset int64) (n int, err error)

----------------------------------------------------------------------------------------------------------------------

func AppendData

func AppendData(bs []byte, name string, fileType string, shardname string) (err error)

func Bytes2Octal

func Bytes2Octal(bb []byte) (value int32)

func Bytes2hex

func Bytes2hex(bb []byte) (value int64)

func DBDel

func DBDel(key []byte) (err error)

func DBExsit

func DBExsit(key []byte) (b bool)

func DBPut

func DBPut(key, value []byte) (err error)

func DBPutMd5Bean

func DBPutMd5Bean(md5key []byte, md5Bean Md5Bean) (err error)

func DBPutSegment

func DBPutSegment(key []byte, s Segment) (err error)

--------------------------------------------------------------------------------------------------------------------------

func DelData

func DelData(name string) (shardname string, err error)

func DelSlave

func DelSlave(name string)

func EncodeMd5

func EncodeMd5(md5 Md5Bean) (bs []byte)

func EncodeSegment

func EncodeSegment(segment Segment) (bs []byte)

func Exsit

func Exsit(name string) (b bool)

func GetData

func GetData(name string) (bs []byte, shardname string, er error)

func Hex2bytes

func Hex2bytes(row int64) (bs []byte)

--------------------------------------------------------------------------------------------------------------------

func Init

func Init()

func MD5

func MD5(data []byte) []byte

func NewHashMap

func NewHashMap() *hashmap

func NewLruCache

func NewLruCache(maxEntries int) *lruCache

func Octal2bytes

func Octal2bytes(row int32) (bs []byte)

func ReadAt

func ReadAt(f *os.File, byteInt int, offset int64) (bs []byte, err error)

func SaveSlave

func SaveSlave(name string, bs []byte)

*****************************************************************************

func SlaveList

func SlaveList() (slavemap map[string][]byte)

func Write

func Write(f *os.File, bs []byte) (n int, err error)

Types

type Fdata

type Fdata struct {
	FileName string //所在文件名
	CurPoint int64  //当前指针
	// contains filtered or unexported fields
}

func (*Fdata) AppendData

func (this *Fdata) AppendData(bs []byte) (offset int64, size int32, err error)

func (*Fdata) CloseAndDelete

func (this *Fdata) CloseAndDelete()

func (*Fdata) CloseFile

func (this *Fdata) CloseFile()

func (*Fdata) Compact

func (this *Fdata) Compact(chip int32) (finish bool)

func (*Fdata) FileSize

func (this *Fdata) FileSize() int64

func (*Fdata) GetAndSetCurPoint

func (this *Fdata) GetAndSetCurPoint(size int64) (offset int64)

func (*Fdata) GetData

func (this *Fdata) GetData(md5Bean *Md5Bean) (bs []byte, err error)

func (*Fdata) WriteIdxMd5

func (this *Fdata) WriteIdxMd5(md5key []byte) (err error)

type FileManager

type FileManager struct {
	// contains filtered or unexported fields
}

func OpenFileManager

func OpenFileManager() (f *FileManager)

func (*FileManager) DelMd5Bean

func (this *FileManager) DelMd5Bean(md5key []byte)

注意这个删除并非线程安全,mk5key并发调用仍然存储相同md5值刚存储就被删除的情况 由于正常情况下出现机率极低,此处不做处理

func (*FileManager) GetFdataByName

func (this *FileManager) GetFdataByName(filename string) (fdata *Fdata)

func (*FileManager) GetMd5Bean

func (this *FileManager) GetMd5Bean(md5key []byte) (mb *Md5Bean)

type LockString

type LockString struct {
	// contains filtered or unexported fields
}

func (*LockString) Lock

func (this *LockString) Lock(s string)

func (*LockString) UnLock

func (this *LockString) UnLock(s string)

type Md5Bean

type Md5Bean struct {
	Offset   int64  //文件所在位置
	Size     int32  //文件大小 字节
	FileName string //所在文件名
	QuoteNum int32  //引用数
	Sequence []byte //文件序号
	Compress bool   //是否压缩
}

func Byte2Md5Bean

func Byte2Md5Bean(bs []byte) (md5 Md5Bean)

func DBGetMd5Bean

func DBGetMd5Bean(md5key []byte) (md5 Md5Bean, err error)

func DecoderMd5

func DecoderMd5(data []byte) (md5 Md5Bean)

-------------------------------------------------

func NewMd5Bean

func NewMd5Bean(offset int64, size int32, filename string, sequence []byte, compress bool) (mb *Md5Bean)

func (*Md5Bean) AddQuote

func (this *Md5Bean) AddQuote()

func (*Md5Bean) SubQuote

func (this *Md5Bean) SubQuote()

type ReadBean

type ReadBean struct {
	// contains filtered or unexported fields
}

type Segment

type Segment struct {
	Id        int64  //文件ID号
	Name      string //文件名
	FileType  string //文件类型
	Md5       []byte //文件md5值
	ShardName string
}

func Bytes2Segment

func Bytes2Segment(bs []byte) (s Segment)

func DBGetSegment

func DBGetSegment(key []byte) (s Segment, err error)

func DecoderSegment

func DecoderSegment(data []byte) (segment Segment)

--------------------------------------------------------------------------------------------------------------------

func NewSegment

func NewSegment(name string, filetype string, md5 []byte, shardname string) (s *Segment)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL