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 / VectorIndex.h < prev   
Encoding:
Text File  |  1998-04-16  |  2.4 KB  |  92 lines  |  [TEXT/CWIE]

  1. // VectorIndex.h
  2. //    Copyright:    © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //// IAIndex that stores vectors.
  5.  
  6. #pragma once
  7. #ifndef VectorIndex_h
  8. #define VectorIndex_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 "TFVector.h"
  18.  
  19. #pragma IA_BEGIN_EXPORTS
  20.  
  21. const uint32        VectorIndexType = 'Vec4';
  22.  
  23. class VectorDocInfo : public DocInfo {
  24. public:
  25.         VectorDocInfo() : vectorBlock(0), DocInfo() {}
  26.         VectorDocInfo(IADoc* d, DocID i) :  DocInfo(d,i), vectorBlock(0) {}
  27.     // IAOrderedStorable methods
  28.     IAStorable*            DeepCopy() const;
  29.     IABlockSize            StoreSize() const;
  30.     void                Store(IAOutputBlock* output) const;
  31.     IAStorable*            Restore(IAInputBlock* input) const;
  32.     IABlockID            GetVectorBlockID() const {return vectorBlock;}
  33.     void                SetVectorBlockID(IABlockID blockID){vectorBlock = blockID;}
  34. protected:
  35.     void                DeepCopying(const IAStorable* source);
  36.     void                Restoring(IAInputBlock* input, const IAStorable* proto);
  37. private:
  38.                         VectorDocInfo(VectorDocInfo&);
  39.     IABlockID            vectorBlock;
  40.  
  41. };
  42.  
  43. // needed for private member declaration
  44. class TermIdUpdateSet;
  45.  
  46. class VectorIndex : public virtual TermIndex {
  47. public:
  48.         VectorIndex(IAStorage* s, IACorpus* c, IAAnalysis* a,
  49.                     uint32 t = VectorIndexType, IABlockID r = NULL);
  50.         ~VectorIndex();
  51.                     
  52.     // VectorIndex-specific method:
  53.     virtual TFVector*    GetTFVector(IADoc* doc);
  54.  
  55.     IADefineNarrowMethods(VectorIndex, IAIndex);        // support for IANarrow
  56.     
  57.     virtual bool ValidateDocInfos(bool verbose);
  58.     
  59. protected:
  60.     // TermIndex methods we augment to store vectors:
  61.     DocInfo*            MakeDocInfo(IADoc* doc, DocID docID);
  62.     void                UpdateDocInfo(DocInfo* i, TFVector* vector);
  63.     void                MergeDocInfo(DocInfo* i, DocInfo* addDi, TermIndex* addIndex, TermID* reMap);
  64.     uint32                MergeDocCost();
  65.  
  66.     void                FlushUpdates();
  67.     void                DeletingDoc(DocInfo* i);
  68.     // Optimized version of GetTFMaps.
  69.     bool                GetTFMaps(IADoc** docs, uint32 nDocs, TFMap** tfMaps, Progress* p);
  70.     // delete doc clean up
  71.     void                 ExpungeTermPostings(); 
  72. private:
  73.     void                WriteTFVector(TFVector* vector, IABlockID block);
  74.     
  75.     TFVector*            ReadTFVector(IABlockID block);
  76.     TFVector*            ReadTFVector(IAStorage* storage, IABlockID block);
  77.     
  78.     TermIdUpdateSet*    termIdUpdateSet;
  79.     void                FlushTermIdUpdates();
  80.  
  81.                         VectorIndex(VectorIndex&);
  82. };
  83.  
  84. #pragma IA_END_EXPORTS
  85.  
  86. #if PRAGMA_STRUCT_ALIGN
  87.     #pragma options align=reset
  88. #endif
  89.  
  90. #pragma import reset
  91. #endif
  92.