所以我对Stream Insight相当新,这可能是一个相当基本的问题,但似乎不支持按事件类型过滤查询(见下文),那么应该如何做呢?
为了充实我的问题,这是我的CepStream ......
var stockStream = CepStream<MarketDataPoint>.Create(appName, typeof(MarketdataPointInputAdapterFactory), new MarketDataAdapterConfig(), EventShape.Point);
..这是我的询问......
var patternResult = from w in stockStream.Where(x => x is FxSpot)
.AlterEventDuration(e => TimeSpan.FromMinutes(1))
.SnapshotWindow(SnapshotWindowOutputPolicy.Clip)
select new MarketDataPointEvent() {Price = w.Max(e => e.Price)};
...运行时产生此异常: Microsoft Complex Event Processing LINQ Provider不支持以下表达式:(x是FxSpot)
据我了解,我可以创建多个适配器,而不是有效地执行过滤器,但这似乎不应该“应该”完成。
非常感谢任何建议!
马特
答案 0 :(得分:1)
我会尝试从is运算符继续进行类型比较。这是一个使用LINQPad的示例,我强烈建议您使用它。在这种情况下,过滤器由库存完成。使用
自动插入CTIAdvanceTimeSettings.IncreasingStartTime
样品
void Main()
{
var marketReadings = new []
{
new MarketDataPoint() { Stock = "MSFT", Value = 30.0, Timestamp = DateTime.Parse("11/19/2012 4:10:00 PM") },
new MarketDataPoint() { Stock = "MSFT", Value = 30.1, Timestamp = DateTime.Parse("11/19/2012 4:11:00 PM") },
new MarketDataPoint() { Stock = "GOOG", Value = 667.97, Timestamp = DateTime.Parse("11/19/2012 4:12:00 PM") },
new MarketDataPoint() { Stock = "GOOG", Value = 667.51, Timestamp = DateTime.Parse("11/19/2012 4:12:00 PM") },
};
var stockStream = marketReadings.ToPointStream(Application, e=> PointEvent.CreateInsert(e.Timestamp,e),AdvanceTimeSettings.IncreasingStartTime);
var patternResult = from w in stockStream.Where(x => x.Stock == "MSFT")
.AlterEventDuration(e => TimeSpan.FromMinutes(1))
.SnapshotWindow(SnapshotWindowOutputPolicy.Clip)
select new {Price = w.Max(e => e.Value)} ;
patternResult.Dump();
}
public class MarketDataPoint
{
public string Stock { get; set; }
public double Value { get; set; }
public DateTime Timestamp { get;set;}
}
}
答案 1 :(得分:0)
您定义的有效负载类型是MarketDataPoint。这根据Event Structure定义了事件的模式: “StreamInsight服务器中的事件是一个有序的字段列表,而不是.NET结构,它不会在其字段上强加订单。”
您要完成的工作的潜在解决方法是在MarketDataPoint中包含构成FxSpot的所有必需字段。然后向MarketDataPoint添加一个额外的属性,以定义它是什么类型的MarketDataPoint。