Go to the documentation of this file. 1 #ifndef _FAST_LOOKUP_TABLE_HPP_
2 #define _FAST_LOOKUP_TABLE_HPP_ "$Id: fastLookupTable.hpp 454 2020-07-23 20:22:23Z geoff $";
114 template <
typename RECORD_TYPE,
const uint_fast8_t MAX_LOOKAHEAD=4,
115 const unsigned char SMALLEST_CHAR=
'A',
const unsigned char LARGEST_CHAR=
'Z',
127 typename std::map<BinaryBlock_struct,RECORD_TYPE *,LT_KEY_COMPARE>::const_iterator i =
outOfBoundEntries.find(key);
165 typename std::map<BinaryBlock_struct,RECORD_TYPE *,LT_KEY_COMPARE>::iterator
extra_it;
245 RECORD_TYPE *result = curState.
extra_it->second;
302 int_fast32_t offsetInKey = 0;
303 const int_fast32_t maxLen =
OME_EXPECT_TRUE((keyLen <= MAX_LOOKAHEAD)) ?
static_cast<int32_t
>(keyLen) - 1 : MAX_LOOKAHEAD - 1;
307 while (offsetInKey < maxLen) {
308 int_fast16_t iOffset =
static_cast<int_fast16_t
>(key[offsetInKey]) - SMALLEST_CHAR;
320 " intermediate Record at depth=" << offsetInKey <<
327 if (offsetInKey == (
static_cast<int_fast32_t
>(keyLen) - 1)) {
328 int_fast16_t iOffset =
static_cast<int_fast16_t
>(key[offsetInKey]) - SMALLEST_CHAR;
331 result = levelPtr->
record[iOffset];
333 " Record at depth=" << offsetInKey <<
348 RECORD_TYPE *result =
findRecord(
reinterpret_cast<const unsigned char *
>(key),
349 (uint_fast32_t) strlen(key));
358 RECORD_TYPE *result =
findRecord(
reinterpret_cast<const unsigned char *
>(key.data()),
359 (uint_fast32_t) key.length());
378 int addRecord(
const unsigned char *key,
const uint_fast32_t keyLen, RECORD_TYPE *rec) {
380 uint_fast32_t offsetInKey = 0;
381 int_fast16_t iOffset =
static_cast<int_fast16_t
>(key[offsetInKey]) - SMALLEST_CHAR;
389 const uint_fast32_t maxLen =
OME_EXPECT_TRUE(keyLen <= MAX_LOOKAHEAD) ? keyLen : MAX_LOOKAHEAD;
391 uint_fast32_t nextOffset = 1;
392 while (nextOffset < maxLen) {
396 levelPtr->
nextLevel[iOffset] = nextLevelPtr;
398 levelPtr = nextLevelPtr;
399 offsetInKey = nextOffset;
400 iOffset =
static_cast<int_fast16_t
>(key[offsetInKey]) - SMALLEST_CHAR;
411 levelPtr->
record[iOffset] = rec;
428 int result =
addRecord(
reinterpret_cast<const unsigned char *
>(key),
429 (uint_fast32_t) strlen(key), rec);
444 int result =
addRecord(
reinterpret_cast<const unsigned char *
>(key.data()),
445 (uint_fast32_t) key.length(), rec);
std::map< BinaryBlock_struct, RECORD_TYPE *, LT_KEY_COMPARE > outOfBoundEntries
Map to handle entries that do not fit: character out of bounds or too long.
Definition: fastLookupTable.hpp:124
OMEstring * condenseIntoString(bool includeVersionID)
Serialize all OMEencodeBufferElement items into a single string.
Definition: OMEencode.cpp:75
uint_fast32_t bfrLen
Definition: logging_api.hpp:520
OMEstring * encodeNLM(const class OMEencodeBuffer *bfr) const
Definition: OMEnlm.h:156
@ OME_NLM
Definition: OMEmanifests.h:90
FastLookupTable< RECORD_TYPE, MAX_LOOKAHEAD, SMALLEST_CHAR, LARGEST_CHAR, LT_KEY_COMPARE > * nextLevel[ELEMENT_RANGE]
pointer to chain of records that had character in this position
Definition: fastLookupTable.hpp:122
uint32_t elementCount() const OME_ALWAYS_INLINE
Returns the number of elements in the set.
Definition: OMEset.h:213
@ OME_FLOAT
Definition: OMEmanifests.h:82
const char s[]
Definition: t.cpp:4
@ OME_POINTER
Definition: OMEmanifests.h:92
class OMEfixed * fixed
Definition: OMEbaseType.h:300
@ OME_UINT16
Definition: OMEmanifests.h:98
RECORD_TYPE * record[ELEMENT_RANGE]
pointer to records that end at this position
Definition: fastLookupTable.hpp:120
IteratorState()
Definition: fastLookupTable.hpp:174
Implements associative array of OMEtype elements.
Definition: OMEassoc.h:112
ASSOC_HASH_KEY_t nextIndex(const ASSOC_HASH_KEY_t currentSubscript) const
Definition: OMEassoc.h:236
OMEstring * OMEuncompressString(const OMEstring &data)
Uncompress a previously compressed string.
Definition: OMEcompress.cpp:61
void resetIterator(FastLookupTable< RECORD_TYPE, MAX_LOOKAHEAD, SMALLEST_CHAR, LARGEST_CHAR, LT_KEY_COMPARE > *level)
Reset the iterator so that the next call to nextElement() returns the first record.
Definition: fastLookupTable.hpp:188
Implements text and binary string storage.
Definition: OMEstring.h:305
OME type encoding routines.
Buffer into which OMEtype data is encoded.
Definition: OMEencode.h:54
bool indexExists(const uint32_t i) const
Definition: OMEarray.h:202
Fundamental ANY type for FARGOS/VISTA Object Management Environment.
Definition: OMEbaseType.h:250
Internal class for iterator state.
Definition: fastLookupTable.hpp:156
@ OME_DOUBLE
Definition: OMEmanifests.h:83
RECORD_TYPE * findRecord(const std::string &key) const OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Convenience interface for working with std::string keys.
Definition: fastLookupTable.hpp:357
#define OME_ALWAYS_OPTIMIZE(level)
Mark a function to be compiled with a specific level of optimization.
Definition: compiler_hints.h:406
RECORD_TYPE * findRecord(const unsigned char *key, const uint_fast32_t keyLen) const OME_ALWAYS_OPTIMIZE("-O3")
Find record in mapping table.
Definition: fastLookupTable.hpp:298
class OMEoid * oid
Definition: OMEbaseType.h:297
void OMEloadVersion1Encodings()
Definition: encodeVer1.cpp:631
RECORD_TYPE * firstElement()
Return first element in table.
Definition: fastLookupTable.hpp:269
@ OME_UINT32
Definition: OMEmanifests.h:96
dl_attach_req_t attach_req
Definition: ethers.c:45
int_fast16_t currentLookaheadDepth
Definition: fastLookupTable.hpp:180
class OMEstring * s
Definition: OMEbaseType.h:299
long buffer[MAXDLBUF]
Definition: ethers.c:42
Iterator for FastLookupTable.
Definition: fastLookupTable.hpp:153
main(int argc, argv)
Definition: ethers.c:48
class OMEarray * array
Definition: OMEbaseType.h:294
int addRecord(const unsigned char *key, const uint_fast32_t keyLen, RECORD_TYPE *rec)
Add a record to mapping table.
Definition: fastLookupTable.hpp:378
~FastLookupTableIterator()
Destructor for FastLookupTable iterator.
Definition: fastLookupTable.hpp:266
bool atEnd() const OME_ALWAYS_INLINE
Returns a Boolean indicator if the end of the table has been seen.
Definition: fastLookupTable.hpp:196
class OMEnlm * nlm
Definition: OMEbaseType.h:301
@ IN_EXTRAS
Definition: fastLookupTable.hpp:162
void reset(FastLookupTable< RECORD_TYPE, MAX_LOOKAHEAD, SMALLEST_CHAR, LARGEST_CHAR, LT_KEY_COMPARE > *level)
Definition: fastLookupTable.hpp:167
std::map< BinaryBlock_struct, RECORD_TYPE *, LT_KEY_COMPARE >::iterator extra_it
Definition: fastLookupTable.hpp:165
struct strbuf ctl
Definition: ethers.c:43
~IteratorState()
Definition: fastLookupTable.hpp:176
#define OME_PREFETCH(addr, rw, locality)
Macro to request prefetch.
Definition: compiler_hints.h:362
Public interface to an OME Native Language Message.
Definition: OMEnlm.h:98
const char srcID[]
Definition: catSym.c:17
@ OME_STRING
Definition: OMEmanifests.h:85
void noteCharacterSet(uint_fast8_t c)
Definition: OMEstring.h:386
const OMEstring & getKeyForIndex(const ASSOC_HASH_KEY_t i) const
Definition: OMEassoc.h:198
static OMEnlm * decodeNLM(uint32_t ver, const OMEstring *encodedData, size_t *offset)
Definition: OMEnlm.cpp:140
Implements an ordered list of OMEtype elements.
Definition: OMEset.h:64
dl_phys_addr_req_t phys_addr_req
Definition: ethers.c:44
@ AT_END
Definition: fastLookupTable.hpp:162
int encode(class OMEencodeBuffer *) const
Add the encoding of an OMEtype into an OMEencodeBuffer.
Definition: OMEencode.cpp:189
enum FastLookupTable::FastLookupTableIterator::IteratorState::SEARCH_STATES searchState
#define MAXDLBUF
Definition: ethers.c:39
void addEncodedElement(OMEencodeBufferElement *elem)
Append an encoded element to the collection.
Definition: OMEencode.h:84
@ OME_NIL
Definition: OMEmanifests.h:78
#define OME_EXPECT_TRUE(expr)
Annotation macro for conditional expression expected to be true.
Definition: compiler_hints.h:541
@ IN_CHILDREN
Definition: fastLookupTable.hpp:162
@ OME_OID
Definition: OMEmanifests.h:84
bool operator()(const BinaryBlock_struct arg1, const BinaryBlock_struct arg2) const
Performs less-than comparison on BinaryBlock_struct elements.
Definition: fastLookupTable.hpp:38
float f
Definition: OMEbaseType.h:287
OMEtypes_t
Definition: OMEmanifests.h:77
uint_fast8_t getCharacterSet() const
Definition: OMEstring.h:396
Placeholder structure to reference a block of arbitrary data.
Definition: logging_api.hpp:517
RECORD_TYPE * findRecord(const char *key) const OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Convenience interface for working with C-string keys.
Definition: fastLookupTable.hpp:347
Fast map lookup table.
Definition: fastLookupTable.hpp:116
#define NULL
Definition: tmp.o.cpp:327
@ OME_UINT64
Definition: OMEmanifests.h:97
IteratorState stateStack[MAX_LOOKAHEAD]
Definition: fastLookupTable.hpp:179
LogMaskType_t COMPONENT_LOG_MASK() app("app_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(app, defaultMask))
OMEtype * decodeVersion1(uint32_t version, const OMEstring *encodedData, size_t *offset)
Definition: encodeVer1.cpp:260
OME fundamental type implementation.
Namespace to qualify ltBinaryBlock routine.
Definition: fastLookupTable.hpp:27
OMEstring * OMEcompressString(const OMEstring &data)
Compress a string.
Definition: OMEcompress.cpp:28
int addRecord(const std::string &key, RECORD_TYPE *rec) OME_ALWAYS_INLINE
Convenience interface for working with std::string keys.
Definition: fastLookupTable.hpp:443
FastLookupTable< RECORD_TYPE, MAX_LOOKAHEAD, SMALLEST_CHAR, LARGEST_CHAR, LT_KEY_COMPARE > * levelPtr
Definition: fastLookupTable.hpp:158
dl_phys_addr_ack_t * dlpadd
Definition: ethers.c:46
const void * dataBfr
Definition: logging_api.hpp:519
RECORD_TYPE * findRecordInSpillover(const unsigned char *key, const uint_fast32_t len) const OME_ALWAYS_INLINE
Definition: fastLookupTable.hpp:134
uint32_t ui
Definition: OMEbaseType.h:286
size_t length() const
Definition: OMEstring.h:401
virtual ~FastLookupTable()
Definition: fastLookupTable.hpp:285
const char srcID[] OME_USED
Definition: tick_time.cpp:24
int flags
Definition: ethers.c:41
SEARCH_STATES
Definition: fastLookupTable.hpp:161
uint_fast32_t elementCount() const OME_ALWAYS_INLINE
Definition: OMEarray.h:247
static OMEoid * decodeOID(uint32_t ver, const OMEstring *encodedData, size_t *offset)
Definition: OMEoidIntStub.cpp:48
#define AS_TEXT_BUFFER(s,...)
Convenience label to enable passing text with known length to output operator<<().
Definition: logging_api.hpp:2087
@ OME_SET
Definition: OMEmanifests.h:89
#define ntohl(x)
Definition: tmp.o.cpp:3101
int errno
Definition: ethers.c:41
Less-than comparison for BinaryBlock_struct.
Definition: fastLookupTable.hpp:32
#define OME_EXPECT_FALSE(expr)
Annotation macro for conditional expression expected to be false.
Definition: compiler_hints.h:540
#define LOG_COMPONENT_CERR(component, lvl)
Convenience macro that uses LOG_COMPONENT_INTO to conditionally log a message to standard error.
Definition: logging_api.hpp:3030
ARRAY_SUBSCRIPT_t nextIndex(const uint32_t currentSubscript) const
Definition: OMEarray.h:217
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
Description for OME encoding routines for a specific encoding version.
Definition: OMEencode.h:118
@ OME_UINT8
Definition: OMEmanifests.h:99
@ FIND_RECORD
Definition: fastLookupTable.hpp:162
@ OME_FIXED
Definition: OMEmanifests.h:91
FastLookupTableIterator(FastLookupTable< RECORD_TYPE, MAX_LOOKAHEAD, SMALLEST_CHAR, LARGEST_CHAR, LT_KEY_COMPARE > *levelPtr)
Constructor for FastLookupTable iterator.
Definition: fastLookupTable.hpp:261
RECORD_TYPE * nextElement()
Returns a pointer to the next element located by the iterator.
Definition: fastLookupTable.hpp:204
int ppa
Definition: ethers.c:41
RECORD_TYPE * findRecordInSpillover(const BinaryBlock_struct key) const
Definition: fastLookupTable.hpp:126
Implements sparse array of OMEtype elements.
Definition: OMEarray.h:75
@ ELEMENT_RANGE
Definition: fastLookupTable.hpp:118
#define LOG_ENDLINE
Closing clause for text line output using << operators.
Definition: logging_api.hpp:2956
Public interface to an OME Object Identifier.
Definition: OMEoid.h:196
@ OME_ANY
Definition: OMEmanifests.h:93
OMEstring * encodeOID(const class OMEencodeBuffer *bfr) const
Definition: OMEoid.h:221
int_fast16_t currentCharIndex
Definition: fastLookupTable.hpp:159
int addRecord(const char *key, RECORD_TYPE *rec) OME_ALWAYS_INLINE
Convenience interface for working with C-string keys.
Definition: fastLookupTable.hpp:427
uint32_t type
Definition: OMEbaseType.h:304
const class OMEtype & READ_ONLY_OMEtype
A convenience typedef for performing read-only access to sparse and associative arrays....
Definition: OMEtype.h:58
void addRecordToSpillover(const unsigned char *key, const uint_fast32_t keyLen, RECORD_TYPE *rec) OME_ALWAYS_INLINE
Definition: fastLookupTable.hpp:138
OMEtype * decodeVersion2(uint32_t version, const OMEstring *encodedData, size_t *offset)
Definition: encodeVer1.cpp:502
uint_fast32_t elementCount() const OME_ALWAYS_INLINE
Definition: OMEassoc.h:241
Holds data for a single encoded OMEtype element. Multiple OMEencodeBufferElement objects are linked t...
Definition: OMEencode.h:20
@ OME_ARRAY
Definition: OMEmanifests.h:86
OMEarrayStorage::ARRAY_SUBSCRIPT_t ARRAY_SUBSCRIPT_t
Definition: OMEarray.h:90
class OMEassoc * assoc
Definition: OMEbaseType.h:296
#define OMEtype
Definition: tmp.o.cpp:396
class OMEset * set
Definition: OMEbaseType.h:298
Internal data type to generate fixed-point constant from floating-point value.
Definition: OMEfixed.h:26
#define htonl(x)
Definition: tmp.o.cpp:3098
double d
Definition: OMEfixed.h:27
FastLookupTableIterator begin()
Get initial iterator.
Definition: fastLookupTable.hpp:451
@ OME_ASSOC
Definition: OMEmanifests.h:87
int fd
Definition: ethers.c:41
#define byte_swap64(x)
Definition: encodeVer1.cpp:26
FastLookupTable()
Construct a FastLookupTable object.
Definition: fastLookupTable.hpp:279
@ OME_INT32
Definition: OMEmanifests.h:79
@ OME_INT64
Definition: OMEmanifests.h:81
void OMEdefineEncodeRoutinesForVersion(OMEencodeRoutines *routines)
Register encoding routines for OMEtype data.
Definition: OMEencode.cpp:121