Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #275 from wolfgangmm/develop

[performance] ngram index: method for computing string offsets
  • Loading branch information...
commit 20292fc7ec78f592a376f17882003a9b1f7e02fa 2 parents 4b889ea + 340364c
ljo ljo authored
14 extensions/indexes/ngram/src/org/exist/indexing/ngram/NGramIndexWorker.java
View
@@ -578,18 +578,18 @@ public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert,
}
private void indexText(NodeId nodeId, QName qname, String text) {
- String[] ngram = tokenize(text);
- int len = ngram.length;
- for (int i = 0; i < len; i++) {
- int offset = text.offsetByCodePoints(0, i);
- QNameTerm key = new QNameTerm(qname, ngram[i]);
+ final String[] ngram = tokenize(text);
+ final int len = text.length();
+ for (int i = 0, j = 0, cp; i < len; i += Character.charCount(cp), j++) {
+ cp = text.codePointAt(i);
+ final QNameTerm key = new QNameTerm(qname, ngram[j]);
OccurrenceList list = ngrams.get(key);
if (list == null) {
list = new OccurrenceList();
- list.add(nodeId, offset);
+ list.add(nodeId, i);
ngrams.put(key, list);
} else {
- list.add(nodeId, offset);
+ list.add(nodeId, i);
}
}
}
1  extensions/indexes/ngram/src/org/exist/xquery/modules/ngram/NGramSearch.java
View
@@ -136,6 +136,7 @@ public NGramSearch(XQueryContext context, FunctionSignature signature) {
@Override
public void setArguments(List<Expression> arguments) throws XPathException {
+ steps.clear();
Expression path = arguments.get(0);
steps.add(path);
Please sign in to comment.
Something went wrong with that request. Please try again.