Exemplo n.º 1
0
		/// <summary>Called whenever a merge has completed and the merged segments had deletions </summary>
		internal void  RemapDeletes(SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
		{
			lock (this)
			{
				if (docMaps == null)
				// The merged segments had no deletes so docIDs did not change and we have nothing to do
					return ;
				MergeDocIDRemapper mapper = new MergeDocIDRemapper(infos, docMaps, delCounts, merge, mergeDocCount);
				deletesInRAM.Remap(mapper, infos, docMaps, delCounts, merge, mergeDocCount);
				deletesFlushed.Remap(mapper, infos, docMaps, delCounts, merge, mergeDocCount);
				flushedDocCount -= mapper.docShift;
			}
		}
Exemplo n.º 2
0
        // Remaps all buffered deletes based on a completed
        // merge
        internal virtual void  Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
        {
            lock (this)
            {
                IDictionary <Term, Num> newDeleteTerms;

                // Remap delete-by-term
                if (terms.Count > 0)
                {
                    if (doTermSort)
                    {
                        newDeleteTerms = new SortedDictionary <Term, Num>();
                    }
                    else
                    {
                        newDeleteTerms = new HashMap <Term, Num>();
                    }
                    foreach (var entry in terms)
                    {
                        Num num = entry.Value;
                        newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
                    }
                }
                else
                {
                    newDeleteTerms = null;
                }

                // Remap delete-by-docID
                List <int> newDeleteDocIDs;

                if (docIDs.Count > 0)
                {
                    newDeleteDocIDs = new List <int>(docIDs.Count);
                    foreach (int num in docIDs)
                    {
                        newDeleteDocIDs.Add(mapper.Remap(num));
                    }
                }
                else
                {
                    newDeleteDocIDs = null;
                }

                // Remap delete-by-query
                HashMap <Query, int> newDeleteQueries;

                if (queries.Count > 0)
                {
                    newDeleteQueries = new HashMap <Query, int>(queries.Count);
                    foreach (var entry in queries)
                    {
                        int num = entry.Value;
                        newDeleteQueries[entry.Key] = mapper.Remap(num);
                    }
                }
                else
                {
                    newDeleteQueries = null;
                }

                if (newDeleteTerms != null)
                {
                    terms = newDeleteTerms;
                }
                if (newDeleteDocIDs != null)
                {
                    docIDs = newDeleteDocIDs;
                }
                if (newDeleteQueries != null)
                {
                    queries = newDeleteQueries;
                }
            }
        }
Exemplo n.º 3
0
        // Remaps all buffered deletes based on a completed
        // merge
        internal virtual void  Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
        {
            lock (this)
            {
                System.Collections.IDictionary newDeleteTerms;

                // Remap delete-by-term
                if (terms.Count > 0)
                {
                    if (doTermSort)
                    {
                        newDeleteTerms = new System.Collections.Generic.SortedDictionary <object, object>();
                    }
                    else
                    {
                        newDeleteTerms = new System.Collections.Hashtable();
                    }
                    System.Collections.IEnumerator iter = new System.Collections.Hashtable(terms).GetEnumerator();
                    while (iter.MoveNext())
                    {
                        System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry)iter.Current;
                        Num num = (Num)entry.Value;
                        newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
                    }
                }
                else
                {
                    newDeleteTerms = null;
                }

                // Remap delete-by-docID
                System.Collections.ArrayList newDeleteDocIDs;

                if (docIDs.Count > 0)
                {
                    newDeleteDocIDs = new System.Collections.ArrayList(docIDs.Count);
                    System.Collections.IEnumerator iter = docIDs.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        System.Int32 num = (System.Int32)iter.Current;
                        newDeleteDocIDs.Add((System.Int32)mapper.Remap(num));
                    }
                }
                else
                {
                    newDeleteDocIDs = null;
                }

                // Remap delete-by-query
                System.Collections.Hashtable newDeleteQueries;

                if (queries.Count > 0)
                {
                    newDeleteQueries = new System.Collections.Hashtable(queries.Count);
                    System.Collections.IEnumerator iter = new System.Collections.Hashtable(queries).GetEnumerator();
                    while (iter.MoveNext())
                    {
                        System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry)iter.Current;
                        System.Int32 num = (System.Int32)entry.Value;
                        newDeleteQueries[entry.Key] = (System.Int32)mapper.Remap(num);
                    }
                }
                else
                {
                    newDeleteQueries = null;
                }

                if (newDeleteTerms != null)
                {
                    terms = newDeleteTerms;
                }
                if (newDeleteDocIDs != null)
                {
                    docIDs = newDeleteDocIDs;
                }
                if (newDeleteQueries != null)
                {
                    queries = newDeleteQueries;
                }
            }
        }
