Exemple #1
0
        private DirectoryReader DoOpenNoWriter(IndexCommit commit)
        {
            if (commit == null)
            {
                if (IsCurrent())
                {
                    return(null);
                }
            }
            else
            {
                if (m_directory != commit.Directory)
                {
                    throw new IOException("the specified commit does not match the specified Directory");
                }
                if (segmentInfos != null && commit.SegmentsFileName.Equals(segmentInfos.GetSegmentsFileName(), StringComparison.Ordinal))
                {
                    return(null);
                }
            }

            return(DoOpenFromCommit(commit));
        }
Exemple #2
0
        private DirectoryReader DoOpenFromWriter(IndexCommit commit)
        {
            if (commit != null)
            {
                return(DoOpenFromCommit(commit));
            }

            if (writer.NrtIsCurrent(segmentInfos))
            {
                return(null);
            }

            DirectoryReader reader = writer.GetReader(applyAllDeletes);

            // If in fact no changes took place, return null:
            if (reader.Version == segmentInfos.Version)
            {
                reader.DecRef();
                return(null);
            }

            return(reader);
        }
Exemple #3
0
 /// <summary>
 /// Increments the refCount for this <see cref="IndexCommit"/>. </summary>
 protected internal virtual void IncRef(IndexCommit ic)
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         long gen = ic.Generation;
         int  refCountInt;
         if (!m_refCounts.TryGetValue(gen, out int refCount))
         {
             m_indexCommits[gen] = m_lastCommit;
             refCountInt         = 0;
         }
         else
         {
             refCountInt = refCount;
         }
         m_refCounts[gen] = refCountInt + 1;
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
Exemple #4
0
 public override void OnInit <T>(IList <T> commits)
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         initCalled = true;
         primary.OnInit(WrapCommits(commits));
         foreach (IndexCommit commit in commits)
         {
             if (m_refCounts.ContainsKey(commit.Generation))
             {
                 m_indexCommits[commit.Generation] = commit;
             }
         }
         if (commits.Count > 0)
         {
             m_lastCommit = commits[commits.Count - 1];
         }
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
Exemple #5
0
 protected internal override sealed DirectoryReader DoOpenIfChanged(IndexCommit commit)
 {
     return(WrapDirectoryReader(m_input.DoOpenIfChanged(commit)));
 }
Exemple #6
0
 /// <summary>
 /// Implement this method to support <see cref="OpenIfChanged(DirectoryReader, IndexCommit)"/>.
 /// If this reader does not support reopen from a specific <see cref="Index.IndexCommit"/>,
 /// throw <see cref="NotSupportedException"/>. </summary>
 /// <exception cref="IOException"> if there is a low-level IO error </exception>
 /// <returns> <c>null</c> if there are no changes; else, a new
 /// <see cref="DirectoryReader"/> instance. </returns>
 protected internal abstract DirectoryReader DoOpenIfChanged(IndexCommit commit);
Exemple #7
0
 /// <summary>
 /// Expert: returns an <see cref="IndexReader"/> reading the index in the given
 /// <seealso cref="Index.IndexCommit"/> and <paramref name="termInfosIndexDivisor"/>. </summary>
 /// <param name="commit"> the commit point to open </param>
 /// <param name="termInfosIndexDivisor"> Subsamples which indexed
 /// terms are loaded into RAM. this has the same effect as setting
 /// <see cref="LiveIndexWriterConfig.TermIndexInterval"/> (on <see cref="IndexWriterConfig"/>) except that setting
 /// must be done at indexing time while this setting can be
 /// set per reader.  When set to N, then one in every
 /// N*termIndexInterval terms in the index is loaded into
 /// memory.  By setting this to a value &gt; 1 you can reduce
 /// memory usage, at the expense of higher latency when
 /// loading a TermInfo.  The default value is 1.  Set this
 /// to -1 to skip loading the terms index entirely.
 /// <b>NOTE:</b> divisor settings &gt; 1 do not apply to all <see cref="Codecs.PostingsFormat"/>
 /// implementations, including the default one in this release. It only makes
 /// sense for terms indexes that can efficiently re-sample terms at load time. </param>
 /// <exception cref="IOException"> if there is a low-level IO error </exception>
 new public static DirectoryReader Open(IndexCommit commit, int termInfosIndexDivisor)
 {
     return(StandardDirectoryReader.Open(commit.Directory, commit, termInfosIndexDivisor));
 }
Exemple #8
0
 /// <summary>
 /// Expert: returns an <see cref="IndexReader"/> reading the index in the given
 /// <see cref="Index.IndexCommit"/>. </summary>
 /// <param name="commit"> the commit point to open </param>
 /// <exception cref="IOException"> if there is a low-level IO error </exception>
 new public static DirectoryReader Open(IndexCommit commit)
 {
     return(StandardDirectoryReader.Open(commit.Directory, commit, DEFAULT_TERMS_INDEX_DIVISOR));
 }
 /// <summary>
 /// Creates a <see cref="SnapshotCommitPoint"/> wrapping the provided
 /// <see cref="IndexCommit"/>.
 /// </summary>
 protected internal SnapshotCommitPoint(SnapshotDeletionPolicy outerInstance, IndexCommit cp)
 {
     this.outerInstance = outerInstance;
     this.m_cp          = cp;
 }
Exemple #10
0
 public static DirectoryReader Open(IndexCommit commit)
 {
     return(DirectoryReader.Open(commit));
 }
Exemple #11
0
 /// <summary>
 /// called from <c>DirectoryReader.Open(...)</c> methods </summary>
 internal static DirectoryReader Open(Directory directory, IndexCommit commit, int termInfosIndexDivisor)
 {
     return((DirectoryReader) new FindSegmentsFileAnonymousInnerClassHelper(directory, termInfosIndexDivisor).Run(commit));
 }
Exemple #12
0
 private DirectoryReader DoOpenFromCommit(IndexCommit commit)
 {
     return((DirectoryReader) new FindSegmentsFileAnonymousInnerClassHelper2(this, m_directory).Run(commit));
 }