mirror of https://github.com/apache/lucene.git
LUCENE-4591: Make CompressingStoredFields{Writer,Reader} accept a segment suffix as a constructor parameter.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1419449 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dffaebd814
commit
b549619dc8
|
@ -156,6 +156,9 @@ API Changes
|
||||||
RateLimitingDirectoryWrapper. Any Directory can now be rate-limited.
|
RateLimitingDirectoryWrapper. Any Directory can now be rate-limited.
|
||||||
(Simon Willnauer)
|
(Simon Willnauer)
|
||||||
|
|
||||||
|
* LUCENE-4591: CompressingStoredFields{Writer,Reader} now accept a segment
|
||||||
|
suffix as a constructor parameter. (Renaud Delbru via Adrien Grand)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
* LUCENE-1822: BaseFragListBuilder hard-coded 6 char margin is too naive.
|
* LUCENE-1822: BaseFragListBuilder hard-coded 6 char margin is too naive.
|
||||||
|
|
|
@ -93,13 +93,13 @@ public class CompressingStoredFieldsFormat extends StoredFieldsFormat {
|
||||||
@Override
|
@Override
|
||||||
public StoredFieldsReader fieldsReader(Directory directory, SegmentInfo si,
|
public StoredFieldsReader fieldsReader(Directory directory, SegmentInfo si,
|
||||||
FieldInfos fn, IOContext context) throws IOException {
|
FieldInfos fn, IOContext context) throws IOException {
|
||||||
return new CompressingStoredFieldsReader(directory, si, fn, context, formatName, compressionMode);
|
return new CompressingStoredFieldsReader(directory, si, "", fn, context, formatName, compressionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StoredFieldsWriter fieldsWriter(Directory directory, SegmentInfo si,
|
public StoredFieldsWriter fieldsWriter(Directory directory, SegmentInfo si,
|
||||||
IOContext context) throws IOException {
|
IOContext context) throws IOException {
|
||||||
return new CompressingStoredFieldsWriter(directory, si, context,
|
return new CompressingStoredFieldsWriter(directory, si, "", context,
|
||||||
formatName, compressionMode, chunkSize);
|
formatName, compressionMode, chunkSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,11 @@ import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.packed.PackedInts;
|
import org.apache.lucene.util.packed.PackedInts;
|
||||||
|
|
||||||
final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
/**
|
||||||
|
* {@link StoredFieldsReader} impl for {@link CompressingStoredFieldsFormat}.
|
||||||
|
* @lucene.experimental
|
||||||
|
*/
|
||||||
|
public final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
||||||
|
|
||||||
private final FieldInfos fieldInfos;
|
private final FieldInfos fieldInfos;
|
||||||
private final CompressingStoredFieldsIndexReader indexReader;
|
private final CompressingStoredFieldsIndexReader indexReader;
|
||||||
|
@ -79,7 +83,8 @@ final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompressingStoredFieldsReader( Directory d, SegmentInfo si, FieldInfos fn,
|
/** Sole constructor. */
|
||||||
|
public CompressingStoredFieldsReader(Directory d, SegmentInfo si, String segmentSuffix, FieldInfos fn,
|
||||||
IOContext context, String formatName, CompressionMode compressionMode) throws IOException {
|
IOContext context, String formatName, CompressionMode compressionMode) throws IOException {
|
||||||
this.compressionMode = compressionMode;
|
this.compressionMode = compressionMode;
|
||||||
final String segment = si.name;
|
final String segment = si.name;
|
||||||
|
@ -88,8 +93,8 @@ final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
||||||
numDocs = si.getDocCount();
|
numDocs = si.getDocCount();
|
||||||
IndexInput indexStream = null;
|
IndexInput indexStream = null;
|
||||||
try {
|
try {
|
||||||
fieldsStream = d.openInput(IndexFileNames.segmentFileName(segment, "", FIELDS_EXTENSION), context);
|
fieldsStream = d.openInput(IndexFileNames.segmentFileName(segment, segmentSuffix, FIELDS_EXTENSION), context);
|
||||||
final String indexStreamFN = IndexFileNames.segmentFileName(segment, "", FIELDS_INDEX_EXTENSION);
|
final String indexStreamFN = IndexFileNames.segmentFileName(segment, segmentSuffix, FIELDS_INDEX_EXTENSION);
|
||||||
indexStream = d.openInput(indexStreamFN, context);
|
indexStream = d.openInput(indexStreamFN, context);
|
||||||
|
|
||||||
final String codecNameIdx = formatName + CODEC_SFX_IDX;
|
final String codecNameIdx = formatName + CODEC_SFX_IDX;
|
||||||
|
@ -123,6 +128,9 @@ final class CompressingStoredFieldsReader extends StoredFieldsReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the underlying {@link IndexInput}s.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (!closed) {
|
if (!closed) {
|
||||||
|
|
|
@ -47,7 +47,11 @@ import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.packed.PackedInts;
|
import org.apache.lucene.util.packed.PackedInts;
|
||||||
|
|
||||||
final class CompressingStoredFieldsWriter extends StoredFieldsWriter {
|
/**
|
||||||
|
* {@link StoredFieldsWriter} impl for {@link CompressingStoredFieldsFormat}.
|
||||||
|
* @lucene.experimental
|
||||||
|
*/
|
||||||
|
public final class CompressingStoredFieldsWriter extends StoredFieldsWriter {
|
||||||
|
|
||||||
static final int STRING = 0x00;
|
static final int STRING = 0x00;
|
||||||
static final int BYTE_ARR = 0x01;
|
static final int BYTE_ARR = 0x01;
|
||||||
|
@ -79,7 +83,8 @@ final class CompressingStoredFieldsWriter extends StoredFieldsWriter {
|
||||||
private int docBase; // doc ID at the beginning of the chunk
|
private int docBase; // doc ID at the beginning of the chunk
|
||||||
private int numBufferedDocs; // docBase + numBufferedDocs == current doc ID
|
private int numBufferedDocs; // docBase + numBufferedDocs == current doc ID
|
||||||
|
|
||||||
public CompressingStoredFieldsWriter(Directory directory, SegmentInfo si, IOContext context,
|
/** Sole constructor. */
|
||||||
|
public CompressingStoredFieldsWriter(Directory directory, SegmentInfo si, String segmentSuffix, IOContext context,
|
||||||
String formatName, CompressionMode compressionMode, int chunkSize) throws IOException {
|
String formatName, CompressionMode compressionMode, int chunkSize) throws IOException {
|
||||||
assert directory != null;
|
assert directory != null;
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
|
@ -94,9 +99,9 @@ final class CompressingStoredFieldsWriter extends StoredFieldsWriter {
|
||||||
this.numBufferedDocs = 0;
|
this.numBufferedDocs = 0;
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
IndexOutput indexStream = directory.createOutput(IndexFileNames.segmentFileName(segment, "", FIELDS_INDEX_EXTENSION), context);
|
IndexOutput indexStream = directory.createOutput(IndexFileNames.segmentFileName(segment, segmentSuffix, FIELDS_INDEX_EXTENSION), context);
|
||||||
try {
|
try {
|
||||||
fieldsStream = directory.createOutput(IndexFileNames.segmentFileName(segment, "", FIELDS_EXTENSION), context);
|
fieldsStream = directory.createOutput(IndexFileNames.segmentFileName(segment, segmentSuffix, FIELDS_EXTENSION), context);
|
||||||
|
|
||||||
final String codecNameIdx = formatName + CODEC_SFX_IDX;
|
final String codecNameIdx = formatName + CODEC_SFX_IDX;
|
||||||
final String codecNameDat = formatName + CODEC_SFX_DAT;
|
final String codecNameDat = formatName + CODEC_SFX_DAT;
|
||||||
|
|
Loading…
Reference in New Issue