mirror of https://github.com/apache/lucene.git
LUCENE-4055: nuke more mutability
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4055@1340108 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a6207d9c04
commit
be52287d6e
|
@ -38,12 +38,10 @@ import org.apache.lucene.util.IOUtils;
|
|||
|
||||
public class SepDocValuesConsumer extends DocValuesWriterBase {
|
||||
private final Directory directory;
|
||||
private final FieldInfos fieldInfos;
|
||||
|
||||
public SepDocValuesConsumer(PerDocWriteState state) throws IOException {
|
||||
super(state);
|
||||
this.directory = state.directory;
|
||||
fieldInfos = state.fieldInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -560,7 +560,7 @@ class DocumentsWriterPerThread {
|
|||
|
||||
PerDocWriteState newPerDocWriteState(String segmentSuffix) {
|
||||
assert segment != null;
|
||||
return new PerDocWriteState(infoStream, directory, segment, fieldInfos, bytesUsed, segmentSuffix, IOContext.DEFAULT);
|
||||
return new PerDocWriteState(infoStream, directory, segment, bytesUsed, segmentSuffix, IOContext.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,18 +33,16 @@ public class PerDocWriteState {
|
|||
public final InfoStream infoStream;
|
||||
public final Directory directory;
|
||||
public final String segmentName;
|
||||
public final FieldInfos fieldInfos;
|
||||
public final Counter bytesUsed;
|
||||
public final String segmentSuffix;
|
||||
public final IOContext context;
|
||||
|
||||
public PerDocWriteState(InfoStream infoStream, Directory directory,
|
||||
String segmentName, FieldInfos fieldInfos, Counter bytesUsed,
|
||||
String segmentName, Counter bytesUsed,
|
||||
String segmentSuffix, IOContext context) {
|
||||
this.infoStream = infoStream;
|
||||
this.directory = directory;
|
||||
this.segmentName = segmentName;
|
||||
this.fieldInfos = fieldInfos;
|
||||
this.segmentSuffix = segmentSuffix;
|
||||
this.bytesUsed = bytesUsed;
|
||||
this.context = context;
|
||||
|
@ -54,7 +52,6 @@ public class PerDocWriteState {
|
|||
infoStream = state.infoStream;
|
||||
directory = state.directory;
|
||||
segmentName = state.segmentName;
|
||||
fieldInfos = state.fieldInfos;
|
||||
segmentSuffix = state.segmentSuffix;
|
||||
bytesUsed = Counter.newCounter();
|
||||
context = state.context;
|
||||
|
@ -64,7 +61,6 @@ public class PerDocWriteState {
|
|||
this.infoStream = state.infoStream;
|
||||
this.directory = state.directory;
|
||||
this.segmentName = state.segmentName;
|
||||
this.fieldInfos = state.fieldInfos;
|
||||
this.segmentSuffix = segmentSuffix;
|
||||
this.bytesUsed = state.bytesUsed;
|
||||
this.context = state.context;
|
||||
|
|
|
@ -248,11 +248,11 @@ public class TestCodecs extends LuceneTestCase {
|
|||
terms[i] = new TermData(text, docs, null);
|
||||
}
|
||||
|
||||
final MutableFieldInfos fieldInfos = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
|
||||
final MutableFieldInfos builder = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
|
||||
|
||||
final FieldData field = new FieldData("field", fieldInfos, terms, true, false);
|
||||
final FieldData field = new FieldData("field", builder, terms, true, false);
|
||||
final FieldData[] fields = new FieldData[] {field};
|
||||
|
||||
final FieldInfos fieldInfos = builder.finish();
|
||||
final Directory dir = newDirectory();
|
||||
this.write(fieldInfos, dir, fields, true);
|
||||
Codec codec = Codec.getDefault();
|
||||
|
@ -294,16 +294,17 @@ public class TestCodecs extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testRandomPostings() throws Throwable {
|
||||
final MutableFieldInfos fieldInfos = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
|
||||
final MutableFieldInfos builder = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
|
||||
|
||||
final FieldData[] fields = new FieldData[NUM_FIELDS];
|
||||
for(int i=0;i<NUM_FIELDS;i++) {
|
||||
final boolean omitTF = 0==(i%3);
|
||||
final boolean storePayloads = 1==(i%3);
|
||||
fields[i] = new FieldData(fieldNames[i], fieldInfos, this.makeRandomTerms(omitTF, storePayloads), omitTF, storePayloads);
|
||||
fields[i] = new FieldData(fieldNames[i], builder, this.makeRandomTerms(omitTF, storePayloads), omitTF, storePayloads);
|
||||
}
|
||||
|
||||
final Directory dir = newDirectory();
|
||||
final FieldInfos fieldInfos = builder.finish();
|
||||
|
||||
if (VERBOSE) {
|
||||
System.out.println("TEST: now write postings");
|
||||
|
|
|
@ -46,10 +46,11 @@ public class TestFieldInfos extends LuceneTestCase {
|
|||
public FieldInfos createAndWriteFieldInfos(Directory dir, String filename) throws IOException{
|
||||
//Positive test of FieldInfos
|
||||
assertTrue(testDoc != null);
|
||||
MutableFieldInfos fieldInfos = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
|
||||
MutableFieldInfos builder = new MutableFieldInfos(new MutableFieldInfos.FieldNumberBiMap());
|
||||
for (IndexableField field : testDoc) {
|
||||
fieldInfos.addOrUpdate(field.name(), field.fieldType());
|
||||
builder.addOrUpdate(field.name(), field.fieldType());
|
||||
}
|
||||
FieldInfos fieldInfos = builder.finish();
|
||||
//Since the complement is stored as well in the fields map
|
||||
assertTrue(fieldInfos.size() == DocHelper.all.size()); //this is all b/c we are using the no-arg constructor
|
||||
|
||||
|
|
Loading…
Reference in New Issue