X-Git-Url: https://git.mdrn.pl/pylucene.git/blobdiff_plain/a2e61f0c04805cfcb8706176758d1283c7e3a55c..aaeed5504b982cf3545252ab528713250aa33eed:/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java diff --git a/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java b/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java deleted file mode 100644 index 21eb006..0000000 --- a/lucene-java-3.4.0/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java +++ /dev/null @@ -1,311 +0,0 @@ -package org.apache.lucene.index; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.IndexInput; -import org.apache.lucene.store.BufferedIndexInput; -import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.store.Lock; - -import java.util.HashMap; -import java.io.FileNotFoundException; -import java.io.IOException; - -/** - * Class for accessing a compound stream. - * This class implements a directory, but is limited to only read operations. - * Directory methods that would normally modify data throw an exception. - */ -class CompoundFileReader extends Directory { - - private int readBufferSize; - - private static final class FileEntry { - long offset; - long length; - } - - // Base info - private Directory directory; - private String fileName; - - private IndexInput stream; - private HashMap entries = new HashMap(); - - public CompoundFileReader(Directory dir, String name) throws IOException { - this(dir, name, BufferedIndexInput.BUFFER_SIZE); - } - - public CompoundFileReader(Directory dir, String name, int readBufferSize) throws IOException { - assert !(dir instanceof CompoundFileReader) : "compound file inside of compound file: " + name; - directory = dir; - fileName = name; - this.readBufferSize = readBufferSize; - - boolean success = false; - - try { - stream = dir.openInput(name, readBufferSize); - - // read the first VInt. If it is negative, it's the version number - // otherwise it's the count (pre-3.1 indexes) - int firstInt = stream.readVInt(); - - final int count; - final boolean stripSegmentName; - if (firstInt < CompoundFileWriter.FORMAT_PRE_VERSION) { - if (firstInt < CompoundFileWriter.FORMAT_CURRENT) { - throw new CorruptIndexException("Incompatible format version: " - + firstInt + " expected " + CompoundFileWriter.FORMAT_CURRENT); - } - // It's a post-3.1 index, read the count. - count = stream.readVInt(); - stripSegmentName = false; - } else { - count = firstInt; - stripSegmentName = true; - } - - // read the directory and init files - FileEntry entry = null; - for (int i=0; i length) - throw new IOException("read past EOF"); - base.seek(fileOffset + start); - base.readBytes(b, offset, len, false); - } - - /** Expert: implements seek. Sets current position in this file, where - * the next {@link #readInternal(byte[],int,int)} will occur. - * @see #readInternal(byte[],int,int) - */ - @Override - protected void seekInternal(long pos) {} - - /** Closes the stream to further operations. */ - @Override - public void close() throws IOException { - base.close(); - } - - @Override - public long length() { - return length; - } - - @Override - public void copyBytes(IndexOutput out, long numBytes) throws IOException { - // Copy first whatever is in the buffer - numBytes -= flushBuffer(out, numBytes); - - // If there are more bytes left to copy, delegate the copy task to the - // base IndexInput, in case it can do an optimized copy. - if (numBytes > 0) { - long start = getFilePointer(); - if (start + numBytes > length) { - throw new IOException("read past EOF"); - } - base.seek(fileOffset + start); - base.copyBytes(out, numBytes); - } - } - } -}