meepodb

package
v0.0.0-...-611133e Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2013 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S_IRALL uint32 = S_IRUSR | S_IRGRP | S_IROTH
	S_IWALL uint32 = S_IWUSR | S_IWGRP | S_IWOTH
	S_IXALL uint32 = S_IXUSR | S_IXGRP | S_IXOTH
	S_IRWXA uint32 = S_IRALL | S_IWALL | S_IXALL

	MAX_RECORDS  uint64 = 1 << 12
	BLX_BUF_SIZE int64  = int64(1) << 20 * 16

	MAX_CONNS      int = 10000
	MAX_TABLES     int = 10000
	REPLICA_FACTOR int = 3
)

* DO NOT MODIFY THE VALUES BELOW IF YOU HAVE NO IDEA WHAT THEY ARE.

View Source
const (
	/*
	   | CMD_CODE       : 7  bits               |  ========
	   | TABLE_NAME_LEN : 7  bits               |    Head
	   | KEY_LEN        : 20 bits               |   64 bits
	   | VALUE_LEN      : 30 bits               |  ========
	   | TABLE_NAME     : $TABLE_NAME_LEN bytes |
	   | KEY            : $KEY_LEN        bytes |
	   | VALUE          : $VALUE_LEN      bytes |
	*/
	CMD_CODE_BITS   = 7
	TABLE_NAME_BITS = 7
	KEY_BITS        = 20
	VALUE_BITS      = 30

	MAX_TABLE_NAME_LEN = uint64(1)<<TABLE_NAME_BITS - 1
	MAX_KEY_LEN        = uint64(1)<<KEY_BITS - 1
	MAX_VALUE_LEN      = uint64(1)<<VALUE_BITS - 1

	GET_CODE  byte = 0x01
	SET_CODE  byte = 0x02
	DEL_CODE  byte = 0x03
	SIZE_CODE byte = 0x0D
	KEYS_CODE byte = 0x0E
	DROP_CODE byte = 0x0F
	MGET_CODE byte = 0x11
	MSET_CODE byte = 0x12
	MDEL_CODE byte = 0x13
	QUIT_CODE byte = 0x21 /* Client quits */
	WORK_CODE byte = 0x22 /* Server ready */
	RALC_CODE byte = 0x23 /* Reallocate   */
	DSTR_CODE byte = 0x24 /* Distribute   */
	EXPL_CODE byte = 0x25 /* Expel        */
	OK_CODE   byte = 0x30
	ERR_CODE  byte = 0x3F
)
View Source
const DB_DIR string = "/home/wiza/mpdb"

Variables

View Source
var CLUSTER_TAG uint64
View Source
var REPLICA bool = false
View Source
var SERVERS = [...]string{
	"192.168.3.139:6631",
}

Functions

func BlocksToExtent2

func BlocksToExtent2(path string, records RecordSlice) bool

* THE FUNCTIONS BELOW ARE OF NO USE ANYMORE.

func BytesToUint64

func BytesToUint64(bytes []byte) uint64

func CompactExtent2

func CompactExtent2(path string) bool

func CompactMemExtent

func CompactMemExtent(ext *Extent)

func DecodeHead

func DecodeHead(head []byte) (byte, uint64, uint64, uint64)

func EncodeDrop

func EncodeDrop(table []byte) []byte

func EncodeGet

func EncodeGet(table, key []byte) []byte

func EncodeHead

func EncodeHead(code byte, tlen, klen, vlen uint64) []byte

func EncodeSet

func EncodeSet(table, key, value []byte) []byte

func EncodeSym

func EncodeSym(code byte) []byte

func GpollAdd

func GpollAdd(state *GpollState, ev *EpollEvent) bool

func GpollDel

func GpollDel(state *GpollState, ev *EpollEvent) bool

func GpollMod

func GpollMod(state *GpollState, ev *EpollEvent) bool

func GpollWait

func GpollWait(state *GpollState) int

func HashTableKey

func HashTableKey(table, key []byte) uint64

func MergeExtents2

func MergeExtents2(path string, ext0, ext1 *Extent) bool

func MoreCmd

func MoreCmd(code byte) bool

Check whether a command is 'MXXX'.

func Reallocate

func Reallocate(addr string)

func SetKeepAlive

func SetKeepAlive(sockfd, v int) error

func SetLinger

func SetLinger(sockfd int, sec int) error

func SetNoDelay

