Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

StatPKFile.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Fri Apr 29 00:25:49 EDT 2005 by ken@xorian.net         
00020 //      modified on Mon Jul 15 17:36:23 EDT 2002 by kcschalk@shr.intel.com 
00021 //      modified on Sat Feb 12 13:10:04 PST 2000 by mann  
00022 //      modified on Sat Oct  4 08:06:49 PDT 1997 by heydon
00023 
00024 #include <Basics.H>
00025 #include "CacheEntry.H"
00026 #include "SPKFileRep.H"
00027 #include "SPKFile.H"
00028 #include "StatNames.H"
00029 #include "StatCFP.H"
00030 #include "StatPKFile.H"
00031 
00032 int PKFileObj::Search(int verbose,
00033                       /*INOUT*/ Stat::Collection &stats)
00034   const throw ()
00035 {
00036     // save total number of entries before searching this PKFile
00037     int childLevel = 1;
00038     long int preNumEntries = (stats.fanout.size() > childLevel)
00039       ? (stats.fanout.get(childLevel))->SumTotal() : 0L;
00040 
00041     // iterate over children
00042     int cnt;
00043     {
00044       CFPObj *cfp = (CFPObj *) 0;
00045       PKFileIter it(this);
00046       for (cnt = 0; it.Next(/*OUT*/ cfp); cnt++) {
00047         (void) cfp->Search(verbose, /*INOUT*/stats);
00048       }
00049       cfp = (CFPObj *) 0; // drop on floor for GC
00050     }
00051 
00052     // update "stats.entryStats" fields for this PKFile
00053     stats.entryStats[Stat::PKFileSize].AddVal(this->len, this->loc);
00054     const FV::ListApp *allNames = this->pkFile->AllNames();
00055     stats.entryStats[Stat::NumNames].AddVal(allNames->len, this->loc);
00056     for (int i = 0; i < allNames->len; i++) {
00057         int nameLen = (allNames->name[i]).Length();
00058         stats.entryStats[Stat::NameSize].AddVal(nameLen, this->loc);
00059     }
00060     long int postNumEntries = (stats.fanout.get(childLevel))->SumTotal();
00061     int numEntries = (int)(postNumEntries - preNumEntries);
00062     stats.entryStats[Stat::NumEntries].AddVal(numEntries, this->loc);
00063     if (allNames->len > 0) {
00064         int numCommonNms = this->pkFile->CommonNames()->Cardinality();
00065         stats.entryStats[Stat::NumCommonNames].AddVal(numCommonNms, this->loc);
00066         float totalF = (float)(allNames->len);
00067         float commonF = (float)numCommonNms;
00068         int pcntCommon = (int)(0.49 + (100.0 * commonF / totalF));
00069         stats.entryStats[Stat::PcntCommonNames].AddVal(pcntCommon, this->loc);
00070     }
00071 
00072     // update fan-out for this level
00073     int thisLevel = childLevel + 1;
00074     StatCount *sc;
00075     if (stats.fanout.size() <= thisLevel) {
00076         assert(stats.fanout.size() == thisLevel);
00077         sc = NEW(StatCount);
00078         stats.fanout.addhi(sc);
00079     } else {
00080         sc = stats.fanout.get(thisLevel);
00081     }
00082     sc->AddVal(cnt, this->loc);
00083     return thisLevel;
00084 }
00085 
00086 PKFileIter::PKFileIter(const PKFileObj *pkf) throw ()
00087   : pkf(pkf), pkHdr(pkf->pkHdr), cfpIndex(0)
00088 {
00089     this->cfpEntryMap = pkf->pkFile->OldEntries();
00090 }
00091 
00092 bool PKFileIter::Next(/*OUT*/ CFPObj* &cfp) throw ()
00093 {
00094     bool res = (this->cfpIndex < this->pkHdr->num);
00095     if (res) {
00096         SPKFileRep::HeaderEntry *he = &(this->pkHdr->entry[this->cfpIndex++]);
00097         CE::List *entries;
00098         bool inTbl = this->cfpEntryMap->Get(he->cfp, /*OUT*/ entries);
00099         assert(inTbl);
00100         Stat::Location *cfp_loc =
00101           NEW_CONSTR(Stat::Location,
00102                      (pkf->loc->add_cfp(pkf->pkFile->NamesEpoch(),
00103                                         he->cfp)));
00104         cfp = NEW_CONSTR(CFPObj, (cfp_loc, pkf->pkFile, he->cfp, entries));
00105     }
00106     return res;
00107 }

Generated on Mon May 8 00:48:36 2006 for Vesta by  doxygen 1.4.2