Index1024.jl
Documentation for Index1024.jl
Data Types
Index1024.Index
— TypeIndex
struct to hold the data associated with a particular Index
Properties
meta::Vector{String}
user defined meta-data to save in the index fileio::IO
the file handle of the index used to navigate
Index1024.DataAux
— TypeDataAux
Type of the leaf data. (data=UInt64, aux=UInt64)
Named elements
data::UInt64
user suppliedaux::UInt64
user supplied
Creating an Index
Index1024.build_index_file
— Functionbuild_index_file(io::IO, kvs; meta=String[])
build_index_file(filename::AbstractString, kvs; meta=String[])
Create the on-disk representation of the index of the kvs Dict. The Leafs are sorted by the key values of the kvs.
Arguments
io::IO
descriptor for writing (so you can use IOBuffer if desired)kvs
Dict{UInt64, T}() where T is the type of the leaf, by default DataAux - might expand in futuremeta::Vector{AbstractString}
vector of strings to add meta data
Using an index
Index1024.open_index
— Functionopen_index(filename::AbstractString)::Index
open_index(io::IO)::Index
Open an Index struct from file on which one can perform searches.
Index1024.search
— Functionsearch(idx::Index, search_key::UInt64)::Union{UInt64, Nothing}
Search the given index for a given search_key
returning a Tuple of the previously stored value If the search_key
is not found, return nothing
Arguments
idx
Index to usesearch_key
UInt64 key to search for
Base.get
— Functionget(idx::Index, search_key, default)
Search the given index for a given search_key
returning a Tuple of the previously stored value or the default
Arguments
idx
Index to searchsearch_key
untagged UInt64 key to search fordefault
what to return if the key is not found
Index1024.node_range
— Functionnode_range(idx::Index, min_key, max_key)
Gather all the Leafs in a given idx
where min_key <= key <= max_key
CURRENTLY BROKEN
Index1024.todot
— Functiontodot(idx::Index)
Output the tree in GraphViz dot format. Used for debugging and only includes the root node.
Extending the library
Index1024.build_page
— Functionbuild_page(ks, kvs, terminal_tag)
Using the given keys ks
use the key/values in ks
to generate the tree for this page. The page is the same structure whether the terminals are leafs or "pointers"
Arguments
ks
UInt64 keys to write in the terminals (a fixed size per page)kvs
the key / value dictionary containing all of the UInt64 => DataAux pairsterminal_tag
the UInt8 Tag applied to the keys of the terminals
Index1024.page_nodes
— Functionpage_nodes(idx, page, min_key, max_key)
Walk the entire page, a return the leafs and topage Nodes in separate lists
Arguments
idx
Index of the tree, needed for iopage
first node of the given pagemin_key
,max_key
range of keys for the Leafs wanted
Index1024.get_leaf
— Functionget_leaf(idx::Index, search_key)
Search the tree for a particular leaf node and return it (or nothing)
Arguments
idx
an Index to searchsearch_key
an untagged UInt64 key to search for
Index1024.write_pages
— Functionwrite_pages(io, sorted_keys, kvs, terminal_tag; terminal_count=16)
Write the current depth of the tree to disk, depth first. Returns the keys at the root of each page in order and generates the kvs to use as DataAux values
Arguments
io
- write into this IOsorted_keys
keys to use in the terminals, in orderkvs
Dict of the values to use in the terminalsterminal_tag
Tag the terminals withterminal_tag
(which will be eitherleaf
ortopage
)terminal_count
write this many terminals, which might be more than the number of keys