Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
5.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2001.
  5. //
  6. // File: FRESHCUR.CXX
  7. //
  8. // Contents: Fresh Cursor
  9. //
  10. // Classes: CFreshCursor
  11. //
  12. // History: 16-May-91 BartoszM Created.
  13. // 28-Feb-92 AmyA Added HitCount()
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <pch.cxx>
  17. #pragma hdrstop
  18. #include "freshcur.hxx"
  19. #include "fresh.hxx"
  20. #include "fretest.hxx"
  21. #include "resman.hxx"
  22. #include "indsnap.hxx"
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Member: CFreshCursor::LoadWorkId, private
  26. //
  27. // Synopsis: Load current wid and occurrence
  28. //
  29. // History: 16-May-91 BartoszM Created
  30. //
  31. //----------------------------------------------------------------------------
  32. __forceinline void CFreshCursor::LoadWorkId ()
  33. {
  34. _wid = _cur->WorkId();
  35. if ( widInvalid == _wid )
  36. return;
  37. _iid = _cur->IndexId();
  38. _pid = _cur->Pid();
  39. while ( _indSnap.GetFresh()->IsCorrectIndex( _iid, _wid ) ==
  40. CFreshTest::Invalid )
  41. {
  42. _wid = _cur->NextWorkId();
  43. if ( widInvalid == _wid )
  44. return;
  45. _iid = _cur->IndexId();
  46. }
  47. _pid = _cur->Pid();
  48. } //LoadWorkId
  49. //+---------------------------------------------------------------------------
  50. //
  51. // Member: CFreshCursor::CFreshCursor, public
  52. //
  53. // Synopsis: Create a sursor that merges a number of cursors.
  54. //
  55. // Arguments: [cur] -- cursor to be pruned
  56. //
  57. // History: 16-May-91 BartoszM Created
  58. //
  59. //----------------------------------------------------------------------------
  60. CFreshCursor::CFreshCursor( XCursor & cur, CIndexSnapshot& indSnap )
  61. : _cur( cur ),
  62. _indSnap ( indSnap ) // acquire it
  63. {
  64. LoadWorkId();
  65. }
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Member: CFreshCursor::WorkIdCount, public
  69. //
  70. // Synopsis: return wid count
  71. //
  72. // Expects: cursor positioned after key
  73. //
  74. // History: 21-Jun-91 BartoszM Created
  75. // 15-Jul-92 KyleP Call doesn't make sense.
  76. //
  77. //----------------------------------------------------------------------------
  78. ULONG CFreshCursor::WorkIdCount()
  79. {
  80. ciAssert (( FALSE && "CFreshCursor::WorkIdCount called" ));
  81. return ( 0 );
  82. }
  83. //+---------------------------------------------------------------------------
  84. //
  85. // Member: CFreshCursor::WorkId, public
  86. //
  87. // Synopsis: Get current work id.
  88. //
  89. // History: 16-May-91 BartoszM Created
  90. //
  91. //----------------------------------------------------------------------------
  92. WORKID CFreshCursor::WorkId()
  93. {
  94. return _wid;
  95. }
  96. //+---------------------------------------------------------------------------
  97. //
  98. // Member: CFreshCursor::NextWorkId, public
  99. //
  100. // Synopsis: Move to next work id
  101. //
  102. // Returns: Target work id or widInvalid if no more wid's for current key
  103. //
  104. // Effects: Changes current IndexId.
  105. //
  106. // History: 16-May-91 BartoszM Created
  107. //
  108. // Notes: The same work id may be returned multiple times,
  109. // corresponding to multiple indexes.
  110. //
  111. //----------------------------------------------------------------------------
  112. WORKID CFreshCursor::NextWorkId()
  113. {
  114. _cur->NextWorkId();
  115. LoadWorkId();
  116. return _wid;
  117. }
  118. //+---------------------------------------------------------------------------
  119. //
  120. // Member: CFreshCursor::HitCount, public
  121. //
  122. // Synopsis: returns the occurrence count
  123. //
  124. // Returns: occurrence count for current wid
  125. //
  126. // History: 28-Feb-92 AmyA Created
  127. //
  128. //----------------------------------------------------------------------------
  129. ULONG CFreshCursor::HitCount()
  130. {
  131. ciAssert( _wid != widInvalid );
  132. return _cur->HitCount();
  133. }
  134. void CFreshCursor::RatioFinished (ULONG& denom, ULONG& num)
  135. {
  136. _cur->RatioFinished (denom, num);
  137. Win4Assert( denom > 0 );
  138. }
  139. //+---------------------------------------------------------------------------
  140. //
  141. // Member: CFreshCursor::Rank, public
  142. //
  143. // Synopsis: returns the rank for _cur
  144. //
  145. // Returns: rank for current wid
  146. //
  147. // History: 14-Apr-92 AmyA Created
  148. //
  149. //----------------------------------------------------------------------------
  150. LONG CFreshCursor::Rank()
  151. {
  152. ciAssert( _wid != widInvalid );
  153. Win4Assert( _cur->Rank() >= 0 );
  154. Win4Assert( _cur->Rank() <= MAX_QUERY_RANK );
  155. return _cur->Rank();
  156. }
  157. //+-------------------------------------------------------------------------
  158. //
  159. // Member: CFreshCursor::GetRankVector, public
  160. //
  161. // Effects: Returns the weights from a vector cursor. No effect
  162. // for non-vector cursors.
  163. //
  164. // Arguments: [pulVector] -- Pointer to array of ULONG into which the
  165. // vector elements are returned.
  166. //
  167. // Returns: The number of elements stored in [pulVector].
  168. //
  169. // History: 15-Jul-92 KyleP Created
  170. //
  171. //--------------------------------------------------------------------------
  172. ULONG CFreshCursor::GetRankVector( LONG * plVector, ULONG cElements )
  173. {
  174. ciAssert( _wid != widInvalid );
  175. return( _cur->GetRankVector( plVector, cElements ) );
  176. }