node

package
v0.0.0-...-bbea46d Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PageSize = 4096
	MaxPages = 1024
)

Variables

View Source
var (
	CommonHeaderSize       = leaf.CommonHeader.Size()
	InternalNodeHeaderSize = CommonHeaderSize + internalNode.Header.Size()
	InternalNodeSize       = internalNode.Size()
	InternalNodeCellSize   = internalNode.ICells[0].Size()
	InternalNodeMaxCells   = uint32(len(internalNode.ICells))

	LeafNodeHeaderSize = CommonHeaderSize + leaf.Header.Size()
	LeafNodeSize       = leaf.Size()
	LeafNodeCellSize   = leaf.Cells[0].Size()
	LeafNodeMaxCells   = uint32(len(leaf.Cells))

	RightSplitCount = (LeafNodeMaxCells + 1) / 2
	LeftSplitCount  = LeafNodeMaxCells + 1 - RightSplitCount
)
View Source
var (
	RowSize = (&Row{}).Size()
)

Functions

func PrintRow

func PrintRow(row *Row)

Id uint32 Sex byte Age uint8 Username [32]byte Email [128]byte Phone [64]byte

func WriteRow

func WriteRow(w io.Writer, row *Row) (int, error)

Types

type Cell

type Cell struct {
	Key   uint32
	Value [230]byte
}

func (*Cell) Marshal

func (d *Cell) Marshal(buf []byte) ([]byte, error)

func (*Cell) Size

func (d *Cell) Size() (s uint64)

func (*Cell) Unmarshal

func (d *Cell) Unmarshal(buf []byte) (uint64, error)
type Header struct {
	IsInternal bool
	IsRoot     bool
	Parent     uint32
}

func (*Header) Marshal

func (d *Header) Marshal(buf []byte) ([]byte, error)

func (*Header) Size

func (d *Header) Size() (s uint64)

func (*Header) Unmarshal

func (d *Header) Unmarshal(buf []byte) (uint64, error)

type ICell

type ICell struct {
	Key   uint32
	Child uint32
}

func (*ICell) Marshal

func (d *ICell) Marshal(buf []byte) ([]byte, error)

func (*ICell) Size

func (d *ICell) Size() (s uint64)

func (*ICell) Unmarshal

func (d *ICell) Unmarshal(buf []byte) (uint64, error)

type InternalNode

type InternalNode struct {
	CommonHeader Header
	Header       InternalNodeHeader
	ICells       [510]ICell
}

func (*InternalNode) Child

func (d *InternalNode) Child(childIdx uint32) (ptr *uint32)

func (*InternalNode) FindChildByKey

func (d *InternalNode) FindChildByKey(key uint32) uint32

FindChildByKey returns the index of the child which should contain

the given key.

func (*InternalNode) Marshal

func (d *InternalNode) Marshal(buf []byte) ([]byte, error)

func (*InternalNode) Size

func (d *InternalNode) Size() (s uint64)

func (*InternalNode) Unmarshal

func (d *InternalNode) Unmarshal(buf []byte) (uint64, error)

type InternalNodeHeader

type InternalNodeHeader struct {
	KeysNum    uint32
	RightChild uint32
}

func (*InternalNodeHeader) Marshal

func (d *InternalNodeHeader) Marshal(buf []byte) ([]byte, error)

func (*InternalNodeHeader) Size

func (d *InternalNodeHeader) Size() (s uint64)

func (*InternalNodeHeader) Unmarshal

func (d *InternalNodeHeader) Unmarshal(buf []byte) (uint64, error)

type LeafNode

type LeafNode struct {
	CommonHeader Header
	Header       LeafNodeHeader
	Cells        [17]Cell
}

func (*LeafNode) Marshal

func (d *LeafNode) Marshal(buf []byte) ([]byte, error)

func (*LeafNode) Size

func (d *LeafNode) Size() (s uint64)

func (*LeafNode) Unmarshal

func (d *LeafNode) Unmarshal(buf []byte) (uint64, error)

type LeafNodeHeader

type LeafNodeHeader struct {
	Cells    uint32
	NextLeaf uint32
}

func (*LeafNodeHeader) Marshal

func (d *LeafNodeHeader) Marshal(buf []byte) ([]byte, error)

func (*LeafNodeHeader) Size

func (d *LeafNodeHeader) Size() (s uint64)

func (*LeafNodeHeader) Unmarshal

func (d *LeafNodeHeader) Unmarshal(buf []byte) (uint64, error)

type Row

type Row struct {
	Id       uint32
	Sex      byte
	Age      uint8
	Username [32]byte
	Email    [128]byte
	Phone    [64]byte
}

func (*Row) Marshal

func (d *Row) Marshal(buf []byte) ([]byte, error)

func (*Row) Size

func (d *Row) Size() (s uint64)

func (*Row) Unmarshal

func (d *Row) Unmarshal(buf []byte) (uint64, error)

Jump to

Keyboard shortcuts

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