//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean luceneDirectoryExists(java.io.File folder) throws java.io.IOException private bool LuceneDirectoryExists(File folder) { using (Directory directory = IndexStorage.openDirectory(folder)) { return(DirectoryReader.indexExists(directory)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static boolean hasCommits(org.apache.lucene.store.Directory directory) throws java.io.IOException private static bool HasCommits(Directory directory) { return(DirectoryReader.indexExists(directory) && SegmentInfos.readLatestCommit(directory) != null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("deprecation") public static void main(String[] args) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public static void Main(string[] args) { if (args.Length < 5) { Console.Error.WriteLine("Usage: MultiPassIndexSplitter -out <outputDir> -num <numParts> [-seq] <inputIndex1> [<inputIndex2 ...]"); Console.Error.WriteLine("\tinputIndex\tpath to input index, multiple values are ok"); Console.Error.WriteLine("\t-out ouputDir\tpath to output directory to contain partial indexes"); Console.Error.WriteLine("\t-num numParts\tnumber of parts to produce"); Console.Error.WriteLine("\t-seq\tsequential docid-range split (default is round-robin)"); Environment.Exit(-1); } List <IndexReader> indexes = new List <IndexReader>(); string outDir = null; int numParts = -1; bool seq = false; for (int i = 0; i < args.Length; i++) { if (args[i].Equals("-out")) { outDir = args[++i]; } else if (args[i].Equals("-num")) { numParts = Convert.ToInt32(args[++i]); } else if (args[i].Equals("-seq")) { seq = true; } else { File file = new File(args[i]); if (!file.exists() || !file.Directory) { Console.Error.WriteLine("Invalid input path - skipping: " + file); continue; } Directory dir = FSDirectory.open(new File(args[i])); try { if (!DirectoryReader.indexExists(dir)) { Console.Error.WriteLine("Invalid input index - skipping: " + file); continue; } } catch (Exception) { Console.Error.WriteLine("Invalid input index - skipping: " + file); continue; } indexes.Add(DirectoryReader.open(dir)); } } if (outDir == null) { throw new Exception("Required argument missing: -out outputDir"); } if (numParts < 2) { throw new Exception("Invalid value of required argument: -num numParts"); } if (indexes.Count == 0) { throw new Exception("No input indexes to process"); } File @out = new File(outDir); if ([email protected]()) { throw new Exception("Can't create output directory: " + @out); } Directory[] dirs = new Directory[numParts]; for (int i = 0; i < numParts; i++) { dirs[i] = FSDirectory.open(new File(@out, "part-" + i)); } MultiPassIndexSplitter splitter = new MultiPassIndexSplitter(); IndexReader input; if (indexes.Count == 1) { input = indexes[0]; } else { input = new MultiReader(indexes.ToArray()); } splitter.Split(Version.LUCENE_CURRENT, input, dirs, seq); }