コード例 #1
0
ファイル: SegmentReader.cs プロジェクト: carrie901/mono
			// NOTE: only called from IndexWriter when a near
			// real-time reader is opened, or applyDeletes is run,
			// sharing a segment that's still being merged.  This
			// method is not fully thread safe, and relies on the
			// synchronization in IndexWriter
			internal void  LoadTermsIndex(SegmentInfo si, int termsIndexDivisor)
			{
				lock (this)
				{
					if (tis == null)
					{
						Directory dir0;
						if (si.GetUseCompoundFile())
						{
							// In some cases, we were originally opened when CFS
							// was not used, but then we are asked to open the
							// terms reader with index, the segment has switched
							// to CFS
							if (cfsReader == null)
							{
								cfsReader = new CompoundFileReader(dir, segment + "." + IndexFileNames.COMPOUND_FILE_EXTENSION, readBufferSize);
							}
							dir0 = cfsReader;
						}
						else
						{
							dir0 = dir;
						}
						
						tis = new TermInfosReader(dir0, segment, fieldInfos, readBufferSize, termsIndexDivisor);
					}
				}
			}
コード例 #2
0
ファイル: SegmentReader.cs プロジェクト: carrie901/mono
			internal void  DecRef()
			{
				lock (this)
				{
					
					if (ref_Renamed.DecRef() == 0)
					{
						
						// close everything, nothing is shared anymore with other readers
						if (tis != null)
						{
							tis.Close();
							// null so if an app hangs on to us we still free most ram
							tis = null;
						}
						
						if (tisNoIndex != null)
						{
							tisNoIndex.Close();
						}
						
						if (freqStream != null)
						{
							freqStream.Close();
						}
						
						if (proxStream != null)
						{
							proxStream.Close();
						}
						
						if (termVectorsReaderOrig != null)
						{
							termVectorsReaderOrig.Close();
						}
						
						if (fieldsReaderOrig != null)
						{
							fieldsReaderOrig.Close();
						}
						
						if (cfsReader != null)
						{
							cfsReader.Close();
						}
						
						if (storeCFSReader != null)
						{
							storeCFSReader.Close();
						}

                        // Force FieldCache to evict our entries at this point
                        if (origInstance != null)
                        {
                            Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.Purge(origInstance);
                        }
					}
				}
			}
コード例 #3
0
ファイル: SegmentReader.cs プロジェクト: carrie901/mono
            internal CoreReaders(SegmentReader origInstance, Directory dir, SegmentInfo si, int readBufferSize, int termsIndexDivisor)
			{
				segment = si.name;
				this.readBufferSize = readBufferSize;
				this.dir = dir;
				
				bool success = false;
				
				try
				{
					Directory dir0 = dir;
					if (si.GetUseCompoundFile())
					{
						cfsReader = new CompoundFileReader(dir, segment + "." + IndexFileNames.COMPOUND_FILE_EXTENSION, readBufferSize);
						dir0 = cfsReader;
					}
					cfsDir = dir0;
					
					fieldInfos = new FieldInfos(cfsDir, segment + "." + IndexFileNames.FIELD_INFOS_EXTENSION);
					
					this.termsIndexDivisor = termsIndexDivisor;
					TermInfosReader reader = new TermInfosReader(cfsDir, segment, fieldInfos, readBufferSize, termsIndexDivisor);
					if (termsIndexDivisor == - 1)
					{
						tisNoIndex = reader;
					}
					else
					{
						tis = reader;
						tisNoIndex = null;
					}
					
					// make sure that all index files have been read or are kept open
					// so that if an index update removes them we'll still have them
					freqStream = cfsDir.OpenInput(segment + "." + IndexFileNames.FREQ_EXTENSION, readBufferSize);
					
					if (fieldInfos.HasProx())
					{
						proxStream = cfsDir.OpenInput(segment + "." + IndexFileNames.PROX_EXTENSION, readBufferSize);
					}
					else
					{
						proxStream = null;
					}
					success = true;
				}
				finally
				{
					if (!success)
					{
						DecRef();
					}
				}


                // Must assign this at the end -- if we hit an
                // exception above core, we don't want to attempt to
                // purge the FieldCache (will hit NPE because core is
                // not assigned yet).
                this.origInstance = origInstance;
			}