共用方式為


在 Windows 7 中編制優先順序和資料列集事件的索引

本主題概述 Windows 7 的索引編制優先順序和資料列集事件的簡介。

本主題的組織方式如下:

編制優先順序和資料列集事件的索引

在 Windows 7 和更新版本中,有任何特定查詢內容的優先順序堆疊,用戶端可以要求該查詢中使用的範圍優先于一般專案的優先順序。

此優先順序堆疊具有下列特性:

  • 堆疊中的專案可以有前景、高或低優先順序:
    • 前景:略過輪詢邏輯,且索引作業會如機器允許的速度一樣快速進行。
    • :已使用輪詢要求優先順序。
    • :已要求優先順序,而不是代價是堆疊上其他範圍,而是高於非優先順序的索引編制。
  • 任何高或前景優先順序的要求都會自動將要求查詢提升到堆疊頂端。
  • 只有堆疊頂端的專案可以有前景優先順序。
  • 優先順序降低的前景優先順序查詢會收到事件,通知它已遺失前景優先順序,且已變成高優先順序與輪詢。

優先順序堆疊會設定索引子中處理之專案的整體優先順序,如下所示:

  • 高優先順序通知沒有輪詢,通常只會針對少數專案傳送。 例如,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 );
};

資料列集優先順序的運作方式如下:

  1. 在索引子資料列集上使用IUnknown::QueryInterface 方法取得IRowsetPrioritizationDBPROP_ENABLEROWSETEVENTS在執行查詢之前,必須先使用 OLE DB ICommandProperties::SetProperties方法設定為TRUE,才能使用資料列集優先順序。
  2. IRowsetPrioritization::SetScopePriority 會設定屬於查詢之範圍的優先順序,並在查詢範圍內有未完成的檔編制索引時引發範圍統計資料事件的間隔。 如果優先順序層級設定為預設值,就會引發此事件。
  3. 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 7 中的 Windows Shell 程式庫