schema

package
v0.0.0-...-32ccde8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TBL_NAME_INFORMATION_SCHEMA = "information_schema"
	FLD_IDX_PK                  = 0
	FID_NAME_PK                 = "0"
)

Variables

View Source
var ErrInvalidIndexType = errors.New("invalid index type")

Functions

func AppendIndexKey

func AppendIndexKey(b []byte, tbl *Table, idx *Index, record Record) (key []byte, err error)

Types

type FLdSeq

type FLdSeq uint16
const (
	FldSeqMax FLdSeq = math.MaxUint16
)

func (*FLdSeq) DecodeMsg

func (z *FLdSeq) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (FLdSeq) EncodeMsg

func (z FLdSeq) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (FLdSeq) MarshalMsg

func (z FLdSeq) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (FLdSeq) Msgsize

func (z FLdSeq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*FLdSeq) UnmarshalMsg

func (z *FLdSeq) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Field

type Field struct {
	Seq   FLdSeq
	Name  string
	Value interface{}
}

func (*Field) DecodeMsg

func (z *Field) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Field) EncodeMsg

func (z *Field) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Field) MarshalMsg

func (z *Field) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Field) Msgsize

func (z *Field) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Field) UnmarshalMsg

func (z *Field) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type IdxName

type IdxName string
const (
	NameIdxPk IdxName = "0"
)

func (*IdxName) DecodeMsg

func (z *IdxName) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (IdxName) EncodeMsg

func (z IdxName) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (IdxName) MarshalMsg

func (z IdxName) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (IdxName) Msgsize

func (z IdxName) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*IdxName) UnmarshalMsg

func (z *IdxName) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type IdxSeq

type IdxSeq uint16
const (
	SeqIdxPK  IdxSeq = 0
	SeqIdxMax IdxSeq = math.MaxUint16
)

func (*IdxSeq) DecodeMsg

func (z *IdxSeq) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (IdxSeq) EncodeMsg

func (z IdxSeq) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (IdxSeq) MarshalMsg

func (z IdxSeq) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (IdxSeq) Msgsize

func (z IdxSeq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*IdxSeq) UnmarshalMsg

func (z *IdxSeq) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type IdxType

type IdxType uint8
const (
	IdxTypePrimary IdxType = iota
	IdxTypeUnique
	IdxTypeRange
	IdxTypeBitset
)

func (*IdxType) DecodeMsg

func (z *IdxType) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (IdxType) EncodeMsg

func (z IdxType) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (IdxType) MarshalMsg

func (z IdxType) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (IdxType) Msgsize

func (z IdxType) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (IdxType) String

func (i IdxType) String() string

func (*IdxType) UnmarshalMsg

func (z *IdxType) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Index

type Index struct {
	Seq    IdxSeq
	Type   IdxType
	Name   string
	Fields []*Field
}

func (*Index) DecodeMsg

func (z *Index) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Index) EncodeMsg

func (z *Index) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Index) MarshalMsg

func (z *Index) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Index) Msgsize

func (z *Index) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Index) UnmarshalMsg

func (z *Index) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Record

type Record interface {
	Get(fieldName string) *Field

	// EncodeAll appends the binary representation of the record to the byte slice,
	// and returns the updated slice.
	EncodeAll(b []byte) ([]byte, error)

	// DecodeAll decodes the binary representation of the record from the byte slice.
	DecodeAll(b []byte) error

	// EncodeField appends the binary representation of the field to the byte slice,
	// and returns the updated slice.
	EncodeField(b []byte, id FLdSeq) ([]byte, error)

	// DecodeField decodes the binary representation of the field from the byte slice.
	DecodeField(b []byte, id FLdSeq) error
}

type Schema

type Schema struct {
	Tables []*Table
	// contains filtered or unexported fields
}

TODO: 임시 - 동시 접근을 막기 위한 mutex lock 필요

func NewSchema

func NewSchema() *Schema

func (*Schema) AddTable

func (s *Schema) AddTable(tblName string) error

func (*Schema) DecodeMsg

func (z *Schema) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Schema) EncodeMsg

func (z *Schema) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Schema) GetTable

func (s *Schema) GetTable(tblName string) *Table

func (*Schema) Load

func (s *Schema) Load(bt []byte) error

func (*Schema) MarshalMsg

func (z *Schema) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Schema) Msgsize

func (z *Schema) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Schema) Save

func (s *Schema) Save() (bt []byte, err error)

func (*Schema) UnmarshalMsg

func (z *Schema) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Table

type Table struct {
	Seq     TblSeq
	Name    string
	Indexes []*Index
	// contains filtered or unexported fields
}

func (*Table) AddIndex

func (t *Table) AddIndex(idxName string, idxType IdxType) error

func (*Table) DecodeMsg

func (z *Table) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Table) EncodeMsg

func (z *Table) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Table) GetIndex

func (t *Table) GetIndex(idxName string) *Index

func (*Table) MarshalMsg

func (z *Table) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Table) Msgsize

func (z *Table) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Table) UnmarshalMsg

func (z *Table) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type TblName

type TblName string
const (
	NameTblInformationSchema TblName = "information_schema"
)

func (*TblName) DecodeMsg

func (z *TblName) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (TblName) EncodeMsg

func (z TblName) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (TblName) MarshalMsg

func (z TblName) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (TblName) Msgsize

func (z TblName) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TblName) UnmarshalMsg

func (z *TblName) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type TblSeq

type TblSeq uint16
const (
	SeqTblInformationSchema TblSeq = iota
	SeqTblTable             TblSeq = math.MaxUint16
)

func (*TblSeq) DecodeMsg

func (z *TblSeq) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (TblSeq) EncodeMsg

func (z TblSeq) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (TblSeq) MarshalMsg

func (z TblSeq) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (TblSeq) Msgsize

func (z TblSeq) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (TblSeq) String

func (i TblSeq) String() string

func (*TblSeq) UnmarshalMsg

func (z *TblSeq) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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