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

                if (reader != null)
                {
                    termEnum = reader.Terms(term);
                }
            }
コード例 #2
0
 public ParallelTermDocs(ParallelReader enclosingInstance, Term term)
 {
     InitBlock(enclosingInstance);
     if (term == null)
     {
         termDocs = (Enclosing_Instance.readers.Count == 0)
                        ? null
                        : Enclosing_Instance.readers[0].TermDocs(null);
     }
     else
     {
         Seek(term);
     }
 }
コード例 #3
0
 public ParallelTermEnum(ParallelReader enclosingInstance)
 {
     InitBlock(enclosingInstance);
     try
     {
         field = Enclosing_Instance.fieldToReader.Keys.First();
     }
     catch (ArgumentOutOfRangeException)
     {
         // No fields, so keep field == null, termEnum == null
         return;
     }
     if (field != null)
     {
         termEnum = Enclosing_Instance.fieldToReader[field].Terms();
     }
 }
コード例 #4
0
 public ParallelTermPositions(ParallelReader enclosingInstance, Term term) : base(enclosingInstance)
 {
     InitBlock(enclosingInstance);
     Seek(term);
 }
コード例 #5
0
 private void  InitBlock(ParallelReader enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
コード例 #6
0
 public ParallelTermDocs(ParallelReader enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
コード例 #7
0
        protected internal virtual IndexReader DoReopen(bool doClone)
        {
            EnsureOpen();

            bool reopened = false;
            IList <IndexReader> newReaders = new List <IndexReader>();

            bool success = false;

            try
            {
                foreach (var oldReader in readers)
                {
                    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 = newReaders[i];
                        if (r != readers[i])
                        {
                            try
                            {
                                r.Close();
                            }
                            catch (System.IO.IOException)
                            {
                                // keep going - we want to clean up as much as possible
                            }
                        }
                    }
                }
            }

            if (reopened)
            {
                List <bool>    newDecrefOnClose = new List <bool>();
                ParallelReader pr = new ParallelReader();
                for (int i = 0; i < readers.Count; i++)
                {
                    IndexReader oldReader = readers[i];
                    IndexReader newReader = 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);
            }
        }
コード例 #8
0
			private void  InitBlock(ParallelReader enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
コード例 #9
0
			public ParallelTermPositions(ParallelReader enclosingInstance, Term term):base(enclosingInstance)
			{
				InitBlock(enclosingInstance);
				Seek(term);
			}
コード例 #10
0
			public ParallelTermDocs(ParallelReader enclosingInstance, Term term)
			{
				InitBlock(enclosingInstance);
                if(term == null)
                    termDocs = (Enclosing_Instance.readers.Count == 0)
                                   ? null
                                   : Enclosing_Instance.readers[0].TermDocs(null);
                else
                    Seek(term);
			}
コード例 #11
0
			public ParallelTermDocs(ParallelReader enclosingInstance)
			{
				InitBlock(enclosingInstance);
			}
コード例 #12
0
			public ParallelTermEnum(ParallelReader enclosingInstance, Term term)
			{
				InitBlock(enclosingInstance);
				field = term.Field;
				IndexReader reader = Enclosing_Instance.fieldToReader[field];
				if (reader != null)
					termEnum = reader.Terms(term);
			}
コード例 #13
0
			public ParallelTermEnum(ParallelReader enclosingInstance)
			{
				InitBlock(enclosingInstance);
				try
				{
					field = Enclosing_Instance.fieldToReader.Keys.First();
				}
				catch (ArgumentOutOfRangeException)
				{
					// No fields, so keep field == null, termEnum == null
					return;
				}
				if (field != null)
					termEnum = Enclosing_Instance.fieldToReader[field].Terms();
			}
コード例 #14
0
		protected internal virtual IndexReader DoReopen(bool doClone)
		{
			EnsureOpen();
			
			bool reopened = false;
            IList<IndexReader> newReaders = new List<IndexReader>();
			
			bool success = false;
			
			try
			{
				foreach(var oldReader in readers)
				{
					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 = newReaders[i];
						if (r != readers[i])
						{
							try
							{
								r.Close();
							}
							catch (System.IO.IOException)
							{
								// keep going - we want to clean up as much as possible
							}
						}
					}
				}
			}
			
			if (reopened)
			{
                List<bool> newDecrefOnClose = new List<bool>();
				ParallelReader pr = new ParallelReader();
				for (int i = 0; i < readers.Count; i++)
				{
					IndexReader oldReader = readers[i];
					IndexReader newReader = 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;
			}
		}