TermVectorsReader(Directory d,
String segment,
FieldInfos fieldInfos,
int readBufferSize) throws IOException, CorruptIndexException {
this(d, segment, fieldInfos, BufferedIndexInput.BUFFER_SIZE, -1, 0);
}
|
TermVectorsReader(Directory d,
String segment,
FieldInfos fieldInfos,
int readBufferSize,
int docStoreOffset,
int size) throws IOException, CorruptIndexException {
boolean success = false;
try {
if (d.fileExists(segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION)) {
tvx = d.openInput(segment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION, readBufferSize);
checkValidFormat(tvx);
tvd = d.openInput(segment + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION, readBufferSize);
tvdFormat = checkValidFormat(tvd);
tvf = d.openInput(segment + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION, readBufferSize);
tvfFormat = checkValidFormat(tvf);
if (-1 == docStoreOffset) {
this.docStoreOffset = 0;
this.size = (int) (tvx.length() > > 3);
} else {
this.docStoreOffset = docStoreOffset;
this.size = size;
// Verify the file is long enough to hold all of our
// docs
assert ((int) (tvx.length() / 8)) >= size + docStoreOffset;
}
}
this.fieldInfos = fieldInfos;
success = true;
} finally {
// With lock-less commits, it's entirely possible (and
// fine) to hit a FileNotFound exception above. In
// this case, we want to explicitly close any subset
// of things that were opened so that we don't have to
// wait for a GC to do so.
if (!success) {
close();
}
}
}
|