Hi Daniel,

I've xindice 1.0 birthday installed on a 1GHZ AMD Redhat 7.3.

This is my test class:

---------begin class-----------

import java.io.*;
import java.util.*;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;


public class DBTest{

//f�r das connecten zur db
private org.xmldb.api.base.Collection col;


  public static String createfile(String filename, int count){

    String result="";
   // File tmpfile = new File(filename);
    StringBuffer sbuff = new StringBuffer();
    sbuff.append("<?xml version=\"1.0\"?>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<person>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<pid id=\"24477"+count+"\"></pid>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<icoId>new</icoId>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<dirk>"+count+"</dirk>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<fname>Homer_"+count+"</fname>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<lname>Simpson_"+count+"</lname>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<phone type=\"work\" >123-456-7890_"+count+"</phone>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<phone type=\"home\" >234-567-8901_"+count+"</phone>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<phone type=\"cell\" >456-789-0123_"+count+"</phone>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<email type=\"home\"
>Hom����er_"+count+"@home.com</email>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<email type=\"work\" >Homer_"+count+"@work.org</email>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<address type=\"home\">1234 W.
Springfield_"+count+"</address>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("<address type=\"work\" >34 N. Atom
Way_"+count+"</address>");
    sbuff.append(System.getProperty("line.separator"));
    sbuff.append("</person>");

    result = sbuff.toString();
    return result;
 }

 public void connect(){
    try {
         String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
         Class c = Class.forName(driver);

         Database database = (Database) c.newInstance();
         DatabaseManager.registerDatabase(database);
         this.col =
            DatabaseManager.getCollection("xmldb:xindice:///db/test1");
    }catch (Exception e) {
         System.err.println("XML:DB Exception occured "
+e.getLocalizedMessage());
      }
  }

  public void disconnect(){
    try{
    if(this.col!=null)
    this.col.close();
    }catch(Exception e) {
         System.err.println("XML:DB Exception occured "
+e.getLocalizedMessage());
      }
  }

    //adding XML Doc to DB

  public void AddXMLDocumentFORMFile(String content) throws Exception{

      try {



         String id = this.col.createId();
         XMLResource document = (XMLResource) col.createResource(id,
            "XMLResource");
         document.setContent(content);
         this.col.storeResource(document);

         //System.out.println("Document  inserted with id: "+id);
  //       System.out.println("updating doc id tag --> start");
         try{
         XUpdate(id);
         }catch (Exception e) {e.printStackTrace(System.out);}
    //     System.out.println("updating doc id tag --> end");

      }
      catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode);
      }
   }

    //XUPDATE

   public void XUpdate(String id) throws Exception{
      try {

         String xupdate = "<xu:modifications version=\"1.0\"" +
            "      xmlns:xu=\"http://www.xmldb.org/xupdate\";>" +
            "   <xu:update select=\"/person/icoId\"> " +
            id +
            "   </xu:update>" +
            "</xu:modifications>";
      //  System.out.println(xupdate);

         XUpdateQueryService service =
            (XUpdateQueryService) this.col.getService("XUpdateQueryService",
"1.0");
         service.updateResource(id,xupdate);
      }
      catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode + " "
+
            e.getMessage());
      }
   }

    //query XPath
   public java.util.Collection queryCollection(String xpath)throws
