@@ -0,0 +1,2506 @@
+package net.sf.katta.index.indexer;%0A%0Aimport net.sf.katta.index.indexer.merge.DfsIndexDirectory;%0Aimport org.apache.commons.cli.CommandLine;%0Aimport org.apache.commons.cli.CommandLineParser;%0Aimport org.apache.commons.cli.HelpFormatter;%0Aimport org.apache.commons.cli.Options;%0Aimport org.apache.commons.cli.PosixParser;%0Aimport org.apache.hadoop.fs.FileSystem;%0Aimport org.apache.hadoop.fs.Path;%0Aimport org.apache.hadoop.mapred.JobConf;%0Aimport org.apache.lucene.document.Document;%0Aimport org.apache.lucene.document.MapFieldSelector;%0Aimport org.apache.lucene.index.IndexReader;%0A%0Apublic class IndexDocumentPrinter %7B%0A%0A  public static void main(String%5B%5D args) throws Exception %7B%0A%0A    Options options = new Options();%0A    options.addOption(%22hadoopConf%22, true, %22Hadoop Site Xml%22);%0A    options.addOption(%22shard%22, true, %22Index Shard (Zip File)%22);%0A    options.addOption(%22workingPath%22, true, %22Working Path in dfs for shard extraction%22);%0A    options.addOption(%22indexField%22, true, %22index field to print out%22);%0A%0A    CommandLineParser parser = new PosixParser();%0A    CommandLine cmd = parser.parse(options, args);%0A%0A    if (!cmd.hasOption(%22hadoopConf%22) %7C%7C !cmd.hasOption(%22shard%22) %7C%7C !cmd.hasOption(%22workingPath%22) %7C%7C !cmd.hasOption(%22indexField%22)) %7B%0A      HelpFormatter formatter = new HelpFormatter();%0A      formatter.printHelp(IndexDocumentPrinter.class.getName(), options);%0A      return;%0A    %7D%0A%0A    String hadoopConf = cmd.getOptionValue(%22hadoopConf%22);%0A    Path zipFile = new Path(cmd.getOptionValue(%22shard%22));%0A    Path workingPath = new Path(cmd.getOptionValue(%22workingPath%22), %22%22 + System.currentTimeMillis());%0A%0A    String indexField = cmd.getOptionValue(%22indexField%22);%0A%0A%0A    JobConf jobConf = new JobConf(hadoopConf);%0A    FileSystem fileSystem = FileSystem.get(jobConf);%0A    fileSystem.mkdirs(workingPath);%0A%0A    DfsIndexDirectory directory = new DfsIndexDirectory(fileSystem, zipFile, workingPath);%0A    IndexReader reader = IndexReader.open(directory);%0A    int maxDoc = reader.maxDoc();%0A    MapFieldSelector selector = new MapFieldSelector(new String%5B%5D%7BindexField%7D);%0A    for (int i = 0; i %3C maxDoc; i++) %7B%0A      Document document = reader.document(i, selector);%0A      String indexValue = document.get(indexField);%0A      System.out.println(%22doc %5B%22 + i + %22%5D # %22 + indexField + %22: %22 + indexValue);%0A%0A    %7D%0A%0A    System.out.println(%22delete workingPath %22 + workingPath);%0A    fileSystem.delete(workingPath);%0A    System.out.println(%22%22);%0A    System.out.println(%22%22);%0A%0A    System.out.println(%22Max. documents in shard: %22 + maxDoc);%0A  %7D%0A%7D%0A

implement a index document printer