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


C# Indexing.WorkContext类代码示例

本文整理汇总了C#中Raven.Database.Indexing.WorkContext的典型用法代码示例。如果您正苦于以下问题:C# WorkContext类的具体用法?C# WorkContext怎么用?C# WorkContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WorkContext类属于Raven.Database.Indexing命名空间,在下文中一共展示了WorkContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

 public override void Execute(WorkContext context)
 {
     foreach (var indexName in context.IndexDefinitionStorage.IndexNames)
     {
         context.IndexStorage.RemoveFromIndex(indexName, Keys, context);
     }
 }
开发者ID:kenegozi,项目名称:ravendb,代码行数:7,代码来源:RemoveFromIndexTask.cs

示例2: PrefetchingBehavior

        public PrefetchingBehavior(PrefetchingUser prefetchingUser, 
            WorkContext context, 
            BaseBatchSizeAutoTuner autoTuner, 
            string prefetchingUserDescription, 
            bool isDefault = false,
            Func<int> getPrefetchintBehavioursCount = null,
            Func<PrefetchingSummary> getPrefetcherSummary = null)
        {
            this.context = context;
            this.autoTuner = autoTuner;
            PrefetchingUser = prefetchingUser;
            this.userDescription = prefetchingUserDescription;
            this.IsDefault = isDefault;
            this.getPrefetchintBehavioursCount = getPrefetchintBehavioursCount ?? (() => 1);
            this.getPrefetcherSummary = getPrefetcherSummary ?? GetSummary;
            MemoryStatistics.RegisterLowMemoryHandler(this);
            LastTimeUsed = DateTime.MinValue;

            ingestMeter = context.MetricsCounters.DbMetrics.Meter("metrics",
                "ingest/sec", "In memory documents held by this prefetcher", TimeUnit.Seconds);
            returnedDocsMeter = context.MetricsCounters.DbMetrics.Meter("metrics",
                  "returned docs/sec", "Documents being served by this prefetcher", TimeUnit.Seconds);

            if (isDefault)
            {
                context.Database.TransactionalStorage.Batch(accessor =>
                {
                    recentEtag = accessor.Staleness.GetMostRecentDocumentEtag();
                });
            }
        }
开发者ID:hero106wen,项目名称:ravendb,代码行数:31,代码来源:PrefetchingBehavior.cs

示例3: Execute

		public override void Execute(WorkContext context)
		{
			if (ReduceKeys.Length == 0)
				return;

			var viewGenerator = context.IndexDefinitionStorage.GetViewGenerator(Index);
			if (viewGenerator == null)
				return; // deleted view?
			
			context.TransactionaStorage.Batch(actions =>
			{
				log.Debug("Starting to read {0} reduce keys for index {1}", ReduceKeys.Length, Index);

				var itemsToFind = ReduceKeys
					.Select(reduceKey => new GetMappedResultsParams(Index, reduceKey, MapReduceIndex.ComputeHash(Index, reduceKey)))
					.ToArray();
				var mappedResults = actions.MappedResults.GetMappedResults(itemsToFind)
					.Select(JsonToExpando.Convert);
				
				var sp = Stopwatch.StartNew();

				var results = mappedResults.ToArray();

				log.Debug("Read {0} reduce keys in {1} with {2} results for index {3}", ReduceKeys.Length, sp.Elapsed, results.Length, Index);
				sp = Stopwatch.StartNew();
				context.IndexStorage.Reduce(Index, viewGenerator, results, context, actions, ReduceKeys);
				log.Debug("Indexed {0} reduce keys in {1} with {2} results for index {3}", ReduceKeys.Length, sp.Elapsed,
				                results.Length, Index);

			});
		}
开发者ID:alwin,项目名称:ravendb,代码行数:31,代码来源:ReduceTask.cs

