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.

248 lines
6.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 2000.
  5. //
  6. // File: tblsink.hxx
  7. //
  8. // Contents: Data structures for large tables.
  9. //
  10. // Classes: CTableSink
  11. //
  12. // History: 09 Jun 1994 Alanw Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #pragma once
  16. //
  17. // Forward declaration of classes
  18. //
  19. class CRetriever;
  20. class CSortSet;
  21. class CQAsyncExecute;
  22. class CCategorize;
  23. class CCategParams
  24. {
  25. public:
  26. WORKID widRow; // row being categorized
  27. WORKID widPrev; // row before widRow (or widInvalid)
  28. WORKID widNext; // row after widRow (or widInvalid)
  29. unsigned catPrev; // category of widPrev
  30. unsigned catNext; // cateogry of widNext
  31. unsigned icmpPrev; // 1-based comparison result with widPrev
  32. unsigned icmpNext; // 1-based comparison result with widNext
  33. };
  34. //+-------------------------------------------------------------------------
  35. //
  36. // Class: CTableSink
  37. //
  38. // Purpose: A sink of table data. This class is used by the query
  39. // execution class (CQAsyncExecute) to push data into the table.
  40. //
  41. // Interface:
  42. //
  43. // Notes: Because of the _status member and its accessor functions,
  44. // this class is not pure virtual. Does it matter?
  45. //
  46. // History: 08 Jun 1994 AlanW Created, factored from CObjectTable
  47. //
  48. //--------------------------------------------------------------------------
  49. class CTableSink
  50. {
  51. public:
  52. //
  53. // Maximum number of rows recommended for a window.
  54. //
  55. // For testing, try using the smaller set of numbers for the window
  56. // bucket limit & rowbusket limit.
  57. //
  58. enum { cWindowRowLimit = 0x400 };
  59. enum { cBucketRowLimit = cWindowRowLimit/8 };
  60. CTableSink() : _status(0), _scStatus(0), _pCategorizer(0),
  61. _cMaxRows(0), _fNoMoreData(FALSE) {}
  62. //
  63. // Add new data
  64. //
  65. enum ERowType {
  66. eNewRow, // Brand new row - not seen before
  67. eMaybeSeenRow, // A row from a multi-pass evaluation
  68. eNotificationRow, // A notification type of row
  69. eBucketRow // Row from exploding a bucket
  70. };
  71. virtual WORKID PathToWorkID( CRetriever& obj,
  72. CTableSink::ERowType eRowType ) = 0;
  73. virtual BOOL PutRow( CRetriever & obj,
  74. BOOL fGuaranteedNew = FALSE )
  75. {
  76. Win4Assert( !"Must Not Be Called" );
  77. return TRUE;
  78. }
  79. virtual BOOL PutRow( CRetriever & obj,
  80. CTableSink::ERowType eRowType )
  81. {
  82. BOOL fGuaranteedNew = eRowType == eNewRow;
  83. return PutRow( obj, fGuaranteedNew );
  84. }
  85. virtual DBCOUNTITEM RowCount() = 0;
  86. //
  87. // Callback(s) from table to query **must not be initiated**
  88. // after this call completes.
  89. //
  90. virtual void QueryAbort();
  91. //
  92. // Modify / delete data
  93. virtual void RemoveRow( PROPVARIANT const & varUnique ) = 0;
  94. //
  95. // Status manipulation
  96. //
  97. virtual inline ULONG Status();
  98. virtual inline NTSTATUS GetStatusError();
  99. virtual void SetStatus(ULONG s, NTSTATUS sc = STATUS_SUCCESS);
  100. //
  101. // Sort order
  102. //
  103. virtual CSortSet const & SortOrder() = 0;
  104. virtual void ProgressDone (ULONG ulDenominator, ULONG ulNumerator)
  105. {
  106. Win4Assert ( !"Progress done called on random table sink");
  107. }
  108. virtual void SetCategorizer(CCategorize *pCategorize)
  109. { _pCategorizer = pCategorize; }
  110. CCategorize * GetCategorizer() { return _pCategorizer; }
  111. unsigned LokCategorize( CCategParams & params );
  112. BOOL IsCategorized() const { return 0 != _pCategorizer; }
  113. virtual void Quiesce () {}
  114. //
  115. // For Bucket -> Window Conversion
  116. //
  117. virtual void SetQueryExecute( CQAsyncExecute * pQExecute )
  118. {
  119. //
  120. // Those classes which need this will over-ride the virtual
  121. // function
  122. //
  123. }
  124. void SetMaxRows( ULONG cMaxRows )
  125. {
  126. _cMaxRows = cMaxRows;
  127. }
  128. ULONG MaxRows( )
  129. {
  130. return _cMaxRows;
  131. }
  132. void SetFirstRows( ULONG cFirstRows )
  133. {
  134. _cFirstRows = cFirstRows;
  135. }
  136. ULONG FirstRows()
  137. {
  138. return _cFirstRows;
  139. }
  140. BOOL NoMoreData( )
  141. {
  142. return _fNoMoreData;
  143. }
  144. # ifdef CIEXTMODE
  145. void CiExtDump(void *ciExtSelf);
  146. # endif
  147. protected:
  148. ULONG _status; // Query status
  149. NTSTATUS _scStatus; // Error code if status is error
  150. CCategorize * _pCategorizer; // table categorizer object
  151. ULONG _cMaxRows; // MaxRows restriction
  152. ULONG _cFirstRows; // Only sort and return the first _cFirstRows
  153. BOOL _fNoMoreData; // Set it to TRUE to indicate no more
  154. // data needed
  155. };
  156. DECLARE_SMARTP( TableSink )
  157. //+---------------------------------------------------------------------------
  158. //
  159. // Member: CTableSink::QueryAbort, public
  160. //
  161. // Synopsis: Signals query is going away.
  162. //
  163. // History: 07-Mar-95 KyleP Created.
  164. //
  165. // Notes: Derived classes should override if they make callbacks
  166. // to query engine.
  167. //
  168. //----------------------------------------------------------------------------
  169. inline void CTableSink::QueryAbort()
  170. {
  171. }
  172. //+---------------------------------------------------------------------------
  173. //
  174. // Member: CTableSink::Status, public
  175. //
  176. // Returns: Current status of the query
  177. //
  178. // History: 08 Jun 94 Alanw Removed serialization
  179. // 20-Apr-92 KyleP Serialized access
  180. // 22-Oct-91 KyleP Created.
  181. //
  182. // Notes: This call is *not* serialized.
  183. //
  184. //----------------------------------------------------------------------------
  185. inline ULONG CTableSink::Status()
  186. {
  187. return ( _status );
  188. }
  189. //+---------------------------------------------------------------------------
  190. //
  191. // Member: CTableSink::GetStatusError, public
  192. //
  193. // Returns: NTSTATUS - status error when query in error state
  194. //
  195. // History: 08 Dec 95 Alanw Created
  196. //
  197. // Notes: This call is *not* serialized.
  198. //
  199. //----------------------------------------------------------------------------
  200. inline NTSTATUS CTableSink::GetStatusError()
  201. {
  202. return ( _scStatus );
  203. }