Exemplo n.º 4
0
		// Remaps all buffered deletes based on a completed
		// merge
		internal virtual void  Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
		{
			lock (this)
			{
				
				System.Collections.IDictionary newDeleteTerms;
				
				// Remap delete-by-term
				if (terms.Count > 0)
				{
                    if (doTermSort)
                    {
                        newDeleteTerms = new System.Collections.Generic.SortedDictionary<object, object>();
                    }
                    else
                    {
                        newDeleteTerms = new System.Collections.Hashtable();
                    }
					System.Collections.IEnumerator iter = new System.Collections.Hashtable(terms).GetEnumerator();
					while (iter.MoveNext())
					{
						System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current;
						Num num = (Num) entry.Value;
						newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
					}
				}
				else
					newDeleteTerms = null;
				
				// Remap delete-by-docID
				System.Collections.ArrayList newDeleteDocIDs;
				
				if (docIDs.Count > 0)
				{
					newDeleteDocIDs = new System.Collections.ArrayList(docIDs.Count);
					System.Collections.IEnumerator iter = docIDs.GetEnumerator();
					while (iter.MoveNext())
					{
						System.Int32 num = (System.Int32) iter.Current;
						newDeleteDocIDs.Add((System.Int32) mapper.Remap(num));
					}
				}
				else
					newDeleteDocIDs = null;
				
				// Remap delete-by-query
				System.Collections.Hashtable newDeleteQueries;
				
				if (queries.Count > 0)
				{
					newDeleteQueries = new System.Collections.Hashtable(queries.Count);
					System.Collections.IEnumerator iter = new System.Collections.Hashtable(queries).GetEnumerator();
					while (iter.MoveNext())
					{
						System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current;
						System.Int32 num = (System.Int32) entry.Value;
						newDeleteQueries[entry.Key] = (System.Int32) mapper.Remap(num);
					}
				}
				else
					newDeleteQueries = null;
				
				if (newDeleteTerms != null)
					terms = newDeleteTerms;
				if (newDeleteDocIDs != null)
					docIDs = newDeleteDocIDs;
				if (newDeleteQueries != null)
					queries = newDeleteQueries;
			}
		}
Exemplo n.º 5
0
        // Remaps all buffered deletes based on a completed
        // merge
        internal virtual void Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
        {
            lock (this)
            {
                IDictionary<Term, Num> newDeleteTerms;

                // Remap delete-by-term
                if (terms.Count > 0)
                {
                    if (doTermSort)
                    {
                        newDeleteTerms = new SortedDictionary<Term, Num>();
                    }
                    else
                    {
                        newDeleteTerms = new HashMap<Term, Num>();
                    }
                    foreach(var entry in terms)
                    {
                        Num num = entry.Value;
                        newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
                    }
                }
                else
                    newDeleteTerms = null;

                // Remap delete-by-docID
                List<int> newDeleteDocIDs;

                if (docIDs.Count > 0)
                {
                    newDeleteDocIDs = new List<int>(docIDs.Count);
                    foreach(int num in docIDs)
                    {
                        newDeleteDocIDs.Add(mapper.Remap(num));
                    }
                }
                else
                    newDeleteDocIDs = null;

                // Remap delete-by-query
                HashMap<Query, int> newDeleteQueries;

                if (queries.Count > 0)
                {
                    newDeleteQueries = new HashMap<Query, int>(queries.Count);
                    foreach(var entry in queries)
                    {
                        int num = entry.Value;
                        newDeleteQueries[entry.Key] = mapper.Remap(num);
                    }
                }
                else
                    newDeleteQueries = null;

                if (newDeleteTerms != null)
                    terms = newDeleteTerms;
                if (newDeleteDocIDs != null)
                    docIDs = newDeleteDocIDs;
                if (newDeleteQueries != null)
                    queries = newDeleteQueries;
            }
        }
