Package nux.xom.pool

Examples of nux.xom.pool.DocumentPool


   */ 
  protected void run() throws Exception {   
    try {
      final boolean isBench2 = (runs > 1);
      final boolean isBench = (runs > 1 && iterations > 0);     
      final DocumentPool docPool = createDocumentPool(isBench);

      DocumentURIResolver resolver = new DocumentURIResolver() {
        public Document resolve(String href, String baseURI) throws ParsingException, IOException, TransformerException {
          String systemID = new net.sf.saxon.StandardURIResolver(null).
            resolve(href, baseURI).getSystemId();
//          System.err.println(systemID);
          return docPool.getDocument(URI.create(systemID));
        }
      };

      // prepare XQuery pool
      XQueryPool queryPool = new XQueryPool(
          new PoolConfig(), new XQueryFactory(null, resolver));
     
      ResultSequenceSerializer serializer = new ResultSequenceSerializer();
      serializer.setAlgorithm(algorithm);
      serializer.setEncoding(encoding);
      serializer.setIndent(indent);
     
      // now do the real work
      long runsStart = System.currentTimeMillis();
      for (int run=0; run < runs; run++) {
        if (isBench) {
          System.out.println("\n\n******************************************");
          System.out.println("run = " + run + ":");
        }
        for (int i=0; i < queries.size(); i++) {
          long start = System.currentTimeMillis();
          long serializationTime = 0;
          Object query = queries.get(i);
          XQuery xquery;
          if (query instanceof String) {
            xquery = queryPool.getXQuery((String)query, baseURI);
          } else if (query instanceof File) {
            xquery = queryPool.getXQuery((File)query, baseURI);
          } else {
            xquery = null; // disable XQuery for benchmarking
          }
         
          if (isBench) {
            System.out.println("query = " +query);
          }
          if (explain && run == 0 && xquery != null) {
            System.out.println("explain = \n" + xquery.explain());
          }
         
          XQuery morpher;
          if (update instanceof String) {
            morpher = queryPool.getXQuery((String)update, null);
          } else if (update instanceof File) {
            morpher = queryPool.getXQuery((File)update, null);
          } else {
            morpher = null;
          }
         
          int numSerials = 0;
          for (int j=0; j < inputFiles.length; j++) {
            Document doc = null;
            if (inputFiles[j] != null) {
              doc = docPool.getDocument(new File(inputFiles[j]));
            }
            if (explain && doc != null) {
              System.out.println("stats=" + toStatisticsString(doc));
            }

View Full Code Here


          throw new UsageException("Illegal validate option: " + validate);
        }
      }
    };
   
    return new DocumentPool(
      new DocumentMap(
        new PoolConfig().
          setCompressionLevel(docPoolCompression).
          setCapacity(docPoolCapacity)),
        docFactory);
View Full Code Here

TOP

Related Classes of nux.xom.pool.DocumentPool

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.