public ParallelTermEnum(ParallelReader enclosingInstance, Term term) { InitBlock(enclosingInstance); field = term.Field; IndexReader reader = Enclosing_Instance.fieldToReader[field]; if (reader != null) { termEnum = reader.Terms(term); } }
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); } }
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(); } }
public ParallelTermPositions(ParallelReader enclosingInstance, Term term) : base(enclosingInstance) { InitBlock(enclosingInstance); Seek(term); }
private void InitBlock(ParallelReader enclosingInstance) { this.enclosingInstance = enclosingInstance; }
public ParallelTermDocs(ParallelReader enclosingInstance) { InitBlock(enclosingInstance); }
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); } }
public ParallelTermPositions(ParallelReader enclosingInstance, Term term):base(enclosingInstance) { InitBlock(enclosingInstance); Seek(term); }
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); }
public ParallelTermEnum(ParallelReader enclosingInstance, Term term) { InitBlock(enclosingInstance); field = term.Field; IndexReader reader = Enclosing_Instance.fieldToReader[field]; if (reader != null) termEnum = reader.Terms(term); }
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(); }
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; } }