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


C# ITransactionalStorage.Batch方法代码示例

本文整理汇总了C#中ITransactionalStorage.Batch方法的典型用法代码示例。如果您正苦于以下问题:C# ITransactionalStorage.Batch方法的具体用法?C# ITransactionalStorage.Batch怎么用?C# ITransactionalStorage.Batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITransactionalStorage的用法示例。


在下文中一共展示了ITransactionalStorage.Batch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: when_there_are_multiple_map_results_for_multiple_indexes

		private static void when_there_are_multiple_map_results_for_multiple_indexes(ITransactionalStorage transactionalStorage)
		{
			transactionalStorage.Initialize(new DummyUuidGenerator());

			transactionalStorage.Batch(accessor =>
			{
				accessor.Indexing.AddIndex("a",true);
				accessor.Indexing.AddIndex("b", true);
				accessor.Indexing.AddIndex("c", true);

				accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
			});

			transactionalStorage.Batch(actionsAccessor =>
			{
				Assert.True(actionsAccessor.Staleness.IsReduceStale("a"));
				Assert.True(actionsAccessor.Staleness.IsReduceStale("b"));
				Assert.True(actionsAccessor.Staleness.IsReduceStale("c"));
			});
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:25,代码来源:ReduceStaleness.cs

示例2: StorageStream

		protected StorageStream(ITransactionalStorage transactionalStorage, string fileName,
								StorageStreamAccess storageStreamAccess,
								RavenJObject metadata, IndexStorage indexStorage, StorageOperationsTask operations)
		{
			TransactionalStorage = transactionalStorage;
			StorageStreamAccess = storageStreamAccess;
			Name = fileName;

			switch (storageStreamAccess)
			{
				case StorageStreamAccess.Read:
					TransactionalStorage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
					if (fileHeader.TotalSize == null)
					{
						throw new FileNotFoundException("File is not uploaded yet");
					}
					Metadata = fileHeader.Metadata;
					Seek(0, SeekOrigin.Begin);
					break;
				case StorageStreamAccess.CreateAndWrite:
					TransactionalStorage.Batch(accessor =>
					{
						operations.IndicateFileToDelete(fileName);
						accessor.PutFile(fileName, null, metadata);
						indexStorage.Index(fileName, metadata);
					});
					Metadata = metadata;
					break;
				default:
					throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
			}
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:32,代码来源:StorageStream.cs

示例3: ReadIndexesFromCatalog

		private void ReadIndexesFromCatalog(IEnumerable<AbstractViewGenerator> compiledGenerators, ITransactionalStorage transactionalStorage)
		{
			foreach (var generator in compiledGenerators)
			{
				var copy = generator;
				var displayNameAtt = TypeDescriptor.GetAttributes(copy)
					.OfType<DisplayNameAttribute>()
					.FirstOrDefault();

				var name = displayNameAtt != null ? displayNameAtt.DisplayName : copy.GetType().Name;

				transactionalStorage.Batch(actions =>
				{
					if (actions.Indexing.GetIndexesStats().Any(x => x.Name == name))
						return;

					actions.Indexing.AddIndex(name, copy.ReduceDefinition != null);
				});

				var indexDefinition = new IndexDefinition
				{
					Name = name,
					Map = "Compiled map function: " + generator.GetType().AssemblyQualifiedName,
					// need to supply this so the index storage will create map/reduce index
					Reduce = generator.ReduceDefinition == null ? null : "Compiled reduce function: " + generator.GetType().AssemblyQualifiedName,
					Indexes = generator.Indexes,
					Stores = generator.Stores,
					IsCompiled = true
				};
				indexCache.AddOrUpdate(name, copy, (s, viewGenerator) => copy);
				indexDefinitions.AddOrUpdate(name, indexDefinition, (s1, definition) => indexDefinition);
			}
		}
开发者ID:remcoros,项目名称:ravendb,代码行数:33,代码来源:IndexDefinitionStorage.cs

示例4: IndexDefinitionStorage

		public IndexDefinitionStorage(
			ITransactionalStorage  transactionalStorage,
			string path, 
			IEnumerable<AbstractViewGenerator> compiledGenerators, 
			AbstractDynamicCompilationExtension[] extensions)
		{
			this.extensions = extensions;// this is used later in the ctor, so it must appears first
			this.path = Path.Combine(path, IndexDefDir);

			if (Directory.Exists(this.path) == false)
				Directory.CreateDirectory(this.path);

            this.extensions = extensions;
            foreach (var index in Directory.GetFiles(this.path, "*.index"))
			{
				try
				{
					AddAndCompileIndex(
						MonoHttpUtility.UrlDecode(Path.GetFileNameWithoutExtension(index)),
						JsonConvert.DeserializeObject<IndexDefinition>(File.ReadAllText(index), new JsonEnumConverter())
						);
				}
				catch (Exception e)
				{
					logger.Warn("Could not compile index " + index + ", skipping bad index", e);
				}
			}

            //compiled view generators always overwrite dynamic views
		    foreach (var generator in compiledGenerators)
		    {
		        var copy = generator;
		        var displayNameAtt = TypeDescriptor.GetAttributes(copy)
		            .OfType<DisplayNameAttribute>()
		            .FirstOrDefault();

		        var name = displayNameAtt != null ? displayNameAtt.DisplayName : copy.GetType().Name;

                transactionalStorage.Batch(actions =>
                {
                    if (actions.Indexing.GetIndexesStats().Any(x => x.Name == name))
                        return;

                    actions.Indexing.AddIndex(name);
                });

		        var indexDefinition = new IndexDefinition
		        {
                    Map = "Compiled map function: " + generator.GetType().AssemblyQualifiedName,
                    // need to supply this so the index storage will create map/reduce index
                    Reduce = generator.ReduceDefinition == null ? null : "Compiled reduce function: " + generator.GetType().AssemblyQualifiedName,
		            Indexes = generator.Indexes,
		            Stores = generator.Stores,
                    IsCompiled = true
		        };
		        indexCache.AddOrUpdate(name, copy, (s, viewGenerator) => copy);
		        indexDefinitions.AddOrUpdate(name, indexDefinition, (s1, definition) => indexDefinition);
		    }
		}
开发者ID:ajaishankar,项目名称:ravendb,代码行数:59,代码来源:IndexDefinitionStorage.cs

示例5: GetOrDefault

        public static SynchronizationConfig GetOrDefault(ITransactionalStorage storage)
        {
            SynchronizationConfig result = null;

            storage.Batch(accessor => result = GetOrDefault(accessor));

            return result ?? new SynchronizationConfig();
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:SynchronizationConfigAccessor.cs

示例6: TimeoutExceeded

        public bool TimeoutExceeded(string fileName, ITransactionalStorage storage)
        {
            var result = false;

            storage.Batch(accessor => result = TimeoutExceeded(fileName, accessor));

            return result;
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:8,代码来源:FileLockManager.cs

示例7: StorageStream

        protected StorageStream(RavenFileSystem fileSystem, ITransactionalStorage storage, string fileName, RavenJObject metadata, StorageStreamAccess storageStreamAccess)
        {
            this.fileSystem = fileSystem;
            this.storage = storage;

            StorageStreamAccess = storageStreamAccess;
            Name = fileName;

            switch (storageStreamAccess)
            {
                case StorageStreamAccess.Read:
                    storage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
                    if (fileHeader.TotalSize == null)
                    {
                        throw new FileNotFoundException("File is not uploaded yet");
                    }
                    Metadata = fileHeader.Metadata;
                    Seek(0, SeekOrigin.Begin);
                    break;
                case StorageStreamAccess.CreateAndWrite:

                    if (this.fileSystem == null)
                        throw new ArgumentNullException("fileSystem");

                    storage.Batch(accessor =>
                    {
                        using (fileSystem.DisableAllTriggersForCurrentThread())
                        {
                            fileSystem.Files.IndicateFileToDelete(fileName, null);
                        }

                        var putResult = accessor.PutFile(fileName, null, metadata);
                        fileSystem.Search.Index(fileName, metadata, putResult.Etag);
                    });
                    Metadata = metadata;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:40,代码来源:StorageStream.cs

示例8: SynchronizationWorkItem

		protected SynchronizationWorkItem(string fileName, string sourceServerUrl, ITransactionalStorage storage)
		{
			Storage = storage;
            FileName = fileName;

			FileAndPagesInformation fileAndPages = null;
			Storage.Batch(accessor => fileAndPages = accessor.GetFile(fileName, 0, 0));
			FileMetadata = fileAndPages.Metadata;
			FileSystemInfo = new FileSystemInfo
			{
				Id = Storage.Id,
				Url = sourceServerUrl
			};

			conflictDetector = new ConflictDetector();
			conflictResolver = new ConflictResolver(null, null);
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:17,代码来源:SynchronizationWorkItem.cs

示例9: when_there_are_updates_to_map_reduce_results

		private static void when_there_are_updates_to_map_reduce_results(ITransactionalStorage transactionalStorage)
		{
			var dummyUuidGenerator = new DummyUuidGenerator();
			transactionalStorage.Initialize(dummyUuidGenerator);
			Guid a = Guid.Empty;
			Guid b = Guid.Empty;
			Guid c = Guid.Empty;
			transactionalStorage.Batch(accessor =>
			{
				accessor.Indexing.AddIndex("a", true);
				accessor.Indexing.AddIndex("b", true);
				accessor.Indexing.AddIndex("c", true);

				accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				a = dummyUuidGenerator.CreateSequentialUuid();
				accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				b = dummyUuidGenerator.CreateSequentialUuid();
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
				c = dummyUuidGenerator.CreateSequentialUuid();
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
			});

			transactionalStorage.Batch(actionsAccessor =>
			{
				Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("a", a).Count());
				Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("b", b).Count());
				Assert.Equal(1, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("c", c).Count());
			});
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:31,代码来源:ReduceStaleness.cs

示例10: when_there_are_multiple_map_results_and_we_ask_for_results

		private static void when_there_are_multiple_map_results_and_we_ask_for_results(ITransactionalStorage transactionalStorage)
		{
			transactionalStorage.Initialize(new DummyUuidGenerator());

			transactionalStorage.Batch(accessor =>
			{
				accessor.Indexing.AddIndex("a", true);
				accessor.Indexing.AddIndex("b", true);
				accessor.Indexing.AddIndex("c", true);

				accessor.MappedResults.PutMappedResult("a", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("a", "a/2", "a", new RavenJObject(), MapReduceIndex.ComputeHash("a", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("b", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("b", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
				accessor.MappedResults.PutMappedResult("c", "a/1", "a", new RavenJObject(), MapReduceIndex.ComputeHash("c", "a"));
			});

			transactionalStorage.Batch(actionsAccessor =>
			{
				Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("a", Guid.Empty).Count());
				Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("b", Guid.Empty).Count());
				Assert.Equal(2, actionsAccessor.MappedResults.GetMappedResultsReduceKeysAfter("c", Guid.Empty).Count());
			});
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:25,代码来源:ReduceStaleness.cs


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