Index1024.jl
Documentation for Index1024.jl
Data Types
Index1024.Index — TypeIndexstruct to hold the data associated with a particular Index
Properties
meta::Vector{String}user defined meta-data to save in the index fileio::IOthe file handle of the index used to navigate
Index1024.DataAux — TypeDataAuxType of the leaf data. (data=UInt64, aux=UInt64)
Named elements
data::UInt64user suppliedaux::UInt64user 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::IOdescriptor for writing (so you can use IOBuffer if desired)kvsDict{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)::IndexOpen 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
idxIndex to usesearch_keyUInt64 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
idxIndex to searchsearch_keyuntagged UInt64 key to search fordefaultwhat 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
ksUInt64 keys to write in the terminals (a fixed size per page)kvsthe key / value dictionary containing all of the UInt64 => DataAux pairsterminal_tagthe 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
idxIndex of the tree, needed for iopagefirst node of the given pagemin_key,max_keyrange 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
idxan Index to searchsearch_keyan 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_keyskeys to use in the terminals, in orderkvsDict of the values to use in the terminalsterminal_tagTag the terminals withterminal_tag(which will be eitherleafortopage)terminal_countwrite this many terminals, which might be more than the number of keys