Lucene.Net.Store.RAMDirectory.ListAll C# (CSharp) Method

ListAll() public method

public ListAll ( ) : System.String[]
return System.String[]
		public override System.String[] ListAll()
		{
			lock (this)
			{
				EnsureOpen();
                // TODO: may have better performance if our HashMap implmented KeySet() instead of generating one via HashSet
                System.Collections.Generic.ISet<string> fileNames = Support.Compatibility.SetFactory.GetSet(fileMap.Keys);
				System.String[] result = new System.String[fileNames.Count];
				int i = 0;
				foreach(string filename in fileNames)
				{
                    result[i++] = filename;
				}
				return result;
			}
		}
		

Usage Example

コード例 #1
0
 public override string[] ListAll()
 {
     lock (this)
     {
         ISet <string> files = new HashSet <string>();
         foreach (string f in cache.ListAll())
         {
             files.Add(f);
         }
         // LUCENE-1468: our NRTCachingDirectory will actually exist (RAMDir!),
         // but if the underlying delegate is an FSDir and mkdirs() has not
         // yet been called, because so far everything is a cached write,
         // in this case, we don't want to throw a NoSuchDirectoryException
         try
         {
             foreach (string f in @delegate.ListAll())
             {
                 // Cannot do this -- if lucene calls createOutput but
                 // file already exists then this falsely trips:
                 //assert !files.contains(f): "file \"" + f + "\" is in both dirs";
                 files.Add(f);
             }
         }
         catch (DirectoryNotFoundException /*ex*/)
         {
             // however, if there are no cached files, then the directory truly
             // does not "exist"
             if (files.Count == 0)
             {
                 throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
             }
         }
         return(files.ToArray());
     }
 }
All Usage Examples Of Lucene.Net.Store.RAMDirectory::ListAll