Exemple #1
0
            public ParallelTermEnum(ParallelReader enclosingInstance, Term term)
            {
                InitBlock(enclosingInstance);
                field = term.Field();
                IndexReader reader = ((IndexReader)Enclosing_Instance.fieldToReader[field]);

                if (reader != null)
                {
                    termEnum = reader.Terms(term);
                }
            }
Exemple #2
0
 public ParallelTermDocs(ParallelReader enclosingInstance, Term term)
 {
     InitBlock(enclosingInstance);
     if (term == null)
     {
         termDocs = (Enclosing_Instance.readers.Count == 0)?null:((IndexReader)Enclosing_Instance.readers[0]).TermDocs(null);
     }
     else
     {
         Seek(term);
     }
 }
Exemple #3
0
 public ParallelTermEnum(ParallelReader enclosingInstance)
 {
     InitBlock(enclosingInstance);
     try
     {
         field = ((System.String)Enclosing_Instance.fieldToReader.GetKey(0));
     }
     catch (ArgumentOutOfRangeException e)
     {
         // No fields, so keep field == null, termEnum == null
         return;
     }
     if (field != null)
     {
         termEnum = ((IndexReader)Enclosing_Instance.fieldToReader[field]).Terms();
     }
 }
Exemple #4
0
			public ParallelTermPositions(ParallelReader enclosingInstance, Term term):base(enclosingInstance)
			{
				InitBlock(enclosingInstance);
				Seek(term);
			}
Exemple #5
0
			private void  InitBlock(ParallelReader enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
Exemple #6
0
			public ParallelTermDocs(ParallelReader enclosingInstance, Term term)
			{
				InitBlock(enclosingInstance);
				if (term == null)
					termDocs = (Enclosing_Instance.readers.Count == 0)?null:((IndexReader) Enclosing_Instance.readers[0]).TermDocs(null);
				else
					Seek(term);
			}
Exemple #7
0
			public ParallelTermDocs(ParallelReader enclosingInstance)
			{
				InitBlock(enclosingInstance);
			}
Exemple #8
0
			public ParallelTermEnum(ParallelReader enclosingInstance, Term term)
			{
				InitBlock(enclosingInstance);
				field = term.Field();
				IndexReader reader = ((IndexReader) Enclosing_Instance.fieldToReader[field]);
				if (reader != null)
					termEnum = reader.Terms(term);
			}
Exemple #9
0
			public ParallelTermEnum(ParallelReader enclosingInstance)
			{
				InitBlock(enclosingInstance);
				try
				{
					field = ((System.String) Enclosing_Instance.fieldToReader.GetKey(0));
				}
				catch (ArgumentOutOfRangeException e)
				{
					// No fields, so keep field == null, termEnum == null
					return;
				}
				if (field != null)
					termEnum = ((IndexReader) Enclosing_Instance.fieldToReader[field]).Terms();
			}
Exemple #10
0
		protected internal virtual IndexReader DoReopen(bool doClone)
		{
			EnsureOpen();
			
			bool reopened = false;
			System.Collections.IList newReaders = new System.Collections.ArrayList();
			
			bool success = false;
			
			try
			{
				for (int i = 0; i < readers.Count; i++)
				{
					IndexReader oldReader = (IndexReader) readers[i];
					IndexReader newReader = null;
					if (doClone)
					{
						newReader = (IndexReader) oldReader.Clone();
					}
					else
					{
						newReader = oldReader.Reopen();
					}
					newReaders.Add(newReader);
					// if at least one of the subreaders was updated we remember that
					// and return a new ParallelReader
					if (newReader != oldReader)
					{
						reopened = true;
					}
				}
				success = true;
			}
			finally
			{
				if (!success && reopened)
				{
					for (int i = 0; i < newReaders.Count; i++)
					{
						IndexReader r = (IndexReader) newReaders[i];
						if (r != readers[i])
						{
							try
							{
								r.Close();
							}
							catch (System.IO.IOException ignore)
							{
								// keep going - we want to clean up as much as possible
							}
						}
					}
				}
			}
			
			if (reopened)
			{
				System.Collections.IList newDecrefOnClose = new System.Collections.ArrayList();
				ParallelReader pr = new ParallelReader();
				for (int i = 0; i < readers.Count; i++)
				{
					IndexReader oldReader = (IndexReader) readers[i];
					IndexReader newReader = (IndexReader) newReaders[i];
					if (newReader == oldReader)
					{
						newDecrefOnClose.Add(true);
						newReader.IncRef();
					}
					else
					{
						// this is a new subreader instance, so on close() we don't
						// decRef but close it 
						newDecrefOnClose.Add(false);
					}
					pr.Add(newReader, !storedFieldReaders.Contains(oldReader));
				}
				pr.decrefOnClose = newDecrefOnClose;
				pr.incRefReaders = incRefReaders;
				return pr;
			}
			else
			{
				// No subreader was refreshed
				return this;
			}
		}
Exemple #11
0
 public ParallelTermPositions(ParallelReader enclosingInstance, Term term) : base(enclosingInstance)
 {
     InitBlock(enclosingInstance);
     Seek(term);
 }
Exemple #12
0
 private void  InitBlock(ParallelReader enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemple #13
0
 public ParallelTermDocs(ParallelReader enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
Exemple #14
0
        protected internal virtual IndexReader DoReopen(bool doClone)
        {
            EnsureOpen();

            bool reopened = false;

            System.Collections.IList newReaders = new System.Collections.ArrayList();

            bool success = false;

            try
            {
                for (int i = 0; i < readers.Count; i++)
                {
                    IndexReader oldReader = (IndexReader)readers[i];
                    IndexReader newReader = null;
                    if (doClone)
                    {
                        newReader = (IndexReader)oldReader.Clone();
                    }
                    else
                    {
                        newReader = oldReader.Reopen();
                    }
                    newReaders.Add(newReader);
                    // if at least one of the subreaders was updated we remember that
                    // and return a new ParallelReader
                    if (newReader != oldReader)
                    {
                        reopened = true;
                    }
                }
                success = true;
            }
            finally
            {
                if (!success && reopened)
                {
                    for (int i = 0; i < newReaders.Count; i++)
                    {
                        IndexReader r = (IndexReader)newReaders[i];
                        if (r != readers[i])
                        {
                            try
                            {
                                r.Close();
                            }
                            catch (System.IO.IOException ignore)
                            {
                                // keep going - we want to clean up as much as possible
                            }
                        }
                    }
                }
            }

            if (reopened)
            {
                System.Collections.IList newDecrefOnClose = new System.Collections.ArrayList();
                ParallelReader           pr = new ParallelReader();
                for (int i = 0; i < readers.Count; i++)
                {
                    IndexReader oldReader = (IndexReader)readers[i];
                    IndexReader newReader = (IndexReader)newReaders[i];
                    if (newReader == oldReader)
                    {
                        newDecrefOnClose.Add(true);
                        newReader.IncRef();
                    }
                    else
                    {
                        // this is a new subreader instance, so on close() we don't
                        // decRef but close it
                        newDecrefOnClose.Add(false);
                    }
                    pr.Add(newReader, !storedFieldReaders.Contains(oldReader));
                }
                pr.decrefOnClose = newDecrefOnClose;
                pr.incRefReaders = incRefReaders;
                return(pr);
            }
            else
            {
                // No subreader was refreshed
                return(this);
            }
        }