Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 29225 invoked from network); 1 May 2003 01:09:21 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 1 May 2003 01:09:21 -0000 Received: (qmail 16976 invoked by uid 97); 1 May 2003 01:11:28 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@nagoya.betaversion.org Received: (qmail 16969 invoked from network); 1 May 2003 01:11:27 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 1 May 2003 01:11:27 -0000 Received: (qmail 28979 invoked by uid 500); 1 May 2003 01:09:17 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 28968 invoked by uid 500); 1 May 2003 01:09:17 -0000 Received: (qmail 28965 invoked from network); 1 May 2003 01:09:17 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 1 May 2003 01:09:17 -0000 Received: (qmail 12862 invoked by uid 1371); 1 May 2003 01:09:15 -0000 Date: 1 May 2003 01:09:15 -0000 Message-ID: <20030501010915.12861.qmail@icarus.apache.org> From: otis@apache.org To: jakarta-lucene-cvs@apache.org Subject: cvs commit: jakarta-lucene/src/java/org/apache/lucene/index IndexReader.java SegmentReader.java SegmentsReader.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N otis 2003/04/30 18:09:15 Modified: . CHANGES.txt src/java/org/apache/lucene/index IndexReader.java SegmentReader.java SegmentsReader.java Log: - Added method getFieldNames(boolean). Submitted by: Julien Nioche Reviewed by: Otis Revision Changes Path 1.47 +3 -2 jakarta-lucene/CHANGES.txt Index: CHANGES.txt =================================================================== RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- CHANGES.txt 20 Mar 2003 18:38:59 -0000 1.46 +++ CHANGES.txt 1 May 2003 01:09:15 -0000 1.47 @@ -4,7 +4,8 @@ 1.3 RC2 - 1. + 1. Added getFieldNames(boolean) to IndexReader, SegmentReader, and + SegmentsReader. (Julien Nioche via otis) 1.3 RC1 1.15 +35 -19 jakarta-lucene/src/java/org/apache/lucene/index/IndexReader.java Index: IndexReader.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/IndexReader.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- IndexReader.java 20 Mar 2003 18:28:13 -0000 1.14 +++ IndexReader.java 1 May 2003 01:09:15 -0000 1.15 @@ -3,8 +3,8 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2001, 2002, 2003 The Apache Software Foundation. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -75,8 +75,8 @@ document numbers, non-negative integers which each name a unique document in the index. These document numbers are ephemeral--they may change as documents are added to and deleted from an index. Clients should thus not - rely on a given document having the same number between sessions. */ - + rely on a given document having the same number between sessions. +*/ public abstract class IndexReader { protected IndexReader(Directory directory) { this.directory = directory; @@ -209,7 +209,8 @@ Term    =>    <docNum, freq>*

The enumeration is ordered by document number. Each document number - is greater than all that precede it in the enumeration. */ + is greater than all that precede it in the enumeration. + */ public TermDocs termDocs(Term term) throws IOException { TermDocs termDocs = termDocs(); termDocs.seek(term); @@ -233,7 +234,8 @@

This positional information faciliates phrase and proximity searching.

The enumeration is ordered by document number. Each document number is - greater than all that precede it in the enumeration. */ + greater than all that precede it in the enumeration. + */ public TermPositions termPositions(Term term) throws IOException { TermPositions termPositions = termPositions(); termPositions.seek(term); @@ -248,7 +250,8 @@ Attempts to read its field with the {@link #document} method will result in an error. The presence of this document may still be reflected in the {@link #docFreq} statistic, though - this will be corrected eventually as the index is further modified. */ + this will be corrected eventually as the index is further modified. + */ public final synchronized void delete(int docNum) throws IOException { if (writeLock == null) { Lock writeLock = directory.makeLock("write.lock"); @@ -258,13 +261,15 @@ } doDelete(docNum); } + abstract void doDelete(int docNum) throws IOException; /** Deletes all documents containing term. This is useful if one uses a document field to hold a unique ID string for the document. Then to delete such a document, one merely constructs a term with the appropriate field and the unique ID string as its text and - passes it to this method. Returns the number of documents deleted. */ + passes it to this method. Returns the number of documents deleted. + */ public final int delete(Term term) throws IOException { TermDocs docs = termDocs(term); if ( docs == null ) return 0; @@ -304,13 +309,24 @@ } } - /** - * Return a list of all unique field names which exist in the index pointed to by - * this IndexReader. - * @return Collection of Strings indicating the names of the fields - * @throws IOException if there is a problem with accessing the index - */ - public abstract Collection getFieldNames() throws IOException; + /** + * Returns a list of all unique field names that exist in the index pointed to by + * this IndexReader. + * @return Collection of Strings indicating the names of the fields + * @throws IOException if there is a problem with accessing the index + */ + public abstract Collection getFieldNames() throws IOException; + + /** + * Returns a list of all unique field names that exist in the index pointed to by + * this IndexReader. The boolean argument specifies whether the fields returned + * are indexed or not. + * @param indexed true if only indexed fields should be returned; + * false if only unindexed fields should be returned. + * @return Collection of Strings indicating the names of the fields + * @throws IOException if there is a problem with accessing the index + */ + public abstract Collection getFieldNames(boolean indexed) throws IOException; /** * Returns true iff the index in the named directory is @@ -319,7 +335,7 @@ * @throws IOException if there is a problem with accessing the index */ public static boolean isLocked(Directory directory) throws IOException { - return directory.fileExists("write.lock"); + return directory.fileExists("write.lock"); } /** @@ -329,7 +345,7 @@ * @throws IOException if there is a problem with accessing the index */ public static boolean isLocked(String directory) throws IOException { - return (new File(directory, "write.lock")).exists(); + return (new File(directory, "write.lock")).exists(); } /** @@ -340,7 +356,7 @@ * currently accessing this index. */ public static void unlock(Directory directory) throws IOException { - directory.deleteFile("write.lock"); - directory.deleteFile("commit.lock"); + directory.deleteFile("write.lock"); + directory.deleteFile("commit.lock"); } } 1.8 +27 -11 jakarta-lucene/src/java/org/apache/lucene/index/SegmentReader.java Index: SegmentReader.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentReader.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SegmentReader.java 4 Jan 2003 17:13:39 -0000 1.7 +++ SegmentReader.java 1 May 2003 01:09:15 -0000 1.8 @@ -223,6 +223,33 @@ return fieldsReader.size(); } + /** + * @see IndexReader#getFieldNames() + */ + public Collection getFieldNames() throws IOException { + // maintain a unique set of field names + Set fieldSet = new HashSet(); + for (int i = 0; i < fieldInfos.size(); i++) { + FieldInfo fi = fieldInfos.fieldInfo(i); + fieldSet.add(fi.name); + } + return fieldSet; + } + + /** + * @see IndexReader#getFieldNames(boolean) + */ + public Collection getFieldNames(boolean indexed) throws IOException { + // maintain a unique set of field names + Set fieldSet = new HashSet(); + for (int i = 0; i < fieldInfos.size(); i++) { + FieldInfo fi = fieldInfos.fieldInfo(i); + if (fi.isIndexed == indexed) + fieldSet.add(fi.name); + } + return fieldSet; + } + public final byte[] norms(String field) throws IOException { Norm norm = (Norm)norms.get(field); if (norm == null) @@ -273,15 +300,4 @@ } } } - - // javadoc inherited - public Collection getFieldNames() throws IOException { - // maintain a unique set of field names - Set fieldSet = new HashSet(); - for (int i = 0; i < fieldInfos.size(); i++) { - FieldInfo fi = fieldInfos.fieldInfo(i); - fieldSet.add(fi.name); - } - return fieldSet; - } } 1.11 +32 -16 jakarta-lucene/src/java/org/apache/lucene/index/SegmentsReader.java Index: SegmentsReader.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentsReader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- SegmentsReader.java 4 Jan 2003 17:13:39 -0000 1.10 +++ SegmentsReader.java 1 May 2003 01:09:15 -0000 1.11 @@ -3,8 +3,8 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 2001, 2002, 2003 The Apache Software Foundation. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -179,21 +179,37 @@ readers[i].close(); } - // javadoc inherited - public Collection getFieldNames() throws IOException { - // maintain a unique set of field names - Set fieldSet = new HashSet(); - for (int i = 0; i < readers.length; i++) { - SegmentReader reader = readers[i]; - Collection names = reader.getFieldNames(); - // iterate through the field names and add them to the set - for (Iterator iterator = names.iterator(); iterator.hasNext();) { - String s = (String) iterator.next(); - fieldSet.add(s); - } + /** + * @see IndexReader#getFieldNames() + */ + public Collection getFieldNames() throws IOException { + // maintain a unique set of field names + Set fieldSet = new HashSet(); + for (int i = 0; i < readers.length; i++) { + SegmentReader reader = readers[i]; + Collection names = reader.getFieldNames(); + // iterate through the field names and add them to the set + for (Iterator iterator = names.iterator(); iterator.hasNext();) { + String s = (String) iterator.next(); + fieldSet.add(s); } - return fieldSet; } + return fieldSet; + } + + /** + * @see IndexReader#getFieldNames(boolean) + */ + public Collection getFieldNames(boolean indexed) throws IOException { + // maintain a unique set of field names + Set fieldSet = new HashSet(); + for (int i = 0; i < readers.length; i++) { + SegmentReader reader = readers[i]; + Collection names = reader.getFieldNames(indexed); + fieldSet.addAll(names); + } + return fieldSet; + } } class SegmentsTermEnum extends TermEnum { --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-dev-help@jakarta.apache.org