GithubHelp home page GithubHelp logo

redislabs / triemap Goto Github PK

View Code? Open in Web Editor NEW
21.0 10.0 9.0 47 KB

C implementation of a compressed trie lookup map

License: BSD 2-Clause "Simplified" License

Makefile 2.23% C 90.96% C++ 6.81%

triemap's Introduction

triemap

C implementation of a compact trie lookup map

Features

  • High memory efficiency, fast lookups and insertions
  • Deletions with node rejoining
  • Prefix lookups with an iterator API
  • Random key extraction
  • No external dependencies, just one C and one H file

Basic Example

 TrieMap *tm = NewTrieMap();

 char buf[32];

 for (int i = 0; i < 100; i++) {
    sprintf(buf, "key%d", i);
    TrieMap_Add(tm, buf, strlen(buf), NULL, NULL);
 }
 
  TrieMapIterator *it = TrieMap_Iterate(tm, "key1", 4);
  
  char *str = NULL;
  tm_len_t len = 0;
  void *ptr = NULL;

  /* Prefix Iteration */
  while (TrieMapIterator_Next(it, &str, &len, &ptr)) {
    printf("Found key %.*s\n", (int)len, str);
  }
  
  TrieMapIterator_Free(&it);
  TrieMap_Free(tm, NULL);
  

triemap's People

Contributors

dvirsky avatar swilly22 avatar

Stargazers

Ivan Chen avatar Roman Gershman avatar Anoop P Oommen avatar Jun Xie avatar Paul Chambers avatar Ritvij Srivastava avatar Shikhar Vaish avatar Madhav Baveja avatar Dhruv avatar  avatar kent avatar Alexander A. avatar Victor Stewart avatar Rain avatar sonny avatar  avatar Simon Klee avatar Adam Zell avatar Fatih Kaya avatar  avatar Serapheim Dimitropoulos avatar

Watchers

James Cloos avatar  avatar Yiftach avatar Dmitry Atamanov avatar Matan Kehat avatar Itamar Haber avatar Uri Shachar avatar Rain avatar Elad Ash avatar  avatar

triemap's Issues

Error when trying to compiling RediSearch on Alpine

Hi,

I'm trying to install RediSearch in Alpine Linux and this error occurs in triemap compilation:

image

Console log:

make[1]: Entering directory '/usr/src/RediSearch/RediSearch/src/trie'
gcc -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC -D_GNU_SOURCE -std=gnu99 -I"/usr/src/RediSearch/RediSearch/src" -DREDIS_MODULE_TARGET -O3 -g -I../   -c -o levenshtein.o levenshtein.c
gcc -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC -D_GNU_SOURCE -std=gnu99 -I"/usr/src/RediSearch/RediSearch/src" -DREDIS_MODULE_TARGET -O3 -g -I../   -c -o rune_util.o rune_util.c
gcc -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC -D_GNU_SOURCE -std=gnu99 -I"/usr/src/RediSearch/RediSearch/src" -DREDIS_MODULE_TARGET -O3 -g -I../   -c -o sparse_vector.o sparse_vector.c
gcc -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC -D_GNU_SOURCE -std=gnu99 -I"/usr/src/RediSearch/RediSearch/src" -DREDIS_MODULE_TARGET -O3 -g -I../   -c -o trie.o trie.c
gcc -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC -D_GNU_SOURCE -std=gnu99 -I"/usr/src/RediSearch/RediSearch/src" -DREDIS_MODULE_TARGET -O3 -g -I../   -c -o trie_type.o trie_type.c
ar rcs libtrie.a levenshtein.o rune_util.o sparse_vector.o trie.o trie_type.o
make[1]: Leaving directory '/usr/src/RediSearch/RediSearch/src/trie'
make -C dep/triemap
make[1]: Entering directory '/usr/src/RediSearch/RediSearch/src/dep/triemap'
cc -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-result -fPIC -D_GNU_SOURCE -std=gnu99 -I"/usr/src/RediSearch/RediSearch/src" -DREDIS_MODULE_TARGET -O3 -g   -c -o triemap.o triemap.c
In file included from triemap.c:1:0:
triemap.h:9:9: error: unknown type name 'u_int16_t'
 typedef u_int16_t tm_len_t;
         ^~~~~~~~~
make[1]: Leaving directory '/usr/src/RediSearch/RediSearch/src/dep/triemap'
make[1]: *** [<builtin>: triemap.o] Error 1
make: *** [Makefile:70: triemap] Error 2

Thanks!

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.