store

package
v0.0.0-...-4284221 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeedlePaddingSize int64 = 8
)
View Source
const StackMaxSize = 32 * GB

Variables

This section is empty.

Functions

func IdToByets

func IdToByets(n *pb.NeedlePb) []byte

func LevelDbCrc32Key

func LevelDbCrc32Key(n *pb.NeedlePb) (crcBytes []byte)

func NewNeedle

func NewNeedle(needleId int64, stackId uint8, file *multipart.FileHeader) (needle *pb.NeedlePb, err error)

Types

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

type Haystack

type Haystack struct {
	Id uint32

	MaxSize ByteSize
	// contains filtered or unexported fields
}

func NewHaystack

func NewHaystack(id int, maxSize ByteSize, barnDir string) *Haystack

func (*Haystack) FileName

func (h *Haystack) FileName() string

func (*Haystack) ReadFileBytes

func (hs *Haystack) ReadFileBytes(n *pb.NeedlePb) error

*

		-----------------------------
		|-headerCrc32 8 bytes  first 4 byes is crc32Uint 5th byte is pad-length, 6th 7th 8th bytes are reserved
		|-magicHeader 8  bytes
 needle-|
		|-FileBytes + padding bytes 8 * n bytes
		|-magicFooter 8  bytes
		-----------------------------

func (*Haystack) WriteFileHeader

func (hs *Haystack) WriteFileHeader(fh *multipart.FileHeader) (*pb.NeedlePb, error)

func (*Haystack) WriteNeedPb

func (hs *Haystack) WriteNeedPb(n *pb.NeedlePb) error

type Store

type Store struct {
	IpPort       string
	Stacks       []*Haystack
	StackCount   int
	StackMaxSize ByteSize
	DB           *leveldb.DB
	// contains filtered or unexported fields
}

func NewStore

func NewStore(ipPort string, dataDir string, stackCount int) *Store

func (*Store) Close

func (s *Store) Close()

func (*Store) DeleteFile

func (s *Store) DeleteFile(id int)

func (*Store) GetAllFile

func (s *Store) GetAllFile()

func (*Store) GetDataDirPath

func (s *Store) GetDataDirPath() string

func (*Store) GetFile

func (s *Store) GetFile(id []byte) (n *pb.NeedlePb, err error)

func (*Store) GetOneFile

func (s *Store) GetOneFile(id int) []byte

func (*Store) PutFile

func (s *Store) PutFile(file *multipart.FileHeader) (*pb.NeedlePb, error)

func (*Store) ReadRpc

func (s *Store) ReadRpc(in *pb.NeedlePb) error

func (*Store) StatusRpc

func (s *Store) StatusRpc(in *pb.NeedlePb) error

func (*Store) WriteRpc

func (s *Store) WriteRpc(in *pb.NeedlePb) error

Jump to

Keyboard shortcuts

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