本文整理汇总了C#中Application.CreateQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Application.CreateQuery方法的具体用法?C# Application.CreateQuery怎么用?C# Application.CreateQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application.CreateQuery方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateQuery
/// <summary>
/// Creates and binds a query with a single input stream.
/// </summary>
private static Query CreateQuery(Application application, CepStream<EventType> streamDefinition, Uri inputAddress, Uri outputAddress)
{
QueryTemplate template = application.CreateQueryTemplate("QueryTemplate", null, streamDefinition);
QueryBinder binder = new QueryBinder(template);
InputAdapter inputAdapter = application.CreateInputAdapter<WcfInputAdapterFactory>("InputAdapter", null);
binder.BindProducer("Input", inputAdapter, inputAddress, EventShape.Point);
OutputAdapter outputAdapter = application.CreateOutputAdapter<WcfOutputAdapterFactory>("OutputAdapter", null);
binder.AddConsumer("Output", outputAdapter, outputAddress, EventShape.Point, StreamEventOrder.FullyOrdered);
Query query = application.CreateQuery("Query", null, binder);
return query;
}
示例2: CreateQuery
private static Query CreateQuery(Application application, CepStream<BrandQuote> streamDefinition, BrandQuoteInputConfig inputConfig, BrandQuoteOutputConfig outputConfig)
{
var template = application.CreateQueryTemplate("QueryTemplate", null, streamDefinition);
var binder = new QueryBinder(template);
var inputAdapter = application.CreateInputAdapter<BrandQuoteInputAdapterFactory>("InputAdapter", null);
binder.BindProducer("Input", inputAdapter, inputConfig, EventShape.Point);
var outputAdapter = application.CreateOutputAdapter<BrandQuoteOutputAdapterFactory>("OutputAdapter", null);
binder.AddConsumer("Output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.FullyOrdered);
var query = application.CreateQuery("Query", null, binder);
return query;
}
示例3: createUserFilterExampleQuery
/// <summary>
/// Example of using a user-defined filter
/// </summary>
/// <param name="application"></param>
/// <param name="inputConfig"></param>
/// <param name="outputConfig"></param>
/// <param name="inputAdapter"></param>
/// <param name="outputAdapter"></param>
/// <returns></returns>
private static Query createUserFilterExampleQuery(Application application, StockQuoteInputConfig inputConfig, StockQuoteOutputConfig outputConfig, InputAdapter inputAdapter, OutputAdapter outputAdapter)
{
var input = CepStream<StockQuote>.Create("input");
var filteredCepStream = from e in input
where UserDefinedFilter(e.FieldID)
select e;
var queryTemplate = application.CreateQueryTemplate("userFilterExampleTemplate", "Description...", filteredCepStream);
var queryBinder = new QueryBinder(queryTemplate);
queryBinder.BindProducer<StockQuote>("input", inputAdapter, inputConfig, EventShape.Point);
queryBinder.AddConsumer<StockQuote>("output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.ChainOrdered);
var query = application.CreateQuery("userFilterExampleQuery", "Description...", queryBinder);
return query;
}
示例4: createStandardDeviationExampleQuery
/// <summary>
/// Example of using a user-defined aggregate
/// </summary>
/// <param name="application"></param>
/// <param name="inputConfig"></param>
/// <param name="outputConfig"></param>
/// <param name="inputAdapter"></param>
/// <param name="outputAdapter"></param>
/// <returns></returns>
private static Query createStandardDeviationExampleQuery(Application application, StockQuoteInputConfig inputConfig, StockQuoteOutputConfig outputConfig, InputAdapter inputAdapter, OutputAdapter outputAdapter)
{
var input = CepStream<StockQuote>.Create("input");
var stddevCepStream = from w in input.Where(e => e.FieldID == "Close")
.HoppingWindow(TimeSpan.FromDays(7), TimeSpan.FromDays(1), HoppingWindowOutputPolicy.ClipToWindowEnd)
select new StockQuote()
{
StockID = "ERIC",
FieldID = "7-day Stddev",
Value = w.StandardDeviation()
};
var queryTemplate = application.CreateQueryTemplate("standardDeviationExampleTemplate", "Description...", stddevCepStream);
var queryBinder = new QueryBinder(queryTemplate);
queryBinder.BindProducer<StockQuote>("input", inputAdapter, inputConfig, EventShape.Point);
queryBinder.AddConsumer<StockQuote>("output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.ChainOrdered);
var query = application.CreateQuery("standardDeviationExampleQuery", "Description...", queryBinder);
return query;
}
示例5: createGroupApplyExampleQuery
/// <summary>
/// Example of a grouping and calculation of averages for the groups
/// </summary>
/// <param name="application"></param>
/// <param name="inputConfig"></param>
/// <param name="outputConfig"></param>
/// <param name="inputAdapter"></param>
/// <param name="outputAdapter"></param>
/// <returns></returns>
private static Query createGroupApplyExampleQuery(Application application, StockQuoteInputConfig inputConfig, StockQuoteOutputConfig outputConfig, InputAdapter inputAdapter, OutputAdapter outputAdapter)
{
var input = CepStream<StockQuote>.Create("input");
var ericUSDGroupCepStream = from e in input
group e by e.FieldID into eGroup
from w in eGroup.HoppingWindow(TimeSpan.FromDays(7), TimeSpan.FromDays(1), HoppingWindowOutputPolicy.ClipToWindowEnd)
select new StockQuote()
{
StockID = "ERIC 7-day avg",
FieldID = eGroup.Key,
Value = w.Avg(e => e.Value)
};
var queryTemplate = application.CreateQueryTemplate("groupApplyExampleTemplate", "Description...", ericUSDGroupCepStream);
var queryBinder = new QueryBinder(queryTemplate);
queryBinder.BindProducer<StockQuote>("input", inputAdapter, inputConfig, EventShape.Point);
queryBinder.AddConsumer<StockQuote>("output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.ChainOrdered);
var query = application.CreateQuery("groupApplyExampleQuery", "Description...", queryBinder);
return query;
}
示例6: createCrossJoinExampleQuery
/// <summary>
/// Compare USD and SEK stock prices using given exchange rate. Example of a cross join.
/// </summary>
/// <param name="application"></param>
/// <param name="ericUSDConfig"></param>
/// <param name="ericSEKConfig"></param>
/// <param name="USDSEKConfig"></param>
/// <param name="outputConfig"></param>
/// <param name="inputAdapter"></param>
/// <param name="outputAdapter"></param>
/// <returns></returns>
private static Query createCrossJoinExampleQuery(Application application, StockQuoteInputConfig ericUSDConfig, StockQuoteInputConfig ericSEKConfig, StockQuoteInputConfig USDSEKConfig, StockQuoteOutputConfig outputConfig, InputAdapter inputAdapter, OutputAdapter outputAdapter)
{
var ericUSDStream = CepStream<StockQuote>.Create("ericUSDStream");
var ericSEKStream = CepStream<StockQuote>.Create("ericSEKStream");
var USDSEKStream = CepStream<StockQuote>.Create("USDSEKStream");
var ericRecalcCepStream = from eUSD in ericUSDStream
from eXch in USDSEKStream // Cross join
where eUSD.FieldID == "Close"
select new StockQuote()
{
StockID = "ERIC-Recalc",
FieldID = "Close",
Value = eUSD.Value * eXch.Value // Convert ERIC USD quote to SEK
};
var ericCompareCepStream = from eRecalc in ericRecalcCepStream
from eSEK in ericSEKStream
where eSEK.FieldID == "Close"
select new StockQuote()
{
StockID = "ERIC-Compare",
FieldID = "Diff",
Value = eSEK.Value - eRecalc.Value
};
var queryTemplate = application.CreateQueryTemplate("ericCompareTemplate", "Description...", ericCompareCepStream);
var queryBinder = new QueryBinder(queryTemplate);
queryBinder.BindProducer<StockQuote>("ericUSDStream", inputAdapter, ericUSDConfig, EventShape.Point);
queryBinder.BindProducer<StockQuote>("ericSEKStream", inputAdapter, ericSEKConfig, EventShape.Point);
queryBinder.BindProducer<StockQuote>("USDSEKStream", inputAdapter, USDSEKConfig, EventShape.Point);
queryBinder.AddConsumer<StockQuote>("output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.ChainOrdered);
var query = application.CreateQuery("ericCompareQuery", "Description...", queryBinder);
return query;
}
示例7: createBigLooserExampleQuery
/// <summary>
/// Example of detecting when stock price falls more than 10% in 7 days
/// </summary>
/// <param name="application"></param>
/// <param name="inputConfig"></param>
/// <param name="outputConfig"></param>
/// <param name="inputAdapter"></param>
/// <param name="outputAdapter"></param>
/// <returns></returns>
private static Query createBigLooserExampleQuery(Application application, StockQuoteInputConfig inputConfig, StockQuoteOutputConfig outputConfig, InputAdapter inputAdapter, OutputAdapter outputAdapter)
{
var input = CepStream<StockQuote>.Create("input");
var bigLooserCepStream = (from e1 in input
from e2 in input.ShiftEventTime(e => e.StartTime.AddDays(7))
where e1.FieldID == "Close" && e2.FieldID == "Close"
select new StockQuote()
{
StockID = "ERIC > 10% drop",
FieldID = "Close",
Value = (e1.Value - e2.Value) / e2.Value * 100
}).Where(e => e.Value < -10);
var queryTemplate = application.CreateQueryTemplate("bigLooserExampleTemplate", "Description...", bigLooserCepStream);
var queryBinder = new QueryBinder(queryTemplate);
queryBinder.BindProducer<StockQuote>("input", inputAdapter, inputConfig, EventShape.Point);
queryBinder.AddConsumer<StockQuote>("output", outputAdapter, outputConfig, EventShape.Point, StreamEventOrder.ChainOrdered);
var query = application.CreateQuery("bigLooserExampleQuery", "Description...", queryBinder);
return query;
}