当前位置: 首页>>代码示例>>C#>>正文


C# RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting方法代码示例

本文整理汇总了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));
			}
		}
开发者ID:mattwarren,项目名称:temp.raven.storage,代码行数:37,代码来源:Aggregator.cs


注:本文中的RavenJArray.EnsureCannotBeChangeAndEnableSnapshotting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。