Exemple #1
0
int lemur::utility::TermCache::find( const char* term ) const {
  int bucket = _hashFunction( term );

  if( _termCache[bucket].id != -1 ) {
    if( !strncmp( term, _termCache[bucket].term, sizeof _termCache[bucket].term ) ) {
      return _termCache[bucket].id;
    }
  }

  return -1;
}
Exemple #2
0
void lemur::utility::TermCache::add( const char* term, int termID ) {
  // don't cache terms longer than TERMCACHE_MAX_TERM_LENGTH
  if (term && (strlen(term) > TERMCACHE_MAX_TERM_LENGTH)) return;

  int bucket = _hashFunction( term );
  
  if( bucket >= 0 ) {
    if( _termCache[bucket].id == -1 ) {
      strncpy( _termCache[bucket].term, term, sizeof _termCache[bucket].term );
      _termCache[bucket].id = termID;
    }
  }
}
Exemple #3
0
link::api::LINKID_T link::utility::LinkCache::find(const char *linkName) const
{
	int bucket = _hashFunction( linkName );

	if( _linkCache[bucket].linkID != -1 ) 
	{
		if( !strncmp( linkName, _linkCache[bucket].link_str, sizeof _linkCache[bucket].link_str ) ) 
		{
			return _linkCache[bucket].linkID;
		}
	}

	return -1;
}
Exemple #4
0
bool link::utility::LinkCache::add(const char *linkName, link::api::LINKID_T LinkID)
{
	  // don't cache links longer than LINKCACHE_MAX_LINK_LENGTH
	if (linkName && (strlen(linkName) > LINKCACHE_MAX_LINK_LENGTH)) {
		return false;
	}
	else
	{
		int bucket = _hashFunction( linkName );

		if( bucket >= 0 ) 
		{
			if( _linkCache[bucket].linkID == -1 ) 
			{
				strncpy( _linkCache[bucket].link_str, linkName, sizeof _linkCache[bucket].link_str );
				_linkCache[bucket].linkID = LinkID;
				return true;
			}else{
				return false;
			}
		}
	}
}