예제 #1
0
        public void Initialize(RavenTransaction tx)
        {
            var tree = tx.InnerTransaction.CreateTree(PrefixesOfReduceOutputDocumentsToDeleteTree);

            if (tx.InnerTransaction.ReadTree(Legacy.LegacyReduceOutputsTreeName) != null)
            {
                Legacy.ConvertLegacyPrefixesToDeleteTree(tx);
            }

            _prefixesOfReduceOutputDocumentsToDelete = new ConcurrentDictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            using (var it = tree.Iterate(false))
            {
                if (it.Seek(Slices.BeforeAllKeys))
                {
                    do
                    {
                        var toDelete = GetPrefixToDeleteAndOriginalPatternFromCurrent(it);

                        if (_prefixesOfReduceOutputDocumentsToDelete.TryAdd(toDelete.Prefix, toDelete.OriginalPattern) == false)
                        {
                            throw new InvalidOperationException($"Could not add '{toDelete.Prefix}' prefix to list of items to delete (pattern - '{toDelete.OriginalPattern}')");
                        }
                    } while (it.MoveNext());
                }
            }
        }