Skip to content

Commit 87e58df

Browse files
committed
improve comments
1 parent c16bb67 commit 87e58df

File tree

1 file changed

+16
-8
lines changed
  • lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree

1 file changed

+16
-8
lines changed

lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/TrieBuilder.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ class TrieBuilder {
4343
static final long NON_LEAF_NODE_HAS_TERMS = 1L << 1;
4444
static final long NON_LEAF_NODE_HAS_FLOOR = 1L << 0;
4545

46-
// describes the on-disk terms block which a trie node points to.
47-
// floorData is non-null when a large block of terms sharing a single trie prefix is split into
48-
// multiple on-disk blocks.
49-
// hasTerms is false if this on-disk block consists entirely of pointers to child blocks.
46+
/**
47+
* The output describing the term block the prefix point to.
48+
*
49+
* @param fp describes the on-disk terms block which a trie node points to.
50+
* @param hasTerms A boolean which will be false if this on-disk block consists entirely of
51+
* pointers to child blocks.
52+
* @param floorData A {@link BytesRef} which will be non-null when a large block of terms sharing
53+
* a single trie prefix is split into multiple on-disk blocks.
54+
*/
5055
record Output(long fp, boolean hasTerms, BytesRef floorData) {}
5156

5257
private enum Status {
@@ -56,16 +61,18 @@ private enum Status {
5661
}
5762

5863
private static class Node {
59-
// the utf8 digit that leads to this Node, and 0 for root node
64+
// The utf8 digit that leads to this Node, 0 for root node
6065
private final int label;
61-
// children listed in order by their utf8 label
66+
// The children listed in order by their utf8 label
6267
private final LinkedList<Node> children;
68+
// The output of this node.
6369
private Output output;
6470

6571
// Vars used during saving:
6672

67-
// -1 means the node has not been saved.
73+
// The file pointer point to where the node saved. -1 means the node has not been saved.
6874
private long fp = -1;
75+
// The iterator whose next() point to the first child has not been saved.
6976
private Iterator<Node> childrenIterator;
7077

7178
Node(int label, Output output, LinkedList<Node> children) {
@@ -145,7 +152,9 @@ Output getEmptyOutput() {
145152
return root.output;
146153
}
147154

155+
/** Used for tests only. */
148156
void visit(BiConsumer<BytesRef, Output> consumer) {
157+
assert status == Status.BUILDING;
149158
if (root.output != null) {
150159
consumer.accept(new BytesRef(), root.output);
151160
}
@@ -252,7 +261,6 @@ void saveNodes(IndexOutput index) throws IOException {
252261
if (node.output != null) {
253262
Output output = node.output;
254263
long encodedFp = encodeFP(output);
255-
;
256264
writeLongNBytes(encodedFp, encodedOutputFpBytes, index);
257265
if (output.floorData != null) {
258266
index.writeBytes(

0 commit comments

Comments
 (0)