Comments (4)
Changing TrieChar
type would involve replacing <string.h>
function calls in the Tails
implementation with custom functions written for uint16
strings.
The amount of work should be about the same as changing the string representation from 0-terminated to length-counted. So, I think changing the type is not necessary.
What really matters is AlphaChar
string, for which 0 termination is still assumed on every API. We need new APIs to allow character 0 in keys.
from libdatrie.
I think binary keys should be represented with a separate set of APIs, just like how memcpy()
is separated from strcpy()
. For ease of use, let's define a dedicated data type BinKey
, e.g.
typedef struct _BinKey BinKey;
struct _BinKey {
AlphaChar *key;
int key_len;
};
with some associated functions, say:
void bin_key_set (BinKey *bk, AlphaChar *key, int key_len);
void bin_key_cpy (BinKey *dst, const BinKey *src);
int bin_key_cmp (const BinKey *bk1, const BinKey *bk2);
void bin_key_destruct (BinKey *bk); // freeing the allocated *key
Then, it can be used in our APIs:
Bool trie_bin_retrieve (const Trie *trie, const BinKey *bin_key, TrieData *o_data);
Bool trie_bin_store (Trie *trie, const BinKey *bin_key, TrieData data);
Bool trie_bin_store_if_absent (Trie *trie, const BinKey *bin_key, TrieData data);
Bool trie_bin_delete (Trie *trie, const BinKey *bin_key);
typedef Bool (*TrieBinEnumFunc) (const BinKey *bin_key, TrieData data, void *user_data);
Bool trie_bin_enumerate (const Trie *trie, TrieBinEnumFunc enum_func, void *user_data);
The TrieIterator
part also needs the BinKey
counterpart. But let's elaborate further whether it needs a new iterator type for BinKey
or just an additional method to the existing TrieIterator
type.
from libdatrie.
I like the API, look forward to seeing it in the next libdatrie
release :)
from libdatrie.
I think binary keys should be represented with a separate set of APIs, just like how
memcpy()
is separated fromstrcpy()
.
I've just got some free time to work on this. And the length-counted key appears to be a bad idea, as the concept of terminating TRIE_CHAR_TERM
('\0'
) is hard-wired in the trie structure, to allow a key to be prefix to other keys (e.g. 'an' is prefix to 'another'). And this also applies to binary keys.
So, let's consider changing the TrieChar
typedef instead. AFAIK, this would break compatibility of the TAIL structure in current trie files.
from libdatrie.
Related Issues (20)
- complexity for searching HOT 2
- Comparison of unsigned size_t with 0 creates unreachable code HOT 1
- Memory corruption error in "trie_new" method when using libdatrie v2.10.0 HOT 3
- Cannot install r0.2.10 on centos 7 HOT 2
- possible bug HOT 1
- about default header files HOT 2
- Difficulties cross-compiling HOT 1
- Replace autotools with CMake
- Should we convert it to C++? HOT 1
- 支持英文匹配吗?
- Build errors? HOT 2
- Installation error -- possibly undefined macro AC_MSG_RESULT HOT 2
- undefined reference to `libiconv_close'
- Some issues reported by Coverity Scan HOT 1
- Warning in test_walk.c
- build error: ld: error: undefined symbol: locale_charset (if configure detects locale_charset) HOT 2
- Any interest in deserializing from a memory buffer?
- Parallel test suite execution causes tests to fail
- error: possibly undefined macro: AC_MSG_RESULT
- fail tests in msys
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libdatrie.