Documentation ¶
Overview ¶
Package btree pager BSD 3-Clause License
Copyright (c) 2024, Alex Gaetano Padula All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Package btree pager BSD 3-Clause License
Copyright (c) 2024, Alex Gaetano Padula All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
- Constants
- type BTree
- func (b *BTree) Close() error
- func (b *BTree) Delete(k []byte) error
- func (b *BTree) Get(k []byte) (*Key, error)
- func (b *BTree) GreaterThan(k []byte) ([]*Key, error)
- func (b *BTree) GreaterThanEq(k []byte) ([]*Key, error)
- func (b *BTree) InOrderTraversal() ([]*Key, error)
- func (b *BTree) LessThan(k []byte) ([]*Key, error)
- func (b *BTree) LessThanEq(k []byte) ([]*Key, error)
- func (b *BTree) NGet(k []byte) ([]*Key, error)
- func (b *BTree) NRange(start, end []byte) ([]*Key, error)
- func (b *BTree) PrintTree() error
- func (b *BTree) Put(key, value []byte) error
- func (b *BTree) Range(start, end []byte) ([]interface{}, error)
- func (b *BTree) Remove(key, value []byte) error
- type Key
- type Node
- type Pager
- func (p *Pager) Close() error
- func (p *Pager) Count() int64
- func (p *Pager) DeletePage(pageID int64) error
- func (p *Pager) GetDeletedPages() []int64
- func (p *Pager) GetPage(pageID int64) ([]byte, error)
- func (p *Pager) Write(data []byte) (int64, error)
- func (p *Pager) WriteTo(pageID int64, data []byte) error
Constants ¶
const HEADER_SIZE = 16 // next (overflowed)
const PAGE_SIZE = 1024 // Page size
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BTree ¶
BTree is the main BTree struct ** not thread safe
func (*BTree) GreaterThan ¶ added in v1.1.0
GreaterThan returns all keys greater than k
func (*BTree) GreaterThanEq ¶ added in v1.2.2
GreaterThanEq returns all keys greater than or equal to k
func (*BTree) InOrderTraversal ¶ added in v1.1.0
InOrderTraversal returns all keys in the BTree in order
func (*BTree) LessThanEq ¶ added in v1.2.2
LessThanEq returns all keys less than or equal to k
func (*BTree) Put ¶
Put inserts a key into the BTree A key can have multiple values Put inserts a key value pair into the BTree
type Node ¶
type Node struct { Page int64 // The page number of the node Keys []*Key // The keys in node Children []int64 // The children of the node Leaf bool // If the node is a leaf node }
Node is the node struct for the BTree
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager manages pages in a file
func OpenPager ¶
func OpenPager(filename string, flag int, perm os.FileMode, syncInterval time.Duration) (*Pager, error)
OpenPager opens a file for page management
func (*Pager) GetDeletedPages ¶ added in v1.2.1
GetDeletedPages returns the list of deleted pages
func (*Pager) GetPage ¶
GetPage gets a page and returns the data Will gather all the pages that are linked together