home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / Index / InvertedIndex.h < prev    next >
Encoding:
Text File  |  1998-04-16  |  2.9 KB  |  106 lines  |  [TEXT/CWIE]

  1. // InvertedIndex.h
  2. //    Copyright:    © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //// IAIndex that stores vectors.
  5.  
  6. #pragma once
  7. #ifndef InvertedIndex_h
  8. #define InvertedIndex_h
  9.  
  10. #pragma import on
  11.  
  12. #if PRAGMA_STRUCT_ALIGN
  13.     #pragma options align=power
  14. #endif
  15.  
  16. #include "TermIndex.h"
  17. #include "FreqPosting.h"
  18.  
  19. #pragma IA_BEGIN_EXPORTS
  20.  
  21. const uint32        InvertedIndexType = 'Inv6';
  22.  
  23. // classes needed for private member declarations
  24. class BitArray;
  25. class UInt32Set;
  26. class InvertedTermInfo;
  27. class InvertedBlockTermInfo;
  28.  
  29. // FreqPosting Stream
  30. class FreqPS : public IAObject {
  31. public:
  32.     IA_INLINE            ~FreqPS() IA_INLINE_DEF()    // no-op dtor def
  33.     // Copys the next FreqPosting from the stream into the provided FreqPosting.
  34.     // Returns NULL at the end of the stream.
  35.     virtual bool         Next(FreqPosting* posting) = 0;
  36. };
  37.  
  38. class InvertedIndex : public virtual TermIndex {
  39. public:
  40.         InvertedIndex(IAStorage* s, IACorpus* c, IAAnalysis* a,
  41.                       uint32 t = InvertedIndexType, IABlockID r = NULL);
  42.         ~InvertedIndex();
  43.                     
  44.     // InvertedIndex-specific methods:
  45.     FreqPS*                GetFreqPostings(TermInfo* termInfo);
  46.     uint32                GetDeletedDocCount();
  47.  
  48.     // IAIndex methods we augment:
  49.     void                Initialize();
  50.     void                Open();
  51.     void                Compact();
  52.  
  53.     IADefineNarrowMethods(InvertedIndex, IAIndex);        // support for IANarrow
  54.     
  55.     virtual bool ValidateTermInfos(bool verbose);
  56.     
  57.     virtual TermInfo*            GetTermInfo(IATerm* term);
  58.  
  59. protected:
  60.     // TermIndex methods we augment to store postings:
  61.     TermInfo*            MakeTermInfo(IATerm* term, TermID id);
  62.     TermInfo*            UpdateTermInfo(TermInfo* i, FreqPosting* adds, TermFreq addCount,
  63.                                                     TermFreq delCount);
  64.     TermInfo*            MergeTermInfo(TermInfo* i, TermInfo* addTi, TermIndex* addIndex, DocID base);
  65.     uint32                MergeTermCost();
  66.     // TermIndex methods we augment to track deletions:
  67.     IABlockSize            RootSize();
  68.     void                StoreRoot(IAOutputBlock* output);
  69.     void                RestoreRoot(IAInputBlock* input);
  70.     void                Initializing();
  71.     void                DeletingDoc(DocInfo* i);
  72.     void                FinishingUpdate();
  73.     void                MergeDocIDs(TermIndex* addIndex, DocID base);
  74.  
  75.     // methods required for multiple inheritance
  76.     void                DeletingDocInternal(DocInfo* i);
  77.     void                DeletingPostings(IATerm* term, TermFreq delCount);
  78.     // delete doc clean up
  79.     void                ResetPostings(TermInfo* terminfo);
  80.     void                ResetDeletedDoc(DocInfo* docInfo);
  81.  
  82.  
  83. private:
  84.     void                UpdateTermMaxDocFreq(InvertedTermInfo* iti,
  85.                                              FreqPosting* adds, TermFreq addCount);
  86.     void                UpdatePostingBlocks(InvertedBlockTermInfo* iti,
  87.                                             FreqPosting* adds, TermFreq addCount);
  88.     void                ExpungeTermIds(UInt32Set* deletedTermIds);
  89.     InvertedTermInfo*    ExpungePostings(InvertedTermInfo* iti);
  90.     InvertedTermInfo*    ExpungePostingsBlocks(InvertedBlockTermInfo* ibti);
  91.  
  92.     IABlockID            deletedDocsRoot;
  93.     BitArray*            deletedDocs;
  94.  
  95.                         InvertedIndex(InvertedIndex&);    // don't define a copy constructor
  96. };
  97.  
  98. #pragma IA_END_EXPORTS
  99.  
  100. #if PRAGMA_STRUCT_ALIGN
  101.     #pragma options align=reset
  102. #endif
  103.  
  104. #pragma import reset
  105. #endif
  106.