Search in sources :

Example 1 with IndexStatistics

use of org.exist.storage.statistics.IndexStatistics in project exist by eXist-db.

the class GetIndexStatistics method eval.

public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    final IndexStatistics index = (IndexStatistics) context.getBroker().getBrokerPool().getIndexManager().getIndexById(IndexStatistics.ID);
    if (index == null) {
        // module may not be enabled
        return Sequence.EMPTY_SEQUENCE;
    }
    final SAXAdapter adapter = new SAXAdapter(context);
    try {
        adapter.startDocument();
        index.toSAX(adapter);
        adapter.endDocument();
    } catch (final SAXException e) {
        throw new XPathException(this, "Error caught while retrieving statistics: " + e.getMessage(), e);
    }
    final DocumentImpl doc = (DocumentImpl) adapter.getDocument();
    return (NodeImpl) doc.getFirstChild();
}
Also used : IndexStatistics(org.exist.storage.statistics.IndexStatistics) NodeImpl(org.exist.dom.memtree.NodeImpl) XPathException(org.exist.xquery.XPathException) SAXAdapter(org.exist.dom.memtree.SAXAdapter) DocumentImpl(org.exist.dom.memtree.DocumentImpl) SAXException(org.xml.sax.SAXException)

Aggregations

DocumentImpl (org.exist.dom.memtree.DocumentImpl)1 NodeImpl (org.exist.dom.memtree.NodeImpl)1 SAXAdapter (org.exist.dom.memtree.SAXAdapter)1 IndexStatistics (org.exist.storage.statistics.IndexStatistics)1 XPathException (org.exist.xquery.XPathException)1 SAXException (org.xml.sax.SAXException)1