XMLDBException {
    java.util.Collection ret = new LinkedList();
    XPathQueryService service =
(XPathQueryService)this.col.getService("XPathQueryService","1.0");
    ResourceSet resultSet = service.query(xpath);
    ResourceIterator results = resultSet.getIterator();
    while (results.hasMoreResources()) {
            Resource res = results.nextResource();
            ret.add(res.getContent());
            //System.out.println((String) res.getContent());
    }

    return ret;
   }

    //STATUS
   public int getDocumentCount(){
      int result=0;
     try{
      result = this.col.getResourceCount();
     }catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode + " "
+
            e.getMessage());
      }
      return result;
   }

   public DBTest(){
   }

    public static void main(String[] args){

            LinkedList content = new LinkedList();

            DBTest test = new DBTest();
            System.out.println("starten des tests...");
            test.connect();
            if(!(test.col==null)){
                    System.out.println("collection not null");
                    content.add(test.createfile(null,0));
                    Iterator ic = content.iterator();
                    while(ic.hasNext()){
                            //System.out.println((String)ic.next());
                            String c = (String)ic.next();
                          for(int i=500;i<0;i++){
                              //System.out.println("Nr: "+i);
                          try{

test.AddXMLDocumentFORMFile(test.createfile(null,i));
                            }catch(Exception e){System.err.println("Error in
addDokument "+e.getMessage());}
                            }
                    }
                    System.out.println("Document count in Collection:
"+test.getDocumentCount());
                    try{
                        long t = System.currentTimeMillis();
                        System.out.println("starting query");
                        LinkedList l = new
LinkedList((test.queryCollection("//person/fname[contains(text(),'1505')]"))
);
                        long time = System.currentTimeMillis()-t;
                        System.out.println("end query");
                        System.out.println("Time: "+time);
                        System.out.println("query Result"+l.size());

                        Iterator i_l = l.iterator();
                        while(i_l.hasNext()){
                            System.out.println(i_l.next());

                        }

                    }catch (Exception e){System.err.println("Error in 
queryDokument
"+e.getMessage());}
            }



    }

}

---------end class-----------

at the begin there is the method to create the "testfiles wich i'm adding to
db"
you must create the collection "db/test1" (see connect() Method).

-- in the main there is a "for(int i=500;i<0;i++){" where i'm creating and
adding the docs...
-- there is a xupdate method wich adds the documentID form the collection to
the document.
-- then there is a
"test.queryCollection("//person/fname[contains(text(),'1505')]"))" where i
tested the different xpath -- searches (this contains(text(),'1505') does
not work with the indexer!!! )

after adding documents to the db i've setup some indexer with the
commandline tools (for the elements and attributes wich i'm searching by the
xpath.)


if there are any questions you can write me a mail.
(german or english)

greats

Dirk Bromberg
[EMAIL PROTECTED]







-----Urspr�ngliche Nachricht-----
Von: Daniel Kr�ger [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 12. Juni 2002 00:04
An: [email protected]
Betreff: AW: Indexer does not work ??!


Hi Dirk,

How did you quantify the time. Do you have any kind of tool....?

Daniel

> -----Urspr�ngliche Nachricht-----
> Von: Dirk Bromberg [mailto:[EMAIL PROTECTED] Im
> Auftrag von Dirk Bromberg
> Gesendet: Donnerstag, 16. Mai 2002 09:13
> An: [email protected]
> Betreff: AW: Indexer does not work ??!
>
>
> That was my problem too,
>
> And so I created the index first and than I added the
> document's to database. And so I can reduce the search time
> by 100.000 doc's from 3min to 30ms (by 500.000docs it takes ca.120ms)
>
> Must be a problem installing indexer after adding documents..
>
> Greets
>
> Dirk Bromberg
>
>
>
> > -----Urspr�ngliche Nachricht-----
> > Von: Thomas Rupp [mailto:[EMAIL PROTECTED]
> > Gesendet: Donnerstag, 16. Mai 2002 09:02
> > An: [email protected]
> > Betreff: Re: Indexer does not work ??!
> >
> >
> > Hello Timo Boehme,
> >
> >
> > I had the same effect. I imported a lot of documents and
> after this I
> > created the index. The xpath search is very slow (not
> better without
> > index).
> >
> > best recards
> > Thomas Rupp
> >
> > > Now I've created a new collection, then I add an indexer for an
> > > attribute..
> > >
> > > then i add 500.000 test documents which have a counter for the
> > > attributevalue
> > >
> > > 1,2GB Data (500MB for the index)
> > >
> > > now the search needs 120ms, that's fast I think.
> > >
> > > great!!!
> > >
> > > Dirk Bromberg
> > >
> > > running xindice 1.0 ,1GHZ AMD, IDE HDD
> > >
> > >
> > >
> > >
> > > Timo Boehme wrote:
> > >
> > > >Hi,
> > > >
> > > >>My question:
> > > >>if i create an index with:
> > > >>xindiceadmin add_indexer -c /db/test -n idIndexer -p id (I'm
> > > >>seraching with this xpath: "//test/id["2447734"]" ) I'm
> wondering
> > > >>creating xindexer takes no time. After creating this
> indexer the
> > > >>search is not faster , why ?? or must I create the
> indexer before
> > > >>adding the documents ??
> > > >>
> > > >
> > > >Is id an attribute or an element? It looks like an element
> > to me. If
> > > >id
> > > is
> > > >an attribute you have to add '@' beforehand.
> > > >
> > > >Nevertheless I tried to do something similar some time ago
> > but got an
> > > >NullPointerExecption when creating the index. I wrote in
> with the
> > > >following mail:
> > > >
> > > >: I would like to create an index for all foo attributes
> within my
> > > >: collection. According to the documentation I specified
> > [EMAIL PROTECTED] as the
> > > index
> > > >: pattern. However the database server throws
> > NullPointerExceptions
> > > >for
> > > all
> > > >: documents within the collection during indexing. The exception
> > > >looks
> > > like
> > > >:
> > > >: DEBUG> java.lang.NullPointerException
> > > >:        at
> > > org.apache.xindice.core.indexer.IndexPattern.getMatchLevel(Unknown
> > > Source)
> > > >:        at
> > >
> > org.apache.xindice.core.indexer.IndexManager$SAXHandler.proces
> > sEntry(Unknown Source)
> > > >:        at
> > >
> >
> org.apache.xindice.core.indexer.IndexManager$SAXHandler.endElement(Unk
> > > nown
> > Source)
> > > >:        at
> > >
> >
> org.apache.xindice.xml.sax.SAXEventGenerator.processContainer(Unknown
> > Source)
> > > >:        at
> > >
> >
> org.apache.xindice.xml.sax.SAXEventGenerator.processContainer(Unknown
> > Source)
> > > >:        at
> > >
> org.apache.xindice.xml.sax.SAXEventGenerator.processDocument(Unknown
> > Source)
> > > >:        at
> > org.apache.xindice.xml.sax.SAXEventGenerator.start(Unknown
> > > Source)
> > > >:        at
> > >
> >
> org.apache.xindice.core.indexer.IndexManager$SAXHandler.<init>(Unknown
> > Source)
> > > >:        at
> > >
> >
> org.apache.xindice.core.indexer.IndexManager.populateNewIndexers(Unkno
> > > wn
> > Source)
> > > >:        at
> > > org.apache.xindice.core.indexer.IndexManager.access$300(Unknown
> > > Source)
> > > >:        at
> > >
> org.apache.xindice.core.indexer.IndexManager$AutoIndexer.run(Unknown
> > Source)
> > > >:
> > > >: You can easily reproduce this problem:
> > > >:  1. add a collection testcoll to db
> > > >:  2. add a simple document (e.g. <test>text</test>) to
> > /db/testcoll
> > > >:  3. add index with pattern [EMAIL PROTECTED] to /db/testcoll
> > > >:
> > > >: I got this with Xindice RC1 running on Solaris and on
> > Windows 2000.
> > > >
> > > >I got a reply from Tom Bradford:
> > > >
> > > >: I'll try to get this fixed this evening.  It's
> probably something
> > > >: simple, and the result of stupidity. :)
> > > >
> > > >However I haven't heard anything afterwards and the bug
> > seems to be
> > > >still there. Can somebody please have a look on it?
> > > >
> > > >
> > > >
> > > >Best regards,
> > > >Timo
> > > >
> > > >
> > > >---------------------------------------------------
> > > > Dipl. Inf. Timo Boehme     Phone: +49 341 9732166
> > > > University of Leipzig      Fax:   +49 341 9732209
> > > >   Institute of Computer Science, Database Group
> > > >    Augustusplatz 10-11, 04109 Leipzig, Germany
> > > >      email: [EMAIL PROTECTED]
> > > >---------------------------------------------------
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> > --
> > GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net
> >
> >
>


Reply via email to