Documentation ¶
Overview ¶
Package mph is a Go implementation of the compress, hash and displace (CHD) minimal perfect hash algorithm.
See http://cmph.sourceforge.net/papers/esa09.pdf for details.
To create and serialize a hash table:
b := mph.Builder() for k, v := range data { b.Add(k, v) } h, _ := b.Build() w, _ := os.Create("data.idx") b, _ := h.Write(w)
To read from the hash table:
r, _ := os.Open("data.idx") h, _ := h.Read(r) v := h.Get([]byte("some key")) if v == nil { // Key not found }
MMAP is also indirectly supported, by deserializing from a byte slice and slicing the keys and values.
See https://github.com/alecthomas/mph for source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CHD ¶
type CHD struct {
// contains filtered or unexported fields
}
CHD hash table lookup.
type CHDBuilder ¶
type CHDBuilder struct {
// contains filtered or unexported fields
}
Build a new CDH MPH.
func (*CHDBuilder) Add ¶
func (b *CHDBuilder) Add(key []byte, value []byte)
Add a key and value to the hash table.
func (*CHDBuilder) Build ¶
func (b *CHDBuilder) Build() (*CHD, error)
Click to show internal directories.
Click to hide internal directories.