Search in sources :

Example 1 with RangeIndexConfigElement

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;
}
Also used : RangeIndexConfigElement(org.exist.indexing.range.RangeIndexConfigElement)

Example 2 with RangeIndexConfigElement

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;
}
Also used : IndexSpec(org.exist.storage.IndexSpec) RangeIndexConfigElement(org.exist.indexing.range.RangeIndexConfigElement) Collection(org.exist.collections.Collection) RangeIndexConfig(org.exist.indexing.range.RangeIndexConfig) NodePath(org.exist.storage.NodePath)

Example 3 with RangeIndexConfigElement

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;
}
Also used : RangeIndexConfigElement(org.exist.indexing.range.RangeIndexConfigElement)

Aggregations

RangeIndexConfigElement (org.exist.indexing.range.RangeIndexConfigElement)3 Collection (org.exist.collections.Collection)1 RangeIndexConfig (org.exist.indexing.range.RangeIndexConfig)1 IndexSpec (org.exist.storage.IndexSpec)1 NodePath (org.exist.storage.NodePath)1