storage

package
v0.0.0-...-27f2751 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TupleNumber = 32
)

Variables

View Source
var TupleData_Type_name = map[int32]string{
	0: "INT",
	1: "STRING",
}
View Source
var TupleData_Type_value = map[string]int32{
	"INT":    0,
	"STRING": 1,
}

Functions

func NewPgid

func NewPgid(tableName string) uint64

func SaveCatalog

func SaveCatalog(dirPath string, c *Catalog) (err error)

SaveCatalog persists the system catalog as `catalog.db`. `catalog.db` has a simple json format like key/value.

func SerializePage

func SerializePage(p *Page) ([4096]byte, error)

func SerializeTuple

func SerializeTuple(t *Tuple) ([128]byte, error)

Types

type Catalog

type Catalog struct {
	Schemes []*meta.Scheme
	// contains filtered or unexported fields
}

func LoadCatalog

func LoadCatalog(catalogPath string) (*Catalog, error)

func NewEmtpyCatalog

func NewEmtpyCatalog() *Catalog

func (*Catalog) Add

func (c *Catalog) Add(scheme *meta.Scheme) error

Add is to add the new scheme into a memory. Be careful not to persist the disk.

func (*Catalog) FetchScheme

func (c *Catalog) FetchScheme(tblName string) *meta.Scheme

func (*Catalog) HasScheme

func (c *Catalog) HasScheme(tblName string) bool

type Page

type Page struct {
	Tuples [TupleNumber]Tuple
}

Page is fixed-sized(4KB) byte.

func DeserializePage

func DeserializePage(b [4096]byte) (*Page, error)

func NewPage

func NewPage() *Page

type Storage

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

Storage is the interface of any manipulation of read/write.

func NewStorage

func NewStorage(home string) *Storage

func (*Storage) CreateIndex

func (s *Storage) CreateIndex(indexName string) (*meta.BTree, error)

func (*Storage) InsertIndex

func (s *Storage) InsertIndex(indexName string, item meta.Item) error

func (*Storage) InsertTuple

func (s *Storage) InsertTuple(tablename string, t *Tuple)

func (*Storage) ReadIndex

func (s *Storage) ReadIndex(indexName string) (*meta.BTree, error)

func (*Storage) ReadTuple

func (s *Storage) ReadTuple(tableName string, tid uint64) (*Tuple, error)

func (*Storage) Terminate

func (s *Storage) Terminate() error

type Transaction

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

func (*Transaction) Txid

func (t *Transaction) Txid() uint64

type TransactionManager

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

func NewTransactionManager

func NewTransactionManager() *TransactionManager

func (*TransactionManager) Abort

func (t *TransactionManager) Abort(tran *Transaction)

func (*TransactionManager) BeginTransaction

func (t *TransactionManager) BeginTransaction() *Transaction

func (*TransactionManager) Commit

func (t *TransactionManager) Commit(tran *Transaction)

type TransactionState

type TransactionState int
const (
	Commited TransactionState = iota + 1
	InProgress
	Abort
)

type Tuple

type Tuple struct {
	MinTxId              uint64       `protobuf:"varint,1,opt,name=minTxId,proto3" json:"minTxId,omitempty"`
	MaxTxId              uint64       `protobuf:"varint,2,opt,name=maxTxId,proto3" json:"maxTxId,omitempty"`
	Data                 []*TupleData `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

func DeserializeTuple

func DeserializeTuple(b [128]byte) (*Tuple, error)

func NewTuple

func NewTuple(minTxId uint64, values []interface{}) *Tuple

func (*Tuple) CanSee

func (m *Tuple) CanSee(tran *Transaction) bool

func (*Tuple) Descriptor

func (*Tuple) Descriptor() ([]byte, []int)

func (*Tuple) Equal

func (m *Tuple) Equal(order int, s string, n int) bool

func (*Tuple) GetData

func (m *Tuple) GetData() []*TupleData

func (*Tuple) GetMaxTxId

func (m *Tuple) GetMaxTxId() uint64

func (*Tuple) GetMinTxId

func (m *Tuple) GetMinTxId() uint64

func (*Tuple) IsUnused

func (m *Tuple) IsUnused() bool

func (*Tuple) Less

func (m *Tuple) Less(than meta.Item) bool

func (*Tuple) ProtoMessage

func (*Tuple) ProtoMessage()

func (*Tuple) Reset

func (m *Tuple) Reset()

func (*Tuple) String

func (m *Tuple) String() string

func (*Tuple) XXX_DiscardUnknown

func (m *Tuple) XXX_DiscardUnknown()

func (*Tuple) XXX_Marshal

func (m *Tuple) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Tuple) XXX_Merge

func (m *Tuple) XXX_Merge(src proto.Message)

func (*Tuple) XXX_Size

func (m *Tuple) XXX_Size() int

func (*Tuple) XXX_Unmarshal

func (m *Tuple) XXX_Unmarshal(b []byte) error

type TupleData

type TupleData struct {
	Type                 TupleData_Type `protobuf:"varint,3,opt,name=type,proto3,enum=storage.TupleData_Type" json:"type,omitempty"`
	Number               int32          `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty"`
	String_              string         `protobuf:"bytes,5,opt,name=string,proto3" json:"string,omitempty"`
	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
	XXX_unrecognized     []byte         `json:"-"`
	XXX_sizecache        int32          `json:"-"`
}

func (*TupleData) Descriptor

func (*TupleData) Descriptor() ([]byte, []int)

func (*TupleData) GetNumber

func (m *TupleData) GetNumber() int32

func (*TupleData) GetString_

func (m *TupleData) GetString_() string

func (*TupleData) GetType

func (m *TupleData) GetType() TupleData_Type

func (*TupleData) ProtoMessage

func (*TupleData) ProtoMessage()

func (*TupleData) Reset

func (m *TupleData) Reset()

func (*TupleData) String

func (m *TupleData) String() string

func (*TupleData) XXX_DiscardUnknown

func (m *TupleData) XXX_DiscardUnknown()

func (*TupleData) XXX_Marshal

func (m *TupleData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TupleData) XXX_Merge

func (m *TupleData) XXX_Merge(src proto.Message)

func (*TupleData) XXX_Size

func (m *TupleData) XXX_Size() int

func (*TupleData) XXX_Unmarshal

func (m *TupleData) XXX_Unmarshal(b []byte) error

type TupleData_Type

type TupleData_Type int32
const (
	TupleData_INT    TupleData_Type = 0
	TupleData_STRING TupleData_Type = 1
)

func (TupleData_Type) EnumDescriptor

func (TupleData_Type) EnumDescriptor() ([]byte, []int)

func (TupleData_Type) String

func (x TupleData_Type) String() string

Jump to

Keyboard shortcuts

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