func SetNoDelay(sockfd int) error

func StartServer

func StartServer(addr string)

func Uint64ToBytes

func Uint64ToBytes(x uint64) []byte

func WriteBlocks

func WriteBlocks(blx *Blocks) bool

Types

type Blocks

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

func LoadBlocks

func LoadBlocks(path string) (*Blocks, bool)

func NewBlocks

func NewBlocks(path string) (*Blocks, bool)

func OpenBlocks

func OpenBlocks(path string) (*Blocks, int64)

func (*Blocks) Close

func (blx *Blocks) Close() bool

func (*Blocks) Get

func (blx *Blocks) Get(key []byte) []byte

func (*Blocks) Records

func (blx *Blocks) Records() RecordSlice

func (*Blocks) Set

func (blx *Blocks) Set(key, value []byte) bool

type COLA

type COLA struct {
	MetaFd int
	Bitmap uint64

	Path string
	// contains filtered or unexported fields
}

func NewCOLA

func NewCOLA(path string) (*COLA, bool)

func OpenCOLA

func OpenCOLA(path string) (*COLA, bool)

func (*COLA) Close

func (cola *COLA) Close()

func (*COLA) Get

func (cola *COLA) Get(key []byte) []byte

func (*COLA) Keys

func (cola *COLA) Keys() []string

func (*COLA) PushDown

func (cola *COLA) PushDown() bool

func (*COLA) Set

func (cola *COLA) Set(key, value []byte) bool

func (*COLA) Size

func (cola *COLA) Size() uint64

type Extent

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

func BlocksToMemExtent

func BlocksToMemExtent(records RecordSlice) *Extent

func MergeMemExtents

func MergeMemExtents(ext0, ext1 *Extent) *Extent

func OpenExtent

func OpenExtent(path string) (*Extent, bool)

func OpenMemExtent

func OpenMemExtent(buffer []byte) *Extent

func (*Extent) Count

func (extent *Extent) Count() uint64

func (*Extent) Find

func (extent *Extent) Find(key []byte) int64

Binary search

func (*Extent) Free

func (extent *Extent) Free() bool

func (*Extent) Index

func (extent *Extent) Index(i uint64) (uint64, uint64)

func (*Extent) Key

func (extent *Extent) Key(i uint64) []byte

func (*Extent) Record

func (extent *Extent) Record(i uint64) ([]byte, []byte)

type GpollLoop

type GpollLoop struct {
	Lfd   int32
	State *GpollState
	Ready int
}

func GpollListen

func GpollListen(addr string, maxConns int) (*GpollLoop, bool)

func (*GpollLoop) AddEvent

func (loop *GpollLoop) AddEvent()

func (*GpollLoop) DelEvent

func (loop *GpollLoop) DelEvent(ev *EpollEvent) bool

func (*GpollLoop) Wait

func (loop *GpollLoop) Wait()

type GpollState

type GpollState struct {
	Epfd   int
	Events []EpollEvent
}

func GpollCreate

func GpollCreate(maxEvents int) (*GpollState, bool)

type Record

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

type RecordSlice

type RecordSlice []Record

func (RecordSlice) Len

func (recs RecordSlice) Len() int

func (RecordSlice) Less

func (recs RecordSlice) Less(i, j int) bool

func (RecordSlice) Swap

func (recs RecordSlice) Swap(i, j int)

type Storage

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

func NewStorage

func NewStorage() *Storage

func (*Storage) COLA

func (strg *Storage) COLA(name []byte) *COLA

func (*Storage) Drop

func (strg *Storage) Drop(table []byte) bool

func (*Storage) ExistentCOLA

func (strg *Storage) ExistentCOLA(name []byte) *COLA

func (*Storage) Get

func (strg *Storage) Get(table, key []byte) []byte

func (*Storage) Keys

func (strg *Storage) Keys(table []byte) []string

func (*Storage) OpenAll

func (strg *Storage) OpenAll() bool

func (*Storage) Set

func (strg *Storage) Set(table, key, value []byte) bool

func (*Storage) Size

func (strg *Storage) Size(table []byte) uint64

type WriteBuf

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

func NewWriteBuf

func NewWriteBuf(size int) *WriteBuf

func (*WriteBuf) ReadAll

func (wbuf *WriteBuf) ReadAll() []byte

func (*WriteBuf) Write

func (wbuf *WriteBuf) Write(data []byte)

Jump to

Keyboard shortcuts

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