Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion lucene/core/src/java/org/apache/lucene/index/MergeState.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,86 @@ public class MergeState {
/** Indicates if the index needs to be sorted * */
public boolean needsIndexSort;

/** Sole constructor. */
/** Returns the document ID maps. */
public DocMap[] getDocMaps() {
return docMaps;
}

/** Returns the segment info of the newly merged segment. */
public SegmentInfo getSegmentInfo() {
return segmentInfo;
}

/** Returns the field infos of the newly merged segment. */
public FieldInfos getMergeFieldInfos() {
return mergeFieldInfos;
}

/** Returns the stored fields readers being merged. */
public StoredFieldsReader[] getStoredFieldsReaders() {
return storedFieldsReaders;
}

/** Returns the term vectors readers being merged. */
public TermVectorsReader[] getTermVectorsReaders() {
return termVectorsReaders;
}

/** Returns the norms producers being merged. */
public NormsProducer[] getNormsProducers() {
return normsProducers;
}

/** Returns the DocValues producers being merged. */
public DocValuesProducer[] getDocValuesProducers() {
return docValuesProducers;
}

/** Returns the field infos being merged. */
public FieldInfos[] getFieldInfos() {
return fieldInfos;
}

/** Returns the live docs for each reader. */
public Bits[] getLiveDocs() {
return liveDocs;
}

/** Returns the postings to merge. */
public FieldsProducer[] getFieldsProducers() {
return fieldsProducers;
}

/** Returns the point readers to merge. */
public PointsReader[] getPointsReaders() {
return pointsReaders;
}

/** Returns the vector readers to merge. */
public KnnVectorsReader[] getKnnVectorsReaders() {
return knnVectorsReaders;
}

/** Returns the max docs per reader. */
public int[] getMaxDocs() {
return maxDocs;
}

/** Returns the info stream for debugging messages. */
public InfoStream getInfoStream() {
return infoStream;
}

/** Returns the executor for intra merge activity. */
public Executor getIntraMergeTaskExecutor() {
return intraMergeTaskExecutor;
}

/** Returns whether the index needs to be sorted. */
public boolean getNeedsIndexSort() {
return needsIndexSort;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a getter to a public field is senseless java verbosity: it adds no value. The field is public: just access the field directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing. I fully understand that you can just use public fields but that's not the point. Like what I mentioned in the description, it provides better testability, we can easily mock a member function but we can't mock a field access.

Apart from that, it's not good practice to have public fields as it doesn't provide good encapsulation. It's just the fields are already public and for backward compatibility, we can't change them to private.


MergeState(
List<CodecReader> readers,
SegmentInfo segmentInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,9 @@ private void generationAdvanced() {
public byte[] getId() {
return id == null ? null : id.clone();
}

/** Returns the SegmentInfo that we wrap. */
public SegmentInfo getInfo() {
return info;
}
}
Loading