0

在 StreamInsight 中,许多示例解决了流的 count、sum、filter 的 linq 用法。

var cepStream = enumerable.ToPointStream(application, e =>  PointEvent<Car>.CreateInsert(new DateTimeOffset(e.TimeStamp, TimeSpan.Zero), e), AdvanceTimeSettings.IncreasingStartTime);

var step1 = from e in cepStream
                    where e.Color == "RedCar"
                    select e;

定义提取在一定时间长度内发生的记录的查询有一些困难。例如step1存储的是“RedCar”的积分事件,但是如何提取10分钟内连续发生的两个“RedCar”事件呢?

真的被困在这里,非常感谢任何帮助!

4

1 回答 1

1

To determine if 2 events occur within a certain time of each other, we have to manipulate their event lifetimes so that they are both valid at the same time. We can determine if 2 events are valid at the same time by using a join.

  1. Shift the event time for step1 as step2.

    var step2 = from e in step1.ShiftEventTime(e => TimeSpan.FromMinutes(10)) select e;

  2. Alter the event duration of step1 as step3.

    var step3 = from e in step1.AlterEventDuration(e => TimeSpan.FromMinutes(10)) select e;

  3. Join step2 and step3 as step4.

    var step4 = from l in step2 join r in step3 on l equals r select l;

Does that help?

于 2013-03-23T17:50:06.407 回答