Examples of Occurrences


Examples of org.exist.util.Occurrences

    try {
            final List<Object> params = new ArrayList<Object>(1);
      params.add(parent.getPath());
      params.add(Boolean.valueOf(inclusive));
      final Object[] result = (Object[]) rpcClient.execute("getIndexedElements", params);
      final Occurrences occurrences[] = new Occurrences[result.length];
      Object[] row;
      for (int i = 0; i < occurrences.length; i++) {
        row = (Object[]) result[i];
        final QName qname = new QName((String)row[0], (String)row[1],
            (String)row[2]);
        occurrences[i] = new Occurrences(qname);
        occurrences[i].addOccurrences(((Integer) row[3]).intValue());
      }
      return occurrences;
    } catch (final XmlRpcException e) {
      throw new XMLDBException(
View Full Code Here

Examples of org.exist.util.Occurrences

      params.add(parent.getPath());
      params.add(start);
      params.add(end);
      params.add(Boolean.valueOf(inclusive));
      final Object[] result = (Object[]) rpcClient.execute("scanIndexTerms", params);
      final Occurrences occurrences[] = new Occurrences[result.length];
      Object[] row;
      for (int i = 0; i < occurrences.length; i++) {
        row = (Object[]) result[i];
        occurrences[i] = new Occurrences((String) row[0]);
        occurrences[i].addOccurrences(((Integer) row[1]).intValue());
      }
      return occurrences;
    } catch (final XmlRpcException e) {
      throw new XMLDBException(
View Full Code Here

Examples of org.exist.util.Occurrences

            final List<Object> params = new ArrayList<Object>(1);
      params.add(xpath);
      params.add(start);
      params.add(end);
      final Object[] result = (Object[]) rpcClient.execute("scanIndexTerms", params);
      final Occurrences occurrences[] = new Occurrences[result.length];
      Object[] row;
      for (int i = 0; i < occurrences.length; i++) {
        row = (Object[]) result[i];
        occurrences[i] = new Occurrences((String) row[0]);
        occurrences[i].addOccurrences(((Integer) row[1]).intValue());
      }
      return occurrences;
    } catch (final XmlRpcException e) {
      throw new XMLDBException(
View Full Code Here

Examples of org.exist.util.Occurrences

                final Lock lock = index.btree.getLock();
                try {
                    lock.acquire(Lock.READ_LOCK);
                    index.btree.query(query, new BTreeCallback() {
                        public boolean indexInfo(Value value, long pointer) throws TerminatedException {
                            Occurrences oc = occurrences.get(name);
                            if (oc == null) {
                                oc = new Occurrences(name);
                                occurrences.put(name, oc);
                                oc.addDocument(doc);
                                oc.addOccurrences(1);
                            } else {
                                oc.addOccurrences(1);
                                oc.addDocument(doc);
                            }
                            return true;
                        }
                    });
                } catch (final LockException e) {
View Full Code Here

Examples of org.exist.util.Occurrences

            checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 1);
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 4);
            checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "good", 0);
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, "good", 0);
            Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "table", 1);
            assertEquals("table", o[0].getTerm());
            o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "cabinet", 1);
            assertEquals("cabinet", o[0].getTerm());
            o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "table", 1);
            assertEquals("table", o[0].getTerm());
View Full Code Here

Examples of org.exist.util.Occurrences

        try {
          broker = pool.get(pool.getSecurityManager().getSystemSubject());
            transact = pool.getTransactionManager();
            transaction = transact.beginTransaction();

            Occurrences occur[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1);
            assertEquals("chair", occur[0].getTerm());
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("//item[ft:query(description, 'chair')]", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(1, seq.getItemCount());

            // Append to root node
            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
            proc.setBroker(broker);
            proc.setDocumentSet(docs);
            String xupdate =
                XUPDATE_START +
                "   <xu:append select=\"/test\">" +
                "       <item id='4'><description>Armchair</description> <condition>bad</condition></item>" +
                "   </xu:append>" +
                XUPDATE_END;
            Modification[] modifications = proc.parse(new InputSource(new StringReader(xupdate)));
            assertNotNull(modifications);
            modifications[0].process(transaction);
            proc.reset();

            Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 2);
            System.out.println("prices: " + o.length);
            for (int i = 0; i < o.length; i++) {
                System.out.println("occurance: " + o[i].getTerm() + ": " + o[i].getOccurrences());
            }
            checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 4);
