コード例 #1
0
ファイル: VnodeCacher.cpp プロジェクト: ShotaroTsuji/mona
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;
}
コード例 #2
0
ファイル: VnodeCacher.cpp プロジェクト: ShotaroTsuji/mona
VnodeCacher::~VnodeCacher()
{
    Vnodes vnodes;
    // enumrate all Vnodes
    for (DirectoriesMap::const_iterator it = directories_->begin(); it != directories_->end(); ++it)
    {
        vnodes.push_back((*it).first);

        EntriesMap* entries = (*it).second;
        for (EntriesMap::iterator i = entries->begin(); i != entries->end(); i++)
        {
            vnodes.push_back((*i).second);
        }
        delete entries;
    }
    // enumrate unique Vnodes
    sort(vnodes.begin(), vnodes.end());
    Vnodes::iterator v = unique(vnodes.begin(), vnodes.end());
    vnodes.erase(v ,vnodes.end());
    for (Vnodes::const_iterator it = vnodes.begin(); it != vnodes.end(); ++it)
    {
        Vnode* v = (*it);
        // todo. v->fs will be destroyed before coming this line.
//        v->fs->destroy_vnode(v);
    }
    delete directories_;
}
コード例 #3
0
ファイル: PivotTable.cpp プロジェクト: jun9/openpivot
  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;
  }
コード例 #4
0
ファイル: VnodeCacher.cpp プロジェクト: ShotaroTsuji/mona
void VnodeCacher::enumCaches(Vnode* directory, std::vector<std::string>& caches)
{
    DirectoriesMap::iterator it = directories_->find(directory);
    if (it == directories_->end()) {
        return;
    }
    EntriesMap* entries = it->second;
    for (EntriesMap::const_iterator eit = entries->begin(); eit != entries->end(); ++eit) {
        caches.push_back(eit->first);
    }
}
コード例 #5
0
ファイル: VnodeCacher.cpp プロジェクト: ShotaroTsuji/mona
void VnodeCacher::remove(Vnode* directory, const string& name)
{
    ASSERT(directory->type == Vnode::DIRECTORY);
    DirectoriesMap::iterator it = directories_->find(directory);
    EntriesMap* entries;
    if (it == directories_->end()) {
        return;
    } else {
        entries = (*it).second;
    }
    entries->erase(name);
    return;
}
コード例 #6
0
ファイル: VnodeCacher.cpp プロジェクト: ShotaroTsuji/mona
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;
}
コード例 #7
0
ファイル: PivotTable.cpp プロジェクト: jun9/openpivot
 void PivotTable::cleanup()
 {
   EntriesMap* entries = 0;
   for (Container::iterator iter = mDocumentMap.begin(); iter != mDocumentMap.end(); ++iter)
   {
     entries = iter->second;
     for (EntriesMap::iterator theIterEntries = entries->begin(); theIterEntries != entries->end(); ++theIterEntries)
     {
       if (theIterEntries->second)
       {
         delete theIterEntries->second;
         theIterEntries->second = 0;
       }
     }
     delete entries;
     delete[] iter->first;
     iter->second = 0;
   }
 }