Inline OrdinalsStore#addOrdinal

Relates #16725
This commit is contained in:
Jason Tedor 2016-02-13 09:15:29 -05:00
parent 6a66882e46
commit 9e52bcd166
1 changed files with 44 additions and 37 deletions

View File

@ -190,8 +190,14 @@ public final class OrdinalsBuilder implements Closeable {
public int addOrdinal(int docID, long ordinal) { public int addOrdinal(int docID, long ordinal) {
final long position = positions.get(docID); final long position = positions.get(docID);
if (position == 0L) { // on the first level if (position == 0L) { // on the first level
return firstLevel(docID, ordinal);
} else {
return nonFirstLevel(docID, ordinal, position);
}
}
private int firstLevel(int docID, long ordinal) {
// 0 or 1 ordinal // 0 or 1 ordinal
if (firstOrdinals.get(docID) == 0L) { if (firstOrdinals.get(docID) == 0L) {
firstOrdinals.set(docID, ordinal + 1); firstOrdinals.set(docID, ordinal + 1);
@ -207,7 +213,9 @@ public final class OrdinalsBuilder implements Closeable {
positions.set(docID, position(1, offset)); // current position is on the 1st level and not allocated yet positions.set(docID, position(1, offset)); // current position is on the 1st level and not allocated yet
return 2; return 2;
} }
} else { }
private int nonFirstLevel(int docID, long ordinal, long position) {
int level = level(position); int level = level(position);
long offset = offset(position, level); long offset = offset(position, level);
assert offset != 0L; assert offset != 0L;
@ -230,7 +238,6 @@ public final class OrdinalsBuilder implements Closeable {
positions.set(docID, newPosition); positions.set(docID, newPosition);
return numOrdinals(level, offset); return numOrdinals(level, offset);
} }
}
public void appendOrdinals(int docID, LongsRef ords) { public void appendOrdinals(int docID, LongsRef ords) {
// First level // First level