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();
}
Aggregations