cziegeler    02/05/24 01:52:33

  Modified:    src/java/org/apache/cocoon Main.java
               src/java/org/apache/cocoon/components/pipeline/impl
                        CachingProcessingPipeline.java
               src/java/org/apache/cocoon/generation FileGenerator.java
               src/java/org/apache/cocoon/reading ResourceReader.java
  Log:
  Improved caching for file generator and reader
  
  Revision  Changes    Path
  1.19      +1 -2      xml-cocoon2/src/java/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Main.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Main.java 13 May 2002 00:13:21 -0000      1.18
  +++ Main.java 24 May 2002 08:52:33 -0000      1.19
  @@ -94,7 +94,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Id: Main.java,v 1.18 2002/05/13 00:13:21 stefano Exp $
  + * @version CVS $Id: Main.java,v 1.19 2002/05/24 08:52:33 cziegeler Exp $
    */
   public class Main {
   
  @@ -220,7 +220,6 @@
        * @exception Exception if an error occurs
        */
       public static void main(String[] args) throws Exception {
  -
           String destDir = Constants.DEFAULT_DEST_DIR;
           String contextDir = Constants.DEFAULT_CONTEXT_DIR;
           String configFile = null;
  
  
  
  1.9       +71 -4     
xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
  
  Index: CachingProcessingPipeline.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CachingProcessingPipeline.java    10 May 2002 08:33:29 -0000      1.8
  +++ CachingProcessingPipeline.java    24 May 2002 08:52:33 -0000      1.9
  @@ -89,7 +89,7 @@
    *
    * @since @next-version@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: CachingProcessingPipeline.java,v 1.8 2002/05/10 08:33:29 
cziegeler Exp $
  + * @version CVS $Id: CachingProcessingPipeline.java,v 1.9 2002/05/24 08:52:33 
cziegeler Exp $
    */
   public class CachingProcessingPipeline
   extends AbstractProcessingPipeline
  @@ -274,6 +274,8 @@
           long key = 0;
           boolean generatorIsCacheableProcessingComponent = false;
           boolean serializerIsCacheableProcessingComponent = false;
  +        boolean[] transformerIsCacheableProcessingComponent = new 
boolean[this.transformers.size()];
  +
           if (this.generator instanceof CacheableProcessingComponent) {
               key = ((CacheableProcessingComponent)this.generator).generateKey();
               generatorIsCacheableProcessingComponent = true;
  @@ -298,6 +300,7 @@
                   key = 0;
                   if (trans instanceof CacheableProcessingComponent) {
                       key = ((CacheableProcessingComponent)trans).generateKey();
  +                    
transformerIsCacheableProcessingComponent[this.firstNotCacheableTransformerIndex] = 
true;
                   } else if (trans instanceof Cacheable) {
                       key = ((Cacheable)trans).generateKey();
                   }
  @@ -331,6 +334,69 @@
               }
           }
   
  +        // lets make a working version first, below is the beginning
  +        // of the new solution
  +        if (this.pipelineCacheKey != null) {
  +            CachedResponse response = 
this.cache.get(this.pipelineCacheKey.toString());
  +            // now test validity
  +            if (response != null) {
  +                boolean responseIsValid = true;
  +                boolean responseIsUsable = true;
  +                SourceValidity[] validities = response.getValidityObjects();
  +                int i = 0;
  +                while (i < validities.length) {
  +                    boolean isValid = validities[i].isValid();
  +                    if ( !isValid ) {
  +                        final SourceValidity validity;
  +                        if (i == 0) {
  +                            // test generator
  +                            if (generatorIsCacheableProcessingComponent) {
  +                                validity = 
((CacheableProcessingComponent)this.generator).generateValidity();
  +                            } else {
  +                                validity = new 
CacheValidityToSourceValidity(((Cacheable)this.generator).generateValidity());
  +                            }
  +                        } else if (i <= firstNotCacheableTransformerIndex + 1) {
  +                            // test transformer
  +                            final Transformer trans =
  +                               (Transformer)this.transformers.get(i-1);
  +                            if (transformerIsCacheableProcessingComponent[i-1]) {
  +                                validity = 
((CacheableProcessingComponent)trans).generateValidity();
  +                            } else {
  +                                validity = new 
CacheValidityToSourceValidity(((Cacheable)trans).generateValidity());
  +                            }
  +                        } else {
  +                            // test serializer
  +                            if (serializerIsCacheableProcessingComponent) {
  +                                validity = 
((CacheableProcessingComponent)this.serializer).generateValidity();
  +                            } else {
  +                                validity = new 
CacheValidityToSourceValidity(((Cacheable)this.serializer).generateValidity());
  +                            }
  +                        }
  +                        if (validity != null) {
  +                            isValid = validities[i].isValid( validity );
  +                        }
  +                        if ( !isValid ) {
  +                            responseIsValid = false;
  +                            // update validity
  +                            validities[i] = validity;
  +                            if (validity == null) responseIsUsable = false;
  +                        }
  +                    }
  +                    if ( isValid ) i++;
  +                }
  +                // FIXME
  +                if ( responseIsValid ) {
  +                    // we are valid, ok that's it
  +                } else {
  +                    // we are not valid!
  +                    this.cache.remove(this.pipelineCacheKey.toString());
  +                    if (!responseIsUsable) {
  +                        this.pipelineCacheKey = null;
  +                    }
  +                }
  +            }
  +        }
  +        /*
           // now, if we have a key, let's see if there is a cached response
           boolean finished = false;
           while (this.pipelineCacheKey != null && !finished) {
  @@ -356,7 +422,7 @@
                               // test transformer
                               final Transformer trans =
                                  (Transformer)this.transformers.get(i-1);
  -                            if (trans instanceof CacheableProcessingComponent) {
  +                            if (transformerIsCacheableProcessingComponent[i-1]) {
                                   validity = 
((CacheableProcessingComponent)trans).generateValidity();
                               } else {
                                   validity = new 
CacheValidityToSourceValidity(((Cacheable)trans).generateValidity());
  @@ -385,6 +451,7 @@
                   } else {
                       // we are not valid!
                       if (validities[i] == null) {
  +                        // FIXME (CZ) : check this
                           // we can try a shorter key now...
                           // but we don't invalidate the current entry!
                           if (i > 0) {
  @@ -403,11 +470,11 @@
                       } else {
                           // invalidate entry
                           this.cache.remove(this.pipelineCacheKey.toString());
  -                        // let's get the rest of the validities now
  +                        // FIXME(CZ) let's get the rest of the validities now
                       }
                   }
               }
  -        }
  +        }*/
       }
   
       /** Connect the pipeline.
  
  
  
  1.10      +2 -5      
xml-cocoon2/src/java/org/apache/cocoon/generation/FileGenerator.java
  
  Index: FileGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/FileGenerator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FileGenerator.java        26 Apr 2002 08:41:52 -0000      1.9
  +++ FileGenerator.java        24 May 2002 08:52:33 -0000      1.10
  @@ -74,7 +74,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: FileGenerator.java,v 1.9 2002/04/26 08:41:52 cziegeler Exp $
  + * @version CVS $Id: FileGenerator.java,v 1.10 2002/05/24 08:52:33 cziegeler Exp $
    */
   public class FileGenerator extends ComposerGenerator
   implements Cacheable {
  @@ -113,10 +113,7 @@
        * @return The generated key hashes the src
        */
       public long generateKey() {
  -        if (this.inputSource.getValidity() != null) {
  -            return HashUtil.hash(this.inputSource.getSystemId());
  -        }
  -        return 0;
  +        return HashUtil.hash(this.inputSource.getSystemId());
       }
   
       /**
  
  
  
  1.9       +2 -5      
xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java
  
  Index: ResourceReader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ResourceReader.java       24 May 2002 08:38:13 -0000      1.8
  +++ ResourceReader.java       24 May 2002 08:52:33 -0000      1.9
  @@ -91,7 +91,7 @@
    *   </dl>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Id: ResourceReader.java,v 1.8 2002/05/24 08:38:13 froehlich Exp $
  + * @version CVS $Id: ResourceReader.java,v 1.9 2002/05/24 08:52:33 cziegeler Exp $
    */
   public class ResourceReader
     extends AbstractReader
  @@ -132,10 +132,7 @@
        * @return The generated key hashes the src
        */
       public long generateKey() {
  -        if (this.inputSource.getValidity() != null) {
  -            return HashUtil.hash(this.inputSource.getSystemId());
  -        }
  -        return 0;
  +        return HashUtil.hash(this.inputSource.getSystemId());
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to