use of org.exist.indexing.range.RangeIndexConfigElement in project exist by eXist-db.
the class Lookup method canOptimize.
@Override
public boolean canOptimize(Sequence contextSequence) {
if (contextQName == null) {
return false;
}
RangeIndexConfigElement rice = findConfiguration(contextSequence);
if (rice == null) {
canOptimize = false;
if (fallback instanceof Optimizable) {
return ((Optimizable) fallback).canOptimize(contextSequence);
}
return false;
}
usesCollation = rice.usesCollation();
canOptimize = true;
return canOptimize;
}
use of org.exist.indexing.range.RangeIndexConfigElement in project exist by eXist-db.
the class Lookup method findConfiguration.
private RangeIndexConfigElement findConfiguration(Sequence contextSequence) {
NodePath path = contextPath;
if (path == null) {
if (contextQName == null) {
return null;
}
path = new NodePath(contextQName);
}
for (final Iterator<Collection> i = contextSequence.getCollectionIterator(); i.hasNext(); ) {
final Collection collection = i.next();
if (collection.getURI().startsWith(XmldbURI.SYSTEM_COLLECTION_URI)) {
continue;
}
IndexSpec idxConf = collection.getIndexConfiguration(context.getBroker());
if (idxConf != null) {
RangeIndexConfig config = (RangeIndexConfig) idxConf.getCustomIndexSpec(RangeIndex.ID);
if (config != null) {
RangeIndexConfigElement rice = config.find(path);
if (rice != null && !rice.isComplex()) {
return rice;
}
}
}
}
return null;
}
use of org.exist.indexing.range.RangeIndexConfigElement in project exist by eXist-db.
the class Lookup method getKeys.
private AtomicValue[] getKeys(Sequence contextSequence) throws XPathException {
RangeIndexConfigElement config = findConfiguration(contextSequence);
int targetType = config != null ? config.getType() : Type.ITEM;
Sequence keySeq = Atomize.atomize(getArgument(1).eval(contextSequence));
AtomicValue[] keys = new AtomicValue[keySeq.getItemCount()];
for (int i = 0; i < keys.length; i++) {
if (targetType == Type.ITEM) {
keys[i] = (AtomicValue) keySeq.itemAt(i);
} else {
keys[i] = keySeq.itemAt(i).convertTo(targetType);
}
}
return keys;
}
Aggregations