Skip to content

Commit

Permalink
Merge remote-tracking branch 'eXist/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shabanovd committed Nov 6, 2013
2 parents 7d6ff1f + f0d5858 commit 7cd023d
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,13 @@ protected Properties parseOptions(Sequence contextSequence, Item contextItem) th
throw new XPathException(this, "Error while parsing options to ft:query: " + e.getMessage(), e);
}
}

@Override
public void resetState(boolean postOptimization) {
super.resetState(postOptimization);
if (!postOptimization) {
preselectResult = null;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,13 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
}
return result;
}

@Override
public void resetState(boolean postOptimization) {
super.resetState(postOptimization);
if (!postOptimization) {
preselectResult = null;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@ public Analyzer getAnalyzer(QName qname, String fieldName) {
return analyzer;
}

public boolean isCaseSensitive(QName qname, String fieldName) {
boolean caseSensitive = true;
if (qname != null) {
RangeIndexConfigElement idxConf = paths.get(qname);
if (idxConf != null) {
caseSensitive = idxConf.isCaseSensitive();
}
} else {
for (RangeIndexConfigElement idxConf: paths.values()) {
if (idxConf.isComplex()) {
caseSensitive = idxConf.isCaseSensitive();
if (!caseSensitive) {
break;
}
}
}
}
return caseSensitive;
}

public Iterator<RangeIndexConfigElement> getConfig(NodePath path) {
iterator.reset(path);
return iterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public Analyzer getAnalyzer(String field) {
return analyzer;
}

public boolean isCaseSensitive() {
return caseSensitive;
}

public boolean isComplex() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,16 @@ private List<QName> getDefinedIndexesFor(QName qname, List<QName> indexes) {
}

protected BytesRef analyzeContent(String field, QName qname, AtomicValue content, DocumentSet docs) throws XPathException {
Analyzer analyzer = getAnalyzer(qname, field, docs);
final Analyzer analyzer = getAnalyzer(qname, field, docs);
String data = content.getStringValue();
if (!isCaseSensitive(qname, field, docs)) {
data = data.toLowerCase();
}
if (analyzer == null) {
return new BytesRef(content.getStringValue());
return new BytesRef(data);
}
try {
TokenStream stream = analyzer.tokenStream(field, new StringReader(content.getStringValue()));
TokenStream stream = analyzer.tokenStream(field, new StringReader(data));
TermToBytesRefAttribute termAttr = stream.addAttribute(TermToBytesRefAttribute.class);
BytesRef token = null;
try {
Expand Down Expand Up @@ -723,6 +727,24 @@ private Analyzer getAnalyzer(QName qname, String fieldName, DocumentSet docs) {
return null;
}

/**
* Return the analyzer to be used for the given field or qname. Either field
* or qname should be specified.
*/
private boolean isCaseSensitive(QName qname, String fieldName, DocumentSet docs) {
for (Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext(); ) {
Collection collection = i.next();
IndexSpec idxConf = collection.getIndexConfiguration(broker);
if (idxConf != null) {
RangeIndexConfig config = (RangeIndexConfig) idxConf.getCustomIndexSpec(RangeIndex.ID);
if (config != null && !config.isCaseSensitive(qname, fieldName)) {
return false;
}
}
}
return true;
}

private static boolean matchQName(QName qname, QName candidate) {
boolean match = true;
if (qname.getLocalName() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,13 @@ public int getDependencies() {
public int returnsType() {
return Type.NODE;
}

@Override
public void resetState(boolean postOptimization) {
super.resetState(postOptimization);
fallback.resetState(postOptimization);
if (!postOptimization) {
preselectResult = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
return result;
}

@Override
public void resetState(boolean postOptimization) {
super.resetState(postOptimization);
fallback.resetState(postOptimization);
if (!postOptimization) {
preselectResult = null;
}
}

@Override
public boolean canOptimize(Sequence contextSequence) {
return contextQName != null;
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/xquery/ExternalModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void setIsReady(boolean ready) {
}

public boolean isReady() {
return false;
return isReady;
}

/* (non-Javadoc)
Expand Down

0 comments on commit 7cd023d

Please sign in to comment.