Package org.exist.util

Examples of org.exist.util.Occurrences


            broker = pool.get(user);
            collection = broker.openCollection(collectionName, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("collection " + collectionName
                        + " not found");}
            final Occurrences occurrences[] = broker.getElementIndex().scanIndexedElements(collection,
                    inclusive);
            final IndexedElement[] result = new IndexedElement[occurrences.length];
            for (int i = 0; i < occurrences.length; i++) {
                final QName qname = (QName)occurrences[i].getTerm();
                result[i] = new IndexedElement(qname.getLocalName(),qname.getNamespaceURI(),
View Full Code Here


                            default :
                                throw new IllegalArgumentException("Invalid section type in '" +
                                    dbTokens.getFile().getName() + "'");
                            }
                            if (include) {
                                Occurrences oc = (Occurrences) map.get(term);
                                if (oc == null) {
                                    oc = new Occurrences(term);
                                    map.put(term, oc);
                                }
                                if (!docAdded) {
                                    oc.addDocument(storedDocument);
                                    docAdded = true;
                                }
                                oc.addOccurrences(freq);
                            }
                        }
                    }
                }
            } catch(final IOException e) {
View Full Code Here

    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

      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

            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

                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

            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

        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

        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

        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

TOP

Related Classes of org.exist.util.Occurrences

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.