storage

package
v0.0.0-...-b17ee77 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

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

Page is a fixed-length area on a Data to store tuples and related Data structures

func NewPage

func NewPage(data *os.File, offset uint64) *Page

NewPage creates and initializes a new page from a specific offset of a Data

func (*Page) Add

func (p *Page) Add(tuple Tuple) (free uint32, err error)

Add adds a tuple to the page returns the remaining free spaces for more tuples

func (*Page) Close

func (p *Page) Close() (err error)

func (*Page) Flush

func (p *Page) Flush() (err error)

func (*Page) Init

func (p *Page) Init() (err error)

func (*Page) ReadAll

func (p *Page) ReadAll() (tuples []Tuple, err error)

ReadAll reads all tuples from a page

func (*Page) Remove

func (p *Page) Remove(tpIdx uint32) (err error)

Remove removes a tuple by providing the pointer index (starting from 0) pointing to the tuple Note that FSM is not updated until we do vacuuming

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

PageHeader is the head of a page

type PagePointer

type PagePointer uint32

PagePointer is a pointer pointing to a location within a page

type Table

type Table struct {
	// Data file
	Data *os.File
	// free space map file
	Fsm *os.File
}

Table is a Data structure to store Data with the same schema which contains multiple pages

func NewTable

func NewTable(data *os.File, fsm *os.File) *Table

func (*Table) Add

func (t *Table) Add(tuple Tuple) (err error)

Add adds a tuple to a table

func (*Table) Close

func (t *Table) Close() (err error)

func (*Table) Delete

func (t *Table) Delete(loc TupleLocation) (err error)

func (*Table) Flush

func (t *Table) Flush() (err error)

func (*Table) Scan

func (t *Table) Scan(iter TableIterator) (err error)

type TableIterator

type TableIterator func(tuple Tuple, loc TupleLocation) (cont bool, err error)

TableIterator is a callback for each tuple in a table

type Tuple

type Tuple []byte

Tuple is a Data tuple

func (*Tuple) Size

func (t *Tuple) Size() uint32

type TupleLocation

type TupleLocation struct {
	Page   int64
	Offset uint32
}

type TuplePointer

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

TuplePointer points to a tuple within a page

func NewTuplePointerFromBytes

func NewTuplePointerFromBytes(data []byte) (pointer TuplePointer, err error)

Jump to

Keyboard shortcuts

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