protected override IIndexingWork[] CreateIndexWorkExecutors() { var workers = new List <IIndexingWork> { new CleanupDocuments(this, DocumentDatabase.DocumentsStorage, _indexStorage, Configuration, null) }; if (_compiled.CollectionsWithCompareExchangeReferences.Count > 0) { workers.Add(_handleCompareExchangeReferences = new HandleCompareExchangeReferences(this, _compiled.CollectionsWithCompareExchangeReferences, DocumentDatabase.DocumentsStorage, _indexStorage, Configuration)); } if (_referencedCollections.Count > 0) { workers.Add(_handleReferences = new HandleDocumentReferences(this, _compiled.ReferencedCollections, DocumentDatabase.DocumentsStorage, _indexStorage, Configuration)); } workers.Add(new MapDocuments(this, DocumentDatabase.DocumentsStorage, _indexStorage, null, Configuration)); return(workers.ToArray()); }
protected override IIndexingWork[] CreateIndexWorkExecutors() { var workers = new List <IIndexingWork>(); workers.Add(new CleanupDocumentsForMapReduce(this, DocumentDatabase.DocumentsStorage, _indexStorage, Configuration, MapReduceWorkContext)); if (_compiled.CollectionsWithCompareExchangeReferences.Count > 0) { workers.Add(_handleCompareExchangeReferences = new HandleCompareExchangeReferences(this, _compiled.CollectionsWithCompareExchangeReferences, DocumentDatabase.DocumentsStorage, _indexStorage, Configuration)); } if (_referencedCollections.Count > 0) { workers.Add(_handleReferences = new HandleDocumentReferences(this, _compiled.ReferencedCollections, DocumentDatabase.DocumentsStorage, _indexStorage, Configuration)); } workers.Add(new MapDocuments(this, DocumentDatabase.DocumentsStorage, _indexStorage, MapReduceWorkContext, Configuration)); workers.Add(new ReduceMapResultsOfStaticIndex(this, _compiled.Reduce, Definition, _indexStorage, DocumentDatabase.Metrics, MapReduceWorkContext)); return(workers.ToArray()); }
public static void HandleDeleteBySourceDocumentId(MapReduceIndex index, HandleReferences handleReferences, HandleCompareExchangeReferences handleCompareExchangeReferences, Tombstone tombstone, string collection, Lazy <IndexWriteOperation> writer, TransactionOperationContext indexContext, IndexingStatsScope stats) { HandleReferencesDelete(handleReferences, handleCompareExchangeReferences, tombstone, collection, writer, indexContext, stats); using (ToPrefixKey(tombstone.LowerId, indexContext, out var prefixKey)) { var toDelete = new List <Slice>(); using (var it = index.MapReduceWorkContext.MapPhaseTree.Iterate(prefetch: false)) { it.SetRequiredPrefix(prefixKey); if (it.Seek(prefixKey) == false) { return; } do { toDelete.Add(it.CurrentKey.Clone(indexContext.Allocator)); } while (it.MoveNext()); } foreach (var key in toDelete) { index.MapReduceWorkContext.DocumentMapEntries.RepurposeInstance(key, clone: false); if (index.MapReduceWorkContext.DocumentMapEntries.NumberOfEntries == 0) { continue; } foreach (var mapEntry in MapReduceIndex.GetMapEntries(index.MapReduceWorkContext.DocumentMapEntries)) { var store = index.GetResultsStore(mapEntry.ReduceKeyHash, indexContext, create: false); store.Delete(mapEntry.Id); } index.MapReduceWorkContext.MapPhaseTree.DeleteFixedTreeFor(key, sizeof(ulong)); } }