diff options
author | 2012-05-07 16:28:30 +0900 | |
---|---|---|
committer | 2012-05-07 17:15:21 +0900 | |
commit | 8950ce6c44706467bb386570ae236a2b8b983666 (patch) | |
tree | d140954320c5ce87a5757d5f8a028011044ae142 /native/jni/src/bigram_dictionary.cpp | |
parent | f1634c872c57a5e8d0a861cda299fdbd98740e79 (diff) | |
download | latinime-8950ce6c44706467bb386570ae236a2b8b983666.tar.gz latinime-8950ce6c44706467bb386570ae236a2b8b983666.tar.xz latinime-8950ce6c44706467bb386570ae236a2b8b983666.zip |
Replace the bigram list position with the map and filter
Passing the position will not allow us a reasonable lookup
time. Replace this with a map and bloom filter for very fast
lookup.
Bug: 6313806
Change-Id: I3a61c0001cbc987c1c3c7b8df635d4590a370144
Diffstat (limited to 'native/jni/src/bigram_dictionary.cpp')
-rw-r--r-- | native/jni/src/bigram_dictionary.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp index d120261ae..220b340d1 100644 --- a/native/jni/src/bigram_dictionary.cpp +++ b/native/jni/src/bigram_dictionary.cpp @@ -158,6 +158,11 @@ static inline void setInFilter(uint8_t *filter, const int position) { filter[bucket >> 3] |= (1 << (bucket & 0x7)); } +static inline bool isInFilter(uint8_t *filter, const int position) { + const unsigned int bucket = position % BIGRAM_FILTER_MODULO; + return filter[bucket >> 3] & (1 << (bucket & 0x7)); +} + void BigramDictionary::fillBigramAddressToFrequencyMapAndFilter(const int32_t *prevWord, const int prevWordLength, std::map<int, int> *map, uint8_t *filter) { memset(filter, 0, BIGRAM_FILTER_BYTE_SIZE); |