Coder Social home page Coder Social logo

hat-trie-erlang's Introduction

hattrie

Erlang binding (nif) for hat-trie

Build & test

$ make

Implementation

Plain trie

Trie tress are named and can be shared between processes. A rw-lock is used to ensure thread-safe.

Just because trie is right here, the mapping from name to a trie is implemented using a global trie. Meaning each API call will perform a name lookup to find a trie for read or write.

Segment trie

Segment trie is an optimization for prefixing of words instead of characters. e.g. word1 is a prefix of word1/word2/word3, but word is not.

Internally, the keys are split into words (segments), then stored in an AVL tree as a dictionary, each word gets a one-based index assigned by the AVL tree manager. Then the index numbers are varint encoded, concatenated, and finally stored in a plain trie.

Performance

Since I am only interested in segment matches, e.g. word1/word2/..., in comparism to ets, all the segmented prefixes are inserted as ETS key.

Observations so far:

  • Plain trie can be quite bloated in memory
  • Segment trie is much more compact, and takes less RAM than ets -- excluding the AVL dict though. (TODO: count bytes for AVL tree)
  • Both plain and segment trie are outperforming ets in concurrent prefix enumeration insert + lookup tests.

See or run hattrie_ets_compare_tests for more information.

hat-trie-erlang's People

Contributors

zmstone avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

zabrane

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.