Take(TPayload) 方法 (CepOrderedStream(TPayload), UInt32)

假設有已排序的資料流,請從每個視窗取出給定的事件數目。

命名空間:  Microsoft.ComplexEventProcessing.Linq
組件:  Microsoft.ComplexEventProcessing (在 Microsoft.ComplexEventProcessing.dll 中)

語法

public static CepStream<TPayload> Take<TPayload>(
    this CepOrderedStream<TPayload> source,
    uint numberOfElements
)

型別參數

  • TPayload
    輸入事件的裝載類型。

參數

傳回值

型別:Microsoft.ComplexEventProcessing.Linq. . :: . .CepStream< (Of < ( <'TPayload> ) > ) >
包含從每個視窗取出之給定事件數目的資料流。

使用注意事項

在 Visual Basic 及 C# 中,您可以在任何型別 CepOrderedStream< (Of < ( <'TPayload> ) > ) > 的物件上將這個方法做為執行個體方法呼叫。使用執行個體方法語法呼叫這個方法時,請省略第一個參數。如需詳細資訊,請參閱 https://msdn.microsoft.com/zh-tw/library/bb384936(v=sql.105)https://msdn.microsoft.com/zh-tw/library/bb383977(v=sql.105)

備註

如需詳細資訊,請參閱<TopK>。

範例

下列範例會從針對輸入資料流 inputStream 所定義的每個快照集視窗中取得前五個事件並產生新的事件資料流。每一個視窗中的事件都會依照裝載欄位 e.f 中值的遞增順序並結合裝載欄位 e.i 中值的遞減順序來排序。

// Assuming the following input event type for inputStream: 
public class MyPayload 
{
  public int f; 
  public int i; 
}

var topfive = (from window in inputStream.Snapshot(SnapshotWindowOutputPolicy.Clip)
               from e in window
               orderby e.f ascending, e.i descending
               select e).Take(5);

請參閱

參考

CepStream 類別

Take 多載

Microsoft.ComplexEventProcessing.Linq 命名空間