From: mh Date: Wed, 20 Feb 2002 13:36:33 +0000 (+0000) Subject: added back proper batching of content EntityLists with optimization for X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=b358c89269633b8a446b5da3c2dc10c6892a24ed;p=mir.git added back proper batching of content EntityLists with optimization for when an id is passed so not to do count(*) in that case. --- diff --git a/source/mircoders/producer/ProducerContent.java b/source/mircoders/producer/ProducerContent.java index 633de456..84111efe 100755 --- a/source/mircoders/producer/ProducerContent.java +++ b/source/mircoders/producer/ProducerContent.java @@ -17,7 +17,7 @@ import mircoders.storage.*; public class ProducerContent extends Producer { - private String contentTemplate = MirConfig.getProp("Producer.Content.Template"); + private String contentTemplate=MirConfig.getProp("Producer.Content.Template"); public static void main(String argv[]){ /** @@ -31,6 +31,8 @@ public class ProducerContent extends Producer { * from cron-script. In that case the config has to be initliased. * Don't know if is ok that way //rk * + * ok, i figured that out a few months ago.. -mh + * */ //Configuration.initConfig("config"); System.out.println(MirConfig.getProp("Producer.DocRoot")); @@ -53,7 +55,8 @@ public class ProducerContent extends Producer { } public void handle(PrintWriter htmlout, EntityUsers user, boolean force, - boolean sync, String id) throws StorageObjectException, ModuleException + boolean sync, String id) throws StorageObjectException, + ModuleException { long startTime = System.currentTimeMillis(); @@ -66,6 +69,8 @@ public class ProducerContent extends Producer { EntityList batchEntityList; EntityUsers userEntity=null; + int contentBatchsize = + Integer.parseInt(MirConfig.getProp("Producer.Content.Batchsize")); // production of the content-pages /** @todo this should be moved to ModuleContent */ @@ -75,20 +80,24 @@ public class ProducerContent extends Producer { // if true: produces a single content item if(id !=null){ whereClause += " AND id="+id; + // I think this avoids a select count(*)... + contentBatchsize=-1; } batchEntityList = contentModule.getContent(whereClause, orderBy, 0, - -1, userEntity); + contentBatchsize, userEntity); } else { whereClause="is_produced='0' AND is_published='1'"; //if true produces a single contentitem if(id !=null){ whereClause += " AND id="+id; + // I think this avoids a select count(*)... + contentBatchsize=-1; } batchEntityList = contentModule.getContent(whereClause, orderBy, 0, - -1, userEntity); + contentBatchsize, userEntity); } - if (batchEntityList!=null) { + while (batchEntityList!=null) { for(int i=0;i