Ejemplo n.º 1
0
void VnodeCacher::add(Vnode* directory, const string& name, Vnode* entry)
{
    if (directory->type != Vnode::DIRECTORY) return;

    DirectoriesMap::iterator it = directories_->find(directory);
    EntriesMap* entries;
    if (it == directories_->end())
    {
        entries = new EntriesMap;
        directories_->insert(vpair(directory, entries));
    }
    else
    {
        entries = (*it).second;
    }

    EntriesMap::iterator eit = entries->find(name);
    if (eit != entries->end())
    {
        monapi_fatal("already exists vnode <%s>\n", name.c_str());
    }

    entries->insert(spair(name, entry));
    return;
}
Ejemplo n.º 2
0
  Accumulator* PivotTable::getAccumulatorForKeyAndEntry(const char* key, const char* entryKey)
  {
    //std::cout << "Key " << key << std::endl;
    Container::const_iterator finder = mDocumentMap.find(key);
    EntriesMap* entries = 0;
    if (finder == mDocumentMap.end())
    {
      entries = new EntriesMap();
#ifndef NO_GOOGLE_HASH
      entries->set_empty_key(0);
#endif
      size_t theSize = strlen(key);
      char* newKey = new char[theSize];
      newKey[0] = '\0';
      strcpy(newKey, key);
      mDocumentMap[newKey] = entries;
    } else {
      entries = finder->second;
    }
      
    EntriesMap::const_iterator finderEntry = entries->find(entryKey);
    Accumulator* result = 0;
    if (finderEntry == entries->end())
    {
      result = new Accumulator();
      entries->insert(std::make_pair(entryKey,result));
    } else  
        result = finderEntry->second;
    return result;
  }
Ejemplo n.º 3
0
Vnode* VnodeCacher::lookup(Vnode* directory, const string& name)
{
    if (directory->type != Vnode::DIRECTORY) return NULL;
    DirectoriesMap::iterator it = directories_->find(directory);
    EntriesMap* entries;
    if (it == directories_->end())
    {
        return NULL;
    }
    else
    {
        entries = (*it).second;
    }
    EntriesMap::iterator eit = entries->find(name);
    return eit == entries->end() ? NULL : (*eit).second;
}