Exemplo n.º 6
0
        // Remaps all buffered deletes based on a completed
        // merge
        internal void Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
        {
            lock (this)
            {
                IDictionary <object, object> newDeleteTerms;

                // Remap delete-by-term
                if (terms.Count > 0)
                {
                    newDeleteTerms = new Dictionary <object, object>();
                    IEnumerator <KeyValuePair <object, object> > iter = terms.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        KeyValuePair <object, object> entry = (KeyValuePair <object, object>)iter.Current;
                        Num num = (Num)entry.Value;
                        newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
                    }
                }
                else
                {
                    newDeleteTerms = null;
                }

                // Remap delete-by-docID
                IList <object> newDeleteDocIDs;

                if (docIDs.Count > 0)
                {
                    newDeleteDocIDs = new List <object>(docIDs.Count);
                    IEnumerator <object> iter = docIDs.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        int num = (int)iter.Current;
                        newDeleteDocIDs.Add(mapper.Remap(num));
                    }
                }
                else
                {
                    newDeleteDocIDs = null;
                }

                // Remap delete-by-query
                IDictionary <object, object> newDeleteQueries;

                if (queries.Count > 0)
                {
                    newDeleteQueries = new Dictionary <object, object>(queries.Count);
                    IEnumerator <KeyValuePair <object, object> > iter = queries.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        KeyValuePair <object, object> entry = (KeyValuePair <object, object>)iter.Current;
                        int num = (int)entry.Value;
                        newDeleteQueries[entry.Key] = mapper.Remap(num);
                    }
                }
                else
                {
                    newDeleteQueries = null;
                }

                if (newDeleteTerms != null)
                {
                    terms = newDeleteTerms;
                }
                if (newDeleteDocIDs != null)
                {
                    docIDs = newDeleteDocIDs;
                }
                if (newDeleteQueries != null)
                {
                    queries = newDeleteQueries;
                }
            }
        }
Exemplo n.º 7
0
        // Remaps all buffered deletes based on a completed
        // merge
        internal void Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
        {
            lock (this)
            {
                IDictionary<object, object> newDeleteTerms;

                // Remap delete-by-term
                if (terms.Count > 0)
                {
                    newDeleteTerms = new Dictionary<object, object>();
                    IEnumerator<KeyValuePair<object, object>> iter = terms.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        KeyValuePair<object, object> entry = (KeyValuePair<object, object>)iter.Current;
                        Num num = (Num)entry.Value;
                        newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum()));
                    }
                }
                else
                    newDeleteTerms = null;

                // Remap delete-by-docID
                IList<object> newDeleteDocIDs;

                if (docIDs.Count > 0)
                {
                    newDeleteDocIDs = new List<object>(docIDs.Count);
                    IEnumerator<object> iter = docIDs.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        int num = (int)iter.Current;
                        newDeleteDocIDs.Add(mapper.Remap(num));
                    }
                }
                else
                    newDeleteDocIDs = null;

                // Remap delete-by-query
                IDictionary<object, object> newDeleteQueries;

                if (queries.Count > 0)
                {
                    newDeleteQueries = new Dictionary<object, object>(queries.Count);
                    IEnumerator<KeyValuePair<object, object>> iter = queries.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        KeyValuePair<object, object> entry = (KeyValuePair<object, object>)iter.Current;
                        int num = (int)entry.Value;
                        newDeleteQueries[entry.Key] = mapper.Remap(num);
                    }
                }
                else
                    newDeleteQueries = null;

                if (newDeleteTerms != null)
                    terms = newDeleteTerms;
                if (newDeleteDocIDs != null)
                    docIDs = newDeleteDocIDs;
                if (newDeleteQueries != null)
                    queries = newDeleteQueries;
            }
        }
Exemplo n.º 8
0
        // Remaps all buffered deletes based on a completed
        // merge
        internal void Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
        {
            lock (this)
            {
                FastList <DeleteTerm> newDeleteTerms;

                // Remap delete-by-term
                if (terms.Count > 0)
                {
                    newDeleteTerms = new FastList <DeleteTerm>(terms.Count);
                    foreach (var entry in terms)
                    {
                        DeleteTermNum num = entry.Number;
                        // Adding because it is already sorted.
                        newDeleteTerms.Add(new DeleteTerm(entry.Term, new DeleteTermNum(mapper.Remap(num.GetNum()))));
                    }
                }
                else
                {
                    newDeleteTerms = null;
                }

                // Remap delete-by-docID
                List <int> newDeleteDocIDs;

                if (docIDs.Count > 0)
                {
                    newDeleteDocIDs = new List <int>(docIDs.Count);
                    foreach (int num in docIDs)
                    {
                        newDeleteDocIDs.Add(mapper.Remap(num));
                    }
                }
                else
                {
                    newDeleteDocIDs = null;
                }

                // Remap delete-by-query
                HashMap <Query, int> newDeleteQueries;

                if (queries.Count > 0)
                {
                    newDeleteQueries = new HashMap <Query, int>(queries.Count);
                    foreach (var entry in queries)
                    {
                        int num = entry.Value;
                        newDeleteQueries[entry.Key] = mapper.Remap(num);
                    }
                }
                else
                {
                    newDeleteQueries = null;
                }

                if (newDeleteTerms != null)
                {
                    terms = newDeleteTerms;
                }
                if (newDeleteDocIDs != null)
                {
                    docIDs = newDeleteDocIDs;
                }
                if (newDeleteQueries != null)
                {
                    queries = newDeleteQueries;
                }
            }
        }