From: <bi...@us...> - 2009-10-28 00:04:23
|
Revision: 2847 http://archive-access.svn.sourceforge.net/archive-access/?rev=2847&view=rev Author: binzino Date: 2009-10-28 00:04:14 +0000 (Wed, 28 Oct 2009) Log Message: ----------- Obsoleted by DumpParallelIndex.java. Removed Paths: ------------- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/tools/DumpIndex.java Deleted: trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/tools/DumpIndex.java =================================================================== --- trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/tools/DumpIndex.java 2009-10-28 00:02:34 UTC (rev 2846) +++ trunk/archive-access/projects/nutchwax/archive/src/java/org/archive/nutchwax/tools/DumpIndex.java 2009-10-28 00:04:14 UTC (rev 2847) @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2008 Internet Archive. - * - * This file is part of the archive-access tools project - * (http://sourceforge.net/projects/archive-access). - * - * The archive-access tools are free software; you can redistribute them and/or - * modify them under the terms of the GNU Lesser Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or any - * later version. - * - * The archive-access tools are distributed in the hope that they will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser - * Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License along with - * the archive-access tools; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package org.archive.nutchwax.tools; - -import java.io.File; -import java.util.Iterator; - -import org.apache.lucene.index.IndexReader; - -public class DumpIndex -{ - public static void main(String[] args) throws Exception - { - String option = ""; - String indexDir = ""; - - if (args.length == 1) - { - indexDir = args[0]; - } - else if (args.length == 2) - { - option = args[0]; - indexDir = args[1]; - } - - if (! (new File(indexDir)).exists()) - { - usageAndExit(); - } - - if (option.equals("-f")) - { - listFields(indexDir); - } - else - { - dumpIndex(indexDir); - } - } - - private static void dumpIndex(String indexDir) throws Exception - { - IndexReader reader = IndexReader.open(indexDir); - - Object[] fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL).toArray(); - - for (int i = 0; i < fieldNames.length; i++) - { - System.out.print(fieldNames[i] + "\t"); - } - - System.out.println(); - - int numDocs = reader.numDocs(); - - for (int i = 0; i < numDocs; i++) - { - for (int j = 0; j < fieldNames.length; j++) - { - System.out.print(reader.document(i).get((String) fieldNames[j]) + "\t"); - } - - System.out.println(); - } - } - - private static void listFields(String indexDir) throws Exception - { - IndexReader reader = IndexReader.open(indexDir); - - Iterator it = reader.getFieldNames(IndexReader.FieldOption.ALL).iterator(); - - while (it.hasNext()) - { - System.out.println(it.next()); - } - - reader.close(); - } - - private static void usageAndExit() - { - System.out.println("Usage: DumpIndex [-f] index"); - System.exit(1); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |