CepStream.Take<TPayload> Method (CepOrderedStream<TPayload>, UInt32)

Given an ordered stream, takes a given number of events from each window.

Namespace:  Microsoft.ComplexEventProcessing.Linq
Assembly:  Microsoft.ComplexEventProcessing (in Microsoft.ComplexEventProcessing.dll)

Syntax

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

Type Parameters

  • TPayload
    Payload type of input events.

Parameters

  • numberOfElements
    Type: System.UInt32
    Number of elements to take from each window.

Return Value

Type: Microsoft.ComplexEventProcessing.Linq.CepStream<TPayload>
A stream with a given number of events taken from each window.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type CepOrderedStream<TPayload>. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=sql.105) or https://msdn.microsoft.com/en-us/library/bb383977(v=sql.105).

Remarks

For more information, see TopK.

Examples

The following example takes the top five events from each snapshot window defined for the input stream inputStream and generates a new event stream. The events in each window are ordered in the ascending order of values in the payload fields e.f combined with the descending order of values in the payload field 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);

See Also

Reference

CepStream Class

Take Overload

Microsoft.ComplexEventProcessing.Linq Namespace