Documentation
¶
Index ¶
- func NewDiskNodeService(file *os.File) *diskNodeService
- type BlockService
- func (bs *BlockService) ConvertBlockToDiskNode(block *DiskBlock) *DiskNode
- func (bs *BlockService) ConvertDiskNodeToBlock(node *DiskNode) *DiskBlock
- func (bs *BlockService) GetBlockFromBuffer(blockBuffer []byte) *DiskBlock
- func (bs *BlockService) GetBufferFromBlock(block *DiskBlock) []byte
- func (bs *BlockService) GetLatestBlockID() (int64, error)
- func (bs *BlockService) GetMaxLeafSize() int
- func (bs *BlockService) GetNodeAtBlockID(blockID uint64) (*DiskNode, error)
- func (bs *BlockService) GetRootBlock() (*DiskBlock, error)
- func (bs *BlockService) SaveNewNodeToDisk(n *DiskNode) error
- func (bs *BlockService) UpdateNodeToDisk(n *DiskNode) error
- func (bs *BlockService) UpdateRootNode(n *DiskNode) error
- func (bs *BlockService) WriteBlockToDisk(block *DiskBlock) error
- type DiskBlock
- type DiskNode
- func (n *DiskNode) AddElement(element *Pairs) int
- func (n *DiskNode) AddPoppedUpElementIntoCurrentNodeAndUpdateWithNewChildren(element *Pairs, leftNode *DiskNode, rightNode *DiskNode)
- func (n *DiskNode) GetChildAtIndex(index int) (*DiskNode, error)
- func (n *DiskNode) GetChildNodes() ([]*DiskNode, error)
- func (n *DiskNode) GetChildOrSibling() (node, error)
- func (n *DiskNode) GetElementAtIndex(index int) *Pairs
- func (n *DiskNode) GetElements() []*Pairs
- func (n *DiskNode) GetValue(key string) (string, time.Time, error)
- func (n *DiskNode) HasOverFlown() bool
- func (n *DiskNode) InsertPair(value *Pairs, bt types.Tree) error
- func (n *DiskNode) IsLeaf() bool
- func (n *DiskNode) PrintTree(level int)
- func (n *DiskNode) Size() int
- func (n *DiskNode) SplitLeafNode() (*Pairs, *DiskNode, *DiskNode, error)
- func (n *DiskNode) SplitNonLeafNode() (*Pairs, *DiskNode, *DiskNode, error)
- type Pairs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDiskNodeService ¶
Types ¶
type BlockService ¶
type BlockService struct { BlockSize int // TODO be sure this can correspond to actual block size // contains filtered or unexported fields }
func NewBlockService ¶
func NewBlockService(file *os.File) *BlockService
func (*BlockService) ConvertBlockToDiskNode ¶
func (bs *BlockService) ConvertBlockToDiskNode(block *DiskBlock) *DiskNode
func (*BlockService) ConvertDiskNodeToBlock ¶
func (bs *BlockService) ConvertDiskNodeToBlock(node *DiskNode) *DiskBlock
func (*BlockService) GetBlockFromBuffer ¶
func (bs *BlockService) GetBlockFromBuffer(blockBuffer []byte) *DiskBlock
func (*BlockService) GetBufferFromBlock ¶
func (bs *BlockService) GetBufferFromBlock(block *DiskBlock) []byte
func (*BlockService) GetLatestBlockID ¶
func (bs *BlockService) GetLatestBlockID() (int64, error)
func (*BlockService) GetMaxLeafSize ¶
func (bs *BlockService) GetMaxLeafSize() int
* @Todo: Implement a function to : 1. Dynamicaly calculate blockSize 2. Then based on the blocksize, calculate the maxLeafSize
func (*BlockService) GetNodeAtBlockID ¶
func (bs *BlockService) GetNodeAtBlockID(blockID uint64) (*DiskNode, error)
func (*BlockService) GetRootBlock ¶
func (bs *BlockService) GetRootBlock() (*DiskBlock, error)
@Todo:Store current root block data somewhere else
func (*BlockService) SaveNewNodeToDisk ¶
func (bs *BlockService) SaveNewNodeToDisk(n *DiskNode) error
NewBlockFromNode - Save a new node to disk block
func (*BlockService) UpdateNodeToDisk ¶
func (bs *BlockService) UpdateNodeToDisk(n *DiskNode) error
func (*BlockService) UpdateRootNode ¶
func (bs *BlockService) UpdateRootNode(n *DiskNode) error
func (*BlockService) WriteBlockToDisk ¶
func (bs *BlockService) WriteBlockToDisk(block *DiskBlock) error
type DiskBlock ¶
type DiskBlock struct { Id uint64 // 4096 - 8 = 4088 CurrentLeafSize uint64 // 4088 - 8 = 4080 ChildrenBlockIds []uint64 // 352 - (8 * 30) = 112 DataSet []*Pairs // 4072 - (124 * 30) = 352 // contains filtered or unexported fields }
DiskBlock -- Make sure that it is accomodated in blockSize = 4096
func (*DiskBlock) SetChildren ¶
type DiskNode ¶
type DiskNode struct { Keys []*Pairs ChildrenBlockIDs []uint64 BlockID uint64 BlockService *BlockService }
DiskNode - In memory node implementation
func NewLeafNode ¶
func NewLeafNode(elements []*Pairs, bs *BlockService) (*DiskNode, error)
NewLeafNode - Create a new leaf node without children
func NewNodeWithChildren ¶
func NewNodeWithChildren(elements []*Pairs, childrenBlockIDs []uint64, bs *BlockService) (*DiskNode, error)
NewNodeWithChildren - Create a non leaf node with children
func (*DiskNode) AddElement ¶
* * Do a linear search and insert the element
func (*DiskNode) AddPoppedUpElementIntoCurrentNodeAndUpdateWithNewChildren ¶
func (n *DiskNode) AddPoppedUpElementIntoCurrentNodeAndUpdateWithNewChildren(element *Pairs, leftNode *DiskNode, rightNode *DiskNode)
AddPoppedUpElementIntoCurrentNodeAndUpdateWithNewChildren - Insert element received as a reaction from insert operation at child nodes
func (*DiskNode) GetChildNodes ¶
func (*DiskNode) GetChildOrSibling ¶
func (*DiskNode) GetElementAtIndex ¶
func (*DiskNode) GetElements ¶
func (*DiskNode) HasOverFlown ¶
func (*DiskNode) InsertPair ¶
Insert - Insert value into Node
func (*DiskNode) Size ¶
argh Size always returns the size of the full data set, not the current node, because I'm a lazy mf
func (*DiskNode) SplitLeafNode ¶
SplitLeafNode - Split leaf node