Package org.exist.dom

Examples of org.exist.dom.NodeSet


      {return NodeSet.EMPTY_SET;}
  }

    protected NodeSet[] getMatches(DocumentSet docs, NodeSet contextSet, int axis, QName qname, List<String> terms)
    throws XPathException {
        final NodeSet hits[] = new NodeSet[terms.size()];
        for (int k = 0; k < terms.size(); k++) {
            hits[k] =
                    context.getBroker().getTextEngine().getNodesContaining(
                            context,
                            docs,
View Full Code Here


                return Sequence.EMPTY_SEQUENCE;
            } else {
                return fallback.eval(contextSequence, contextItem);
            }
        }
        NodeSet result;
        if (preselectResult == null) {
            long start = System.currentTimeMillis();
            Sequence input = getArgument(0).eval(contextSequence);
            if (!(input instanceof VirtualNodeSet) && input.isEmpty())
                result = NodeSet.EMPTY_SET;
            else {
                RangeIndexWorker index = (RangeIndexWorker) context.getBroker().getIndexController().getWorkerByIndexId(RangeIndex.ID);
                AtomicValue[] keys = getKeys(contextSequence);
                if (keys.length == 0) {
                    return NodeSet.EMPTY_SET;
                }
                List<QName> qnames = null;
                if (contextQName != null) {
                    qnames = new ArrayList<QName>(1);
                    qnames.add(contextQName);
                }
                final RangeIndex.Operator operator = getOperator();

                try {
                    NodeSet inNodes = input.toNodeSet();
                    DocumentSet docs = inNodes.getDocumentSet();
                    result = index.query(getExpressionId(), docs, inNodes, qnames, keys, operator, NodeSet.ANCESTOR);
                } catch (IOException e) {
                    throw new XPathException(this, e.getMessage());
                }
            }
View Full Code Here

    @Override
    public NodeSet eval(
        final NGramIndexWorker index, final DocumentSet docs, final List<QName> qnames, final NodeSet nodeSet,
        final int axis, final int expressionId) throws XPathException {

        final NodeSet headNodes = head.eval(index, docs, qnames, nodeSet, axis, expressionId);
        if (headNodes.isEmpty()) {
            return headNodes;
        }

        final NodeSet tailNodes = tail.eval(index, docs, qnames, nodeSet, axis, expressionId);
        if (tailNodes.isEmpty()) {
            return tailNodes;
        }

        NodeSet result = NodeSets.fmapNodes(headNodes, new F<NodeProxy, NodeProxy>() {

            @Override
            public NodeProxy f(NodeProxy headNode) {
                NodeProxy tailNode = tailNodes.get(headNode);
                if (tailNode != null) {
View Full Code Here

    @Override
    public NodeSet eval(
        final NGramIndexWorker index, final DocumentSet docs, final List<QName> qnames, final NodeSet nodeSet,
        final int axis, final int expressionId) throws XPathException {
        NodeSet result = new ExtArrayNodeSet();
        for (String s : strings) {
            result.addAll(nGramSearch.fixedStringSearch(index, docs, qnames, s, nodeSet, axis));
        }
        result.iterate(); // ensure result is ready to use
        return result;
    }
View Full Code Here

            ps.setDouble(2, EPSG4326_geometry.getEnvelopeInternal().getMaxX());
            ps.setDouble(3, EPSG4326_geometry.getEnvelopeInternal().getMinY());
            ps.setDouble(4, EPSG4326_geometry.getEnvelopeInternal().getMaxY());
        }
        ResultSet rs = null;
        NodeSet result = null;
        try {
            int disjointPostFiltered = 0;
            rs = ps.executeQuery();
            result = new ExtArrayNodeSet(); //new ExtArrayNodeSet(docs.getLength(), 250)
            while (rs.next()) {
                DocumentImpl doc = null;
                try {
                    doc = (DocumentImpl)broker.getXMLResource(XmldbURI.create(rs.getString("DOCUMENT_URI")));             
                } catch (PermissionDeniedException e) {
                    LOG.debug(e);
                    //Ignore since the broker has no right on the document
                    continue;
                }
                //contextSet == null should be used to scan the whole index
                if (contextSet == null || refine_query_on_doc || contextSet.getDocumentSet().contains(doc.getDocId())) {
                    NodeId nodeId = new DLN(rs.getInt("NODE_ID_UNITS"), rs.getBytes("NODE_ID"), 0);
                    NodeProxy p = new NodeProxy(doc, nodeId);
                    //Node is in the context : check if it is accurate
                    //contextSet.contains(p) would have made more sense but there is a problem with
                    //VirtualNodeSet when on the DESCENDANT_OR_SELF axis
                    if (contextSet == null || contextSet.get(p) != null) {
                        boolean geometryMatches = false;
                        if (spatialOp == SpatialOperator.DISJOINT) {
                            //No BBox intersection : obviously disjoint
                            if (rs.getDouble("EPSG4326_MAXX") < EPSG4326_geometry.getEnvelopeInternal().getMinX() ||
                                rs.getDouble("EPSG4326_MINX") > EPSG4326_geometry.getEnvelopeInternal().getMaxX() ||
                                rs.getDouble("EPSG4326_MAXY") < EPSG4326_geometry.getEnvelopeInternal().getMinY() ||
                                rs.getDouble("EPSG4326_MINY") > EPSG4326_geometry.getEnvelopeInternal().getMaxY()) {
                                geometryMatches = true;
                                disjointPostFiltered++; 
                            }
                        }
                        //Possible match : check the geometry
                        if (!geometryMatches) { 
                            try {
                                Geometry geometry = wkbReader.read(rs.getBytes("EPSG4326_WKB"));
                                switch (spatialOp) {
                                case SpatialOperator.EQUALS:
                                    geometryMatches = geometry.equals(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.DISJOINT:
                                    geometryMatches = geometry.disjoint(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.INTERSECTS:
                                    geometryMatches = geometry.intersects(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.TOUCHES:
                                    geometryMatches = geometry.touches(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.CROSSES:
                                    geometryMatches = geometry.crosses(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.WITHIN:
                                    geometryMatches = geometry.within(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.CONTAINS:
                                    geometryMatches = geometry.contains(EPSG4326_geometry);
                                    break;
                                case SpatialOperator.OVERLAPS:
                                    geometryMatches = geometry.overlaps(EPSG4326_geometry);
                                    break;
                                }
                            } catch (ParseException e) {
                                //Transforms the exception into an SQLException.
                                //Very unlikely to happen though...
                                SQLException ee = new SQLException(e.getMessage());
                                ee.initCause(e);
                                throw ee;
                            }
                        }
                        if (geometryMatches)
                            result.add(p);
                    }
                }
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug(rs.getRow() + " eligible geometries, " + result.getItemCount() + "selected" +
                    (spatialOp == SpatialOperator.DISJOINT ? "(" + disjointPostFiltered + " post filtered)" : ""));
            }
            return result;
        } finally {
            if (rs != null)
View Full Code Here

                return Sequence.EMPTY_SEQUENCE;
            } else {
                return fallback.eval(contextSequence, contextItem);
            }

        NodeSet result;
        if (preselectResult == null) {
            long start = System.currentTimeMillis();

            DocumentSet docs;
            if (contextSequence == null)
                docs = context.getStaticallyKnownDocuments();
            else
                docs = contextSequence.getDocumentSet();
            NodeSet contextSet = null;
            if (contextSequence != null)
                contextSet = contextSequence.toNodeSet();

            Sequence fields = getArgument(0).eval(contextSequence);
            RangeIndex.Operator[] operators = null;
View Full Code Here

        if (contextSequence != null && !contextSequence.isPersistentSet())
        // in-memory docs won't have an index
        return Sequence.EMPTY_SEQUENCE;
       
        NodeSet result;
        if (preselectResult == null) {
            long start = System.currentTimeMillis();
            Sequence input = getArgument(0).eval(contextSequence);
            if (!(input instanceof VirtualNodeSet) && input.isEmpty())
                result = NodeSet.EMPTY_SET;
            else {
                NodeSet inNodes = input.toNodeSet();
                DocumentSet docs = inNodes.getDocumentSet();
                LuceneIndexWorker index = (LuceneIndexWorker)
                        context.getBroker().getIndexController().getWorkerByIndexId(LuceneIndex.ID);
                Item key = getKey(contextSequence, contextItem);
                List<QName> qnames = null;
                if (contextQName != null) {
View Full Code Here

                if (annotate) {
                    if (onFirstNode)
                        attrs.addAttribute(ATTR_CHANGE, changeMessage);
                    else {
                        NodeId nodeId = (NodeId) reader.getProperty(EmbeddedXMLStreamReader.PROPERTY_NODE_ID);
                        NodeSet children = changeSet.selectParentChild(new NodeProxy(diffDoc, nodeId), NodeSet.ANCESTOR);
                        if (children != null && !children.isEmpty())
                            attrs.addAttribute(ATTR_CHANGE, "changed");
                    }
                    if (elementStack.size() == 0)
                        receiver.startPrefixMapping(StandardDiff.PREFIX, StandardDiff.NAMESPACE);
                }
View Full Code Here

     *            the function to be applied to all NodeProxys in nodes
     * @return a new NodeSet containing the non-null results of f applied to the NodeProxys in nodes
     * @throws XPathException
     */
    public static NodeSet fmapNodes(final NodeSet nodes, final F<NodeProxy, NodeProxy> f) throws XPathException {
        NodeSet result = new ExtArrayNodeSet();
        for (NodeSetIterator iterator = nodes.iterator(); iterator.hasNext();) {
            NodeProxy node = f.f(iterator.next());
            if (node != null)
                result.add(node);
        }
        result.iterate(); // ensure result is ready to use
        return result;
    }
View Full Code Here

            LOG.error("Expression " + toString() + " could not be evaluated");
            throw new XPathException("Could not evaluate wildcarded query.");
        }

        LOG.trace("Evaluating expression " + toString());
        NodeSet result = ((EvaluatableExpression) expressions.get(0)).eval(index, docs, qnames, nodeSet, axis,
            expressionId);

        if (leadingWildcard != null)
            result = expandMatchesBackward(leadingWildcard, result, expressionId);
        if (startAnchorPresent)
View Full Code Here

TOP

Related Classes of org.exist.dom.NodeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.