You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by so...@apache.org on 2019/06/18 20:41:28 UTC
[lucene-solr] branch branch_8x updated: LUCENE-8781: add FST
array-with-gap addressing to Util.readCeilArc
This is an automated email from the ASF dual-hosted git repository.
sokolov pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new badcc4e LUCENE-8781: add FST array-with-gap addressing to Util.readCeilArc
badcc4e is described below
commit badcc4e6c723678cda9c7990a8d2c4bf1e556f42
Author: Michael Sokolov <so...@amazon.com>
AuthorDate: Fri Jun 14 20:47:18 2019 -0400
LUCENE-8781: add FST array-with-gap addressing to Util.readCeilArc
---
.../core/src/java/org/apache/lucene/util/fst/Util.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/Util.java b/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
index 04cd182..f8dd6fd 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
@@ -924,7 +924,7 @@ public final class Util {
*/
/**
- * Reads the first arc greater or equal that the given label into the provided
+ * Reads the first arc greater or equal than the given label into the provided
* arc in place and returns it iff found, otherwise return <code>null</code>.
*
* @param label the label to ceil on
@@ -958,7 +958,19 @@ public final class Util {
}
fst.readFirstTargetArc(follow, arc, in);
if (arc.bytesPerArc != 0 && arc.label != FST.END_LABEL) {
- // Arcs are fixed array -- use binary search to find
+ if (arc.arcIdx == Integer.MIN_VALUE) {
+ // Arcs are in an array-with-gaps
+ int offset = label - arc.label;
+ if (offset >= arc.numArcs) {
+ return null;
+ } else if (offset < 0) {
+ return arc;
+ } else {
+ arc.nextArc = arc.posArcsStart - offset * arc.bytesPerArc;
+ return fst.readNextRealArc(arc, in);
+ }
+ }
+ // Arcs are packed array -- use binary search to find
// the target.
int low = arc.arcIdx;