public override int HandleMap(LazyStringValue lowerId, LazyStringValue id, IEnumerable mapResults, IndexWriteOperation writer, TransactionOperationContext indexContext, IndexingStatsScope stats) { EnsureValidStats(stats); bool mustDelete; using (_stats.BloomStats.Start()) { mustDelete = _filters.Add(lowerId) == false; } if (mustDelete) { writer.Delete(lowerId, stats); } var numberOfOutputs = 0; foreach (var mapResult in mapResults) { writer.IndexDocument(lowerId, mapResult, stats, indexContext); numberOfOutputs++; } HandleIndexOutputsPerDocument(id ?? lowerId, numberOfOutputs, stats); DocumentDatabase.Metrics.MapIndexes.IndexedPerSec.Mark(numberOfOutputs); return(numberOfOutputs); }
public override int HandleMap(LazyStringValue key, IEnumerable mapResults, IndexWriteOperation writer, TransactionOperationContext indexContext, IndexingStatsScope stats) { EnsureValidStats(stats); bool mustDelete; using (_stats.BloomStats.Start()) { mustDelete = _filter.Add(key) == false; } if (mustDelete) { writer.Delete(key, stats); } var numberOfOutputs = 0; foreach (var mapResult in mapResults) { writer.IndexDocument(key, mapResult, stats, indexContext); numberOfOutputs++; if (EnsureValidNumberOfOutputsForDocument(numberOfOutputs)) { continue; } writer.Delete(key, stats); throw new InvalidOperationException($"Index '{Name}' has already produced {numberOfOutputs} map results for a source document '{key}', while the allowed max number of outputs is {MaxNumberOfIndexOutputs} per one document. Please verify this index definition and consider a re-design of your entities or index."); } DocumentDatabase.Metrics.IndexedPerSecond.Mark(); return(numberOfOutputs); }
public override void HandleDelete(Tombstone tombstone, string collection, IndexWriteOperation writer, TransactionOperationContext indexContext, IndexingStatsScope stats) { writer.Delete(tombstone.LowerId, stats); }