producer performance upgrades in the form of entity caching, and preliminary
[mir.git] / source / mir / producer / EntityListProducerNode.java
index d2aeec6..39e3c1a 100755 (executable)
@@ -14,10 +14,12 @@ public class EntityListProducerNode extends ProducerNodeDecorator {
   private int batchSize;
   private EntityAdapterDefinition definition;
   private StorageObject storage;
+  private int limit;
+  private int skip;
 
   public EntityListProducerNode(String aKey, StorageObject aStorage,
       EntityAdapterDefinition aDefinition, String aWhereClause, String anOrderByClause,
-      int aBatchSize, ProducerNode aSubNode) {
+      int aLimit, int aSkip, ProducerNode aSubNode) {
     super(aSubNode);
 
     storage = aStorage;
@@ -25,18 +27,23 @@ public class EntityListProducerNode extends ProducerNodeDecorator {
     key = aKey;
     whereClause = aWhereClause;
     orderByClause = anOrderByClause;
-    batchSize = aBatchSize;
+    limit = aLimit;
+    skip = aSkip;
   }
 
   public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure {
     try {
       aValueMap.put(key,
-        new EntityIteratorAdapter(
-          storage,
-          ParameterExpander.expandExpression( aValueMap, whereClause ),
-          ParameterExpander.expandExpression( aValueMap, orderByClause ),
-          batchSize,
-          definition )
+        new CachingRewindableIterator(
+          new EntityIteratorAdapter(
+            storage,
+            ParameterExpander.expandExpression( aValueMap, whereClause ),
+            ParameterExpander.expandExpression( aValueMap, orderByClause ),
+            20,
+            definition,
+            limit,
+            skip )
+        )
       );
       super.produce(aValueMap, aVerb, aLogger);
     }