PR: 30522
Obtained from:
Submitted by:	Bernhard Messer
Reviewed by:	Otis Gospodnetic


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150443 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2004-08-17 20:53:16 +00:00
parent bcaf26108e
commit 83d745ab0c
2 changed files with 49 additions and 9 deletions

View File

@ -1,11 +1,30 @@
package org.apache.lucene.index; package org.apache.lucene.index;
/**
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.store.InputStream; import org.apache.lucene.store.InputStream;
import java.io.IOException; import java.io.IOException;
/** TODO: relax synchro! /**
* FIXME: relax synchro!
*
* @version $Id$
*/ */
class TermVectorsReader { class TermVectorsReader {
private FieldInfos fieldInfos; private FieldInfos fieldInfos;
@ -41,12 +60,14 @@ class TermVectorsReader {
} }
synchronized void close() throws IOException { void close() throws IOException {
// why don't we trap the exception and at least make sure that // make all effort to close up. Keep the first exception
// all streams that we can close are closed? // and throw it as a new one.
if (tvx != null) tvx.close(); IOException keep = null;
if (tvd != null) tvd.close(); if (tvx != null) try { tvx.close(); } catch (IOException e) { if (keep == null) keep = e; }
if (tvf != null) tvf.close(); if (tvd != null) try { tvd.close(); } catch (IOException e) { if (keep == null) keep = e; }
if (tvf != null) try { tvf.close(); } catch (IOException e) { if (keep == null) keep = e; }
if (keep != null) throw (IOException) keep.fillInStackTrace();
} }
/** /**
@ -188,8 +209,8 @@ class TermVectorsReader {
// If no terms - return a constant empty termvector // If no terms - return a constant empty termvector
if (numTerms == 0) return new SegmentTermVector(field, null, null); if (numTerms == 0) return new SegmentTermVector(field, null, null);
int length = numTerms + tvf.readVInt(); tvf.readVInt();
String terms[] = new String[numTerms]; String terms[] = new String[numTerms];
int termFreqs[] = new int[numTerms]; int termFreqs[] = new int[numTerms];

View File

@ -1,5 +1,21 @@
package org.apache.lucene.index; package org.apache.lucene.index;
/**
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.store.OutputStream; import org.apache.lucene.store.OutputStream;
import org.apache.lucene.util.StringHelper; import org.apache.lucene.util.StringHelper;
@ -29,6 +45,9 @@ import java.util.Vector;
writer.closeDocument() writer.closeDocument()
} }
</CODE> </CODE>
*
* @version $Id$
*
*/ */
final class TermVectorsWriter { final class TermVectorsWriter {
public static final int FORMAT_VERSION = 1; public static final int FORMAT_VERSION = 1;