示例4: SuggestionQueryIndexExtension

		public SuggestionQueryIndexExtension(
			WorkContext workContext,
			string key,
			StringDistance distanceType,
			bool isRunInMemory,
			string field,
			float accuracy)
		{
			this.workContext = workContext;
			this.key = key;
			this.field = field;

			if (isRunInMemory)
			{
				directory = new RAMDirectory();
			}
			else
			{
				directory = FSDirectory.Open(new DirectoryInfo(key));
			}

			this.spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(directory, null);
			this.spellChecker.SetAccuracy(accuracy);
			this.spellChecker.setStringDistance(distanceType);
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:25,代码来源:SuggestionQueryIndexExtension.cs

示例5: BaseBatchSizeAutoTuner

 protected BaseBatchSizeAutoTuner(WorkContext context)
 {
     this.context = context;
     NumberOfItemsToIndexInSingleBatch = InitialNumberOfItems;
     currentlyUsedBatchSizes = new ConcurrentDictionary<Guid, long>();
     memoryLimitForIndexingInBytes = context.Configuration.MemoryLimitForIndexingInMB * 1024 * 1024;
 }
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:BaseBatchSizeAutoTuner.cs

示例6: PrefetchingBehavior

		public PrefetchingBehavior(PrefetchingUser prefetchingUser, WorkContext context, BaseBatchSizeAutoTuner autoTuner)
		{
			this.context = context;
			this.autoTuner = autoTuner;
			PrefetchingUser = prefetchingUser;
			MemoryStatistics.RegisterLowMemoryHandler(this);
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:7,代码来源:PrefetchingBehavior.cs

示例7: AbstractIndexingExecuter

		protected AbstractIndexingExecuter(
			ITransactionalStorage transactionalStorage, WorkContext context, TaskScheduler scheduler)
		{
			this.transactionalStorage = transactionalStorage;
			this.context = context;
			this.scheduler = scheduler;
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:7,代码来源:AbstractIndexingExecuter.cs

示例8: MapReduceIndex

 public MapReduceIndex(Directory directory, int id, IndexDefinition indexDefinition,
                       AbstractViewGenerator viewGenerator, WorkContext context)
     : base(directory, id, indexDefinition, viewGenerator, context)
 {
     jsonSerializer = JsonExtensions.CreateDefaultJsonSerializer();
     jsonSerializer.Converters = MapReduceConverters;
 }
开发者ID:VPashkov,项目名称:ravendb,代码行数:7,代码来源:MapReduceIndex.cs

示例9: Execute

        public override void Execute(WorkContext context)
        {
            if (ReduceKeys.Length == 0)
                return;

            var viewGenerator = context.IndexDefinitionStorage.GetViewGenerator(Index);
            if (viewGenerator == null)
                return; // deleted view?

            context.TransactionaStorage.Batch(actions =>
            {
                IEnumerable<object> mappedResults = null;
                foreach (var reduceKey in ReduceKeys)
                {
                    IEnumerable<object> enumerable = actions.MappedResults.GetMappedResults(Index, reduceKey, MapReduceIndex.ComputeHash(Index, reduceKey))
                        .Select(JsonToExpando.Convert);

                    if (mappedResults == null)
                        mappedResults = enumerable;
                    else
                        mappedResults = mappedResults.Concat(enumerable);
                }

                context.IndexStorage.Reduce(Index, viewGenerator, mappedResults, context, actions, ReduceKeys);
            });
        }
开发者ID:vinone,项目名称:ravendb,代码行数:26,代码来源:ReduceTask.cs

示例10: AbstractIndexingExecuter

        protected AbstractIndexingExecuter(WorkContext context, IndexReplacer indexReplacer)
        {
            this.transactionalStorage = context.TransactionalStorage;
            this.context = context;
	        this.indexReplacer = indexReplacer;
	        this.scheduler = context.TaskScheduler;
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:7,代码来源:AbstractIndexingExecuter.cs

示例11: IndexingExecuter

		public IndexingExecuter(WorkContext context, DatabaseEtagSynchronizer synchronizer, Prefetcher prefetcher)
			: base(context)
		{
			autoTuner = new IndexBatchSizeAutoTuner(context);
			etagSynchronizer = synchronizer.GetSynchronizer(EtagSynchronizerType.Indexer);
			prefetchingBehavior = prefetcher.GetPrefetchingBehavior(PrefetchingUser.Indexer, autoTuner);
		}
开发者ID:urbanfly,项目名称:ravendb,代码行数:7,代码来源:IndexingExecuter.cs

示例12: Execute

 public override void Execute(WorkContext context)
 {
     if (logger.IsDebugEnabled)
     {
         logger.Debug("Going to touch the following documents (missing references, need to check for concurrent transactions): {0}",
             string.Join(", ", Keys));
     }
   
     context.TransactionalStorage.Batch(accessor =>
     {
         foreach (var key in Keys)
         {
             foreach (var index in context.IndexStorage.Indexes)
             {
                 var set = context.DoNotTouchAgainIfMissingReferences.GetOrAdd(index, _ => new ConcurrentSet<string>(StringComparer.OrdinalIgnoreCase));
                 set.Add(key);
             }
             try
             {
                 Etag preTouchEtag;
                 Etag afterTouchEtag;
                 accessor.Documents.TouchDocument(key, out preTouchEtag, out afterTouchEtag);
             }
             catch (ConcurrencyException)
             {
             }
         }
     });
 }
开发者ID:JohannesRudolph,项目名称:ravendb,代码行数:29,代码来源:TouchMissingReferenceDocumentTask.cs

示例13: IndexDocuments

        public override void IndexDocuments(
			AbstractViewGenerator viewGenerator, 
			IEnumerable<dynamic> documents, 
			WorkContext context, 
			IStorageActionsAccessor actions, 
			DateTime minimumTimestamp)
        {
            actions.Indexing.SetCurrentIndexStatsTo(name);
            var count = 0;
            Func<object, object> documentIdFetcher = null;
            var reduceKeys = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
            var documentsWrapped = documents.Select(doc =>
            {
                var documentId = doc.__document_id;
                foreach (var reduceKey in actions.MappedResults.DeleteMappedResultsForDocumentId((string)documentId, name))
                {
                    reduceKeys.Add(reduceKey);
                }
                return doc;
            });
            foreach (var doc in RobustEnumeration(documentsWrapped, viewGenerator.MapDefinition, actions, context))
            {
                count++;

                documentIdFetcher = CreateDocumentIdFetcherIfNeeded(documentIdFetcher, doc);

                var docIdValue = documentIdFetcher(doc);
                if (docIdValue == null)
                    throw new InvalidOperationException("Could not find document id for this document");

                var reduceValue = viewGenerator.GroupByExtraction(doc);
                if (reduceValue == null)
                {
                    logIndexing.DebugFormat("Field {0} is used as the reduce key and cannot be null, skipping document {1}", viewGenerator.GroupByExtraction, docIdValue);
                    continue;
                }
                var reduceKey = ReduceKeyToString(reduceValue);
                var docId = docIdValue.ToString();

                reduceKeys.Add(reduceKey);

                var data = GetMapedData(doc);

                logIndexing.DebugFormat("Mapped result for '{0}': '{1}'", name, data);

                var hash = ComputeHash(name, reduceKey);

                actions.MappedResults.PutMappedResult(name, docId, reduceKey, data, hash);

                actions.Indexing.IncrementSuccessIndexing();
            }

            actions.Tasks.AddTask(new ReduceTask
            {
                Index = name,
                ReduceKeys = reduceKeys.ToArray()
            }, minimumTimestamp);

            logIndexing.DebugFormat("Mapped {0} documents for {1}", count, name);
        }
开发者ID:dplaskon,项目名称:ravendb,代码行数:60,代码来源:MapReduceIndex.cs

示例14: IndexingExecuter

		public IndexingExecuter(WorkContext context, Prefetcher prefetcher)
			: base(context)
		{
			autoTuner = new IndexBatchSizeAutoTuner(context);
			this.prefetcher = prefetcher;
			defaultPrefetchingBehavior = prefetcher.CreatePrefetchingBehavior(PrefetchingUser.Indexer, autoTuner);
			prefetchingBehaviors.TryAdd(defaultPrefetchingBehavior);
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:8,代码来源:IndexingExecuter.cs

示例15: AbstractIndexingExecuter

 protected AbstractIndexingExecuter(WorkContext context, IndexReplacer indexReplacer)
 {
     Log = LogManager.GetLogger(GetType());
     this.transactionalStorage = context.TransactionalStorage;
     this.context = context;
     this.indexReplacer = indexReplacer;
     this.scheduler = context.TaskScheduler;
 }
开发者ID:heinnge,项目名称:ravendb,代码行数:8,代码来源:AbstractIndexingExecuter.cs


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