use of org.exist.storage.NodePath in project exist by eXist-db.
the class ContentFunctions method streamContent.
private Sequence streamContent(ContentExtraction ce, BinaryValue binary, Sequence pathSeq, FunctionReference ref, Map<String, String> mappings, Sequence data) throws XPathException {
NodePath[] paths = new NodePath[pathSeq.getItemCount()];
int i = 0;
for (SequenceIterator iter = pathSeq.iterate(); iter.hasNext(); i++) {
String path = iter.nextItem().getStringValue();
paths[i] = new NodePath(mappings, path, false);
}
ContentReceiver receiver = new ContentReceiver(context, paths, ref, data);
try {
ce.extractContentAndMetadata(binary, receiver);
} catch (IOException | SAXException | ContentExtractionException ex) {
LOG.error(ex.getMessage(), ex);
throw new XPathException(this, ex.getMessage(), ex);
}
return receiver.getResult();
}
use of org.exist.storage.NodePath in project exist by eXist-db.
the class IndexStatisticsWorker method updateDocument.
private void updateDocument(final DBBroker broker, final DocumentImpl doc) {
final ElementImpl root = (ElementImpl) doc.getDocumentElement();
final int rootLevel = root.getNodeId().getTreeLevel();
try {
final NodePath path = new NodePath();
final Deque<NodeStats> stack = new ArrayDeque<>();
final ExtendedXMLStreamReader reader = broker.getXMLStreamReader(root, false);
while (reader.hasNext()) {
final int status = reader.next();
switch(status) {
case XMLStreamReader.START_ELEMENT:
for (final NodeStats next : stack) {
next.incDepth();
}
final QName qname = reader.getQName();
path.addComponent(qname);
final NodeStats nodeStats = perDocGuide.add(path);
stack.push(nodeStats);
break;
case XMLStreamReader.END_ELEMENT:
path.removeLastComponent();
final NodeStats stats = stack.pop();
stats.updateMaxDepth();
final NodeId otherId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID);
final int otherLevel = otherId.getTreeLevel();
if (otherLevel == rootLevel) {
// exit-while
break;
}
break;
}
}
} catch (final IOException | XMLStreamException e) {
e.printStackTrace();
}
}
use of org.exist.storage.NodePath in project exist by eXist-db.
the class NodeStats method mergeInto.
protected void mergeInto(DataGuide other, NodePath currentPath) {
NodePath newPath;
if (qname == null) {
newPath = currentPath;
} else {
newPath = new NodePath(currentPath);
newPath.addComponent(qname);
other.add(newPath, this);
}
if (children != null) {
for (final NodeStats child : children) {
child.mergeInto(other, newPath);
}
}
}
use of org.exist.storage.NodePath in project exist by eXist-db.
the class RangeQueryRewriter method toNodePath.
protected static NodePath toNodePath(List<LocationStep> steps) {
NodePath path = new NodePath();
for (LocationStep step : steps) {
if (step == null) {
return null;
}
NodeTest test = step.getTest();
if (test.isWildcardTest() && step.getAxis() == Constants.SELF_AXIS) {
// return path;
continue;
}
if (!test.isWildcardTest() && test.getName() != null) {
int axis = step.getAxis();
if (axis == Constants.DESCENDANT_AXIS || axis == Constants.DESCENDANT_SELF_AXIS) {
path.addComponent(NodePath.SKIP);
} else if (axis != Constants.CHILD_AXIS && axis != Constants.ATTRIBUTE_AXIS) {
// not optimizable
return null;
}
path.addComponent(test.getName());
}
}
return path;
}
Aggregations