本文整理汇总了C#中RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting方法的典型用法代码示例。如果您正苦于以下问题:C# RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting方法的具体用法?C# RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting怎么用?C# RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RavenJArray
的用法示例。
在下文中一共展示了RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteReduce
private void ExecuteReduce(IEnumerable<IGrouping<dynamic, object>> groupedByReduceKey, WriteBatch writeBatch)
{
foreach (var grouping in groupedByReduceKey)
{
string reduceKey = grouping.Key;
Slice key = "results/" + _name + "/" + reduceKey;
var groupedResults = GetItemsToReduce(reduceKey, key, grouping);
var robustEnumerator = new RobustEnumerator2(_aggregationEngine.CancellationToken, 50)
{
OnError = (exception, o) =>
Log.WarnException("Could not process reduce for aggregation " + _name + Environment.NewLine + o,
exception)
};
var reduceResults =
robustEnumerator.RobustEnumeration(groupedResults.GetEnumerator(), _generator.ReduceDefinition).ToArray();
RavenJToken finalResult;
switch (reduceResults.Length)
{
case 0:
Log.Warn("FLYING PIGS!!! Could not find any results for a reduce on key {0} for aggregator {1}. Should not happen", reduceKey, _name);
finalResult = new RavenJObject {{"Error", "Invalid reduce result was generated"}};
break;
case 1:
finalResult = RavenJObject.FromObject(reduceResults[0]);
break;
default:
finalResult = new RavenJArray(reduceResults.Select(RavenJObject.FromObject));
break;
}
finalResult.EnsureCannotBeChangeAndEnableSnapshotting();
_cache.Set(reduceKey, finalResult);
writeBatch.Put(key, AggregationEngine.RavenJTokenToStream(finalResult));
}
}