Пример #1
0
void PhraseIndexerImpl::addPhrase(unsigned clsid, const string &phrase, 
                                  unsigned rank, const char *udata)
{
  map<phrase_hash_t, unsigned>::const_iterator it;
  phrase_hash_t h;
  Phrase *pphrase;
  
  MurmurHash(phrase, &h);
  
  // chech whatever such phrase already stored
  it = m_phrase2id.find(h);
  if (it == m_phrase2id.end()) {
    unsigned phraseId = m_stat.nphrases_uniq;
    pphrase = insertPhraseWords(phrase, phraseId);
    if (!pphrase)
      return;
    
    m_phrase2id.insert(pair<phrase_hash_t, unsigned>(h, phraseId));
    if (udata != NULL)
      m_udataWriter.add(phraseId, (string)udata);
    
    m_stat.nphrases_uniq++;
  }
  else {
    pphrase = &m_phrases[it->second];
    m_stat.nwords += pphrase->nwords();
  }
  
  m_stat.nphrases++;
  pphrase->addClass(clsid, rank);
  m_bDirty = true;
}
Пример #2
0
void ColorSpace::hashTransform( const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
	std::string inSpace = inputSpacePlug()->getValue();
	std::string outSpace = outputSpacePlug()->getValue();

	if( inSpace == outSpace || inSpace.empty() || outSpace.empty() )
	{
		h = MurmurHash();
		return;
	}

	inputSpacePlug()->hash( h );
	outputSpacePlug()->hash( h );
}
Пример #3
0
const u32 StringHash(const char* Str)
{
    uint len = 0;
    while(Str[len] != '\0') {
        len++;
    }
    u32 ret = MurmurHash(Str, len);

    // DEBUG - record recent strings in a circular buffer
    strncpy(&StringTable[StringIndex].Name[0], Str, sizeof(StringTable[StringIndex].Name)); 
    StringTable[StringIndex].Hash = ret;
    StringIndex = StringIndex + 1 == countof(StringTable) ? 0 : StringIndex + 1;
    // END DEBUG
   
    return ret;
}