View Full Code Here

Examples of org.exist.util.Occurrences

        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            transact = pool.getTransactionManager();
            transaction = transact.beginTransaction();

            Occurrences occur[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1);
            assertEquals("chair", occur[0].getTerm());
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("//item[ft:query(description, 'chair')]", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(1, seq.getItemCount());

            // Update element content
            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
            proc.setBroker(broker);
            proc.setDocumentSet(docs);
            String xupdate =
                    XUPDATE_START +
                    "   <xu:update select=\"//item[@id = '1']/description\">wardrobe</xu:update>" +
                    XUPDATE_END;
            Modification[] modifications = proc.parse(new InputSource(new StringReader(xupdate)));
            assertNotNull(modifications);
            modifications[0].process(transaction);
            proc.reset();

            checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 3);
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5);
            checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 0);
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, "chair", 0);
            Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "wardrobe", 1);
            assertEquals("wardrobe", o[0].getTerm());

            // Update text node
            proc.setBroker(broker);
            proc.setDocumentSet(docs);
View Full Code Here

Examples of org.exist.util.Occurrences

        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            transact = pool.getTransactionManager();
            transaction = transact.beginTransaction();

            Occurrences occur[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1);
            assertEquals("chair", occur[0].getTerm());
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("//item[ft:query(description, 'chair')]", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(1, seq.getItemCount());

            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
            proc.setBroker(broker);
            proc.setDocumentSet(docs);
            String xupdate =
                    XUPDATE_START +
                    "<xu:replace select=\"//item[@id = '1']\">" +
                    "<item id='4'><description>Wheelchair</description> <condition>poor</condition></item>" +
                    "</xu:replace>" +
                    XUPDATE_END;
            Modification[] modifications = proc.parse(new InputSource(new StringReader(xupdate)));
            assertNotNull(modifications);
            modifications[0].process(transaction);
            proc.reset();

            checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 3);
            checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 3);
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 6);
            checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 0);
            checkIndex(docs, broker, new QName[] { new QName("item", "") }, "chair", 0);
            Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "wheelchair", 1);
            assertEquals("wheelchair", o[0].getTerm());
            o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "poor", 1);
            assertEquals("poor", o[0].getTerm());
            o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "wheelchair", 1);
            assertEquals("wheelchair", o[0].getTerm());
View Full Code Here

Examples of org.exist.util.Occurrences

                //Aggregate the occurences between different documents
                for (Map.Entry<Geometry, String> entry : getGeometriesForDocument(doc, conn).entrySet()) {
                    ///TODO : use the IndexWorker.VALUE_COUNT hint, if present, to limit the number of returned entries
                    Geometry key = entry.getKey();
                    //Do we already have an occurence for this geometry ?
                    Occurrences oc = occurences.get(key);
                    if (oc != null) {
                        //Yes : increment occurence count
                        oc.addOccurrences(oc.getOccurrences() + 1);
                        //...and reference the document
                        oc.addDocument(doc);
                    } else {
                        //No : create a new occurence with EPSG4326_WKT as "term"
                        oc = new Occurrences(entry.getValue());
                        //... with a count set to 1
                        oc.addOccurrences(1);
                        //... and reference the document
                        oc.addDocument(doc);
                        occurences.put(key, oc);
                    }
                }
            }
        } catch (SQLException e) {
View Full Code Here

Examples of org.exist.util.Occurrences

        NGramIndexWorker index = (NGramIndexWorker) broker.getIndexController().getWorkerByIndexId(NGramIndex.ID);
        XQueryContext context = new XQueryContext(broker.getBrokerPool(), AccessContext.TEST);
        Occurrences[] occurrences = index.scanIndex(context, docs, null, null);
        int found = 0;
        for (int i = 0; i < occurrences.length; i++) {
            Occurrences occurrence = occurrences[i];
            if (occurrence.getTerm().compareTo(term) == 0)
                found++;
        }       
        assertEquals(count, found);       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.