在 Windows 7 中編制優先順序和數據列集事件的索引
本主題介紹 Windows 7 的索引優先順序和列集事件。
本主題的組織方式如下:
索引優先順序和列集事件
在 Windows 7 和後續版本中,有一個優先順序堆疊,客戶端可以要求將特定查詢中使用的範圍優先於一般項目的範圍。
此優先順序堆疊具有下列特性:
- 堆疊中的項目可以具有高優先順序、中優先順序或低優先順序:
- Foreground:略過退讓邏輯,並以機器的最大速度進行索引。
- 高:已要求優先處理且有退避。
- 低:已要求設置優先順序,並非犧牲堆疊上的其他範圍,而是優先於未設定優先順序的索引編製。
- 任何高優先順序或前景優先順序的請求都會自動將查詢提升到堆疊頂端。
- 只有堆疊頂端的項目可以具有優先順序。
- 當一個具有前景優先權的查詢被降低優先級時,它會收到一個通知事件,告知它已失去前景優先權,並成為具有退避機制的高優先權。
優先順序堆疊會設定索引器中處理之專案的整體優先順序,如下所示:
高優先順序通知沒有延遲,通常只會針對少數項目發送。 例如,Windows 檔案總管會針對小型複製引擎作業使用此優先順序。
優先順序堆疊位於堆疊的頂端,具有退避機制,並且是最近要求的優先順序查詢。
堆疊中的第二個查詢。
堆疊中的第三個查詢。
堆疊中的第四個查詢,以及後續的查詢。
普通優先項目。
已刪除的專案。
注意
每個群組中的專案會透過較舊的個別專案語意,在內部設定優先順序。
IRowsetPriorization 範例
優先順序工作的主要 API 可透過下列介面取得,其可藉由查詢傳回的數據列集來呼叫:
typedef [v1_enum] enum
{
PRIORITY_LEVEL_FOREGROUND = 0, // process items in the scope first as quickly as possible
PRIORITY_LEVEL_HIGH = 1, // process items in the scope first at the normal rate
PRIORITY_LEVEL_LOW = 2, // process items in this scope before those at the normal rate, but after any other prioritization requests
PRIORITY_LEVEL_DEFAULT = 3 // process items at the normal indexer rate
} PRIORITY_LEVEL;
[
object,
uuid(IRowsetPrioritization_GUID),
pointer_default(unique)
]
interface IRowsetPrioritization : IUnknown
{
// Sets or retrieves the current indexer prioritization level for the scope specified by
// this query.
HRESULT SetScopePriority( [in] PRIORITY_LEVEL priority, [in] DWORD scopeStatisticsEventFrequency );
HRESULT GetScopePriority( [out] PRIORITY_LEVEL * priority, [out] DWORD * scopeStatisticsEventFrequency );
// Gets information describing the scope specified by this query:
// indexedDocumentCount - The total number of documents currently indexed in the scope
// oustandingAddCount - The total number of documents yet to be indexed in the scope (those not yet included in indexedDocumentCount)
// oustandingModifyCount - The total number of documents indexed in the scope that need to be re-indexed (included in indexedDocumentCount)
HRESULT GetScopeStatistics( [out] DWORD * indexedDocumentCount, [out] DWORD * oustandingAddCount, [out] DWORD * oustandingModifyCount );
};
資料列集優先順序的運作方式如下:
- IRowsetPrioritization 是透過索引器列集上的 IUnknown::QueryInterface 方法 來獲得。 DBPROP_ENABLEROWSETEVENTS 必須使用 OLE DB ICommandProperties::SetProperties 方法將其設置為 TRUE,然後才能在執行查詢之前使用列集優先功能。
- IRowsetPrioritization::SetScopePriority 設定屬於查詢之範圍的優先順序,並在查詢範圍內有未完成的文件編製索引時引發範圍統計數據事件的間隔。 如果優先順序層級設定為預設值,就會引發此事件。
- IRowsetPrioritization::GetScopeStatistics 可用來取得範圍中已編製索引的項目數目、要加入範圍中未完成的檔數目,以及必須在此範圍內重新編製索引的文件數目。
IRowsetPrioritization 事件
在 IRowsetEvents::OnRowsetEvent 的 ROWSETEVENT_TYPE 列舉中,有三個列集事件:
// This method allows for future notifications of various actions about your rowset or items within
// eventType: - An identifier of the particular event being sent
// pVarEventData: - The expected value of the EventData for each event type
// ROWSETEVENT_TYPE_DATAEXPIRED - VT_EMPTY
// ROWSETEVENT_TYPE_FOREGROUNDLOST - VT_EMPTY
// ROWSETEVENT_TYPE_SCOPESTATISTICS - VT_VECTOR | VT_UI4 - 3 elements (0 = indexed items, 1 = outstanding adds, 2 = oustanding modifies)
HRESULT OnRowsetEvent( [in] ROWSETEVENT_TYPE eventType, [in] REFPROPVARIANT eventData );
資料列集事件如下所示:
- ROWSETEVENT_TYPE_DATAEXPIRED 事件表示支援該資料列集的資料已經過期,應該申請新的資料列集。
- ROWSET_TYPE_FOREGROUNDLOST 事件表示在優先順序堆疊中具有前景優先順序的專案已降級,因為其他人在此查詢之前先排定優先順序。
-
ROWSETEVENT_TYPE_SCOPESTATISTICS 事件會提供您從 IRowsetPrioritization::GetScopeStatistics 方法呼叫所提供的相同資訊,但透過推送機制,如下所示:
- 如果優先順序 API 已用來要求非預設優先順序層級,以及非零的統計數據事件頻率,就會發生此事件。
- 只有當統計數據實際變更,而且 IRowsetPrioritization 中指定的間隔已經過去時,才會發生事件(間隔不保證事件的頻率)。
- 如果先前已引發非零事件,則此事件保證將觸發「反彈為零」狀態(剩餘項目數量為零,剩餘修改數量為零)。
- 如果佇列在統計數據事件頻率之前清空,索引器可能會處理專案而不傳送此事件。
其他資源
請參閱下列與優先順序和資料列集相關的資源:
相關主題
-
適用於 Windows 7 搜尋的 新功能
-
在 Windows 7 中的 Windows Shell 程式庫