velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George.MANTZA...@ext.cec.eu.int
Subject RE: RE: Creating HashMaps from within the template for temporary proc essing
Date Fri, 28 Jul 2006 15:57:29 GMT
Hello Matthias,

Thank you very much for your hints and thoughts.
When I received your reply I had already started using Jprobe trying to find
where the code
gets the big delays.
Apparently the problem seems to be more concentrated in the construction of
the lists before feeding the velocity
contexts.
Its what you said "I could polish a lot here.." :))
So i think I will start from there trying to improve some stuff and after I
will investigate the possibility
to extend the resource loader maybe.

Best regards

G. Mantzakos

-----Original Message-----
From: Matthias Hendler [mailto:hendler2@gmx.de] 
Sent: Friday, July 28, 2006 5:20 PM
To: Velocity Users List
Subject: Re: RE: Creating HashMaps from within the template for temporary
proc essing


Hello Georgios,

well, I dont use the velocity file resource loaders.
As I mentioned I am doing it by myself in java.


What could slow down the file creation?
I think it's ...
1. Template/Java code
2. file i/o

Perhaps you can use a profiler to find out, where the file creation spends a
lot of time.

Alternativly:
0. Measure the time the file creation needs.

1. Measure the time you need to construct all the needed objects and so on.
Perhaps you will find out that you can polish here a lot.

2. Measure the time to create a 5MB file from java on the machine.

3. Read the documentation if you can expand the java i/o buffer in velocity.
Perhaps you have to write your own or expand file resource loader. I have no
idea if its possible in java to create a filewriter with a huge buffer
cache.

Well, not a solution, but hopefully it helps you a bit. :-)

Matthias
























-------- Original-Nachricht --------
Datum: Fri, 28 Jul 2006 11:14:23 +0200
Von: George.MANTZAKOS@ext.cec.eu.int
An: velocity-user@jakarta.apache.org
Betreff: RE: Creating HashMaps from within the template for temporary proc
essing

> Hello Matthias,
> 
> Thank you very much for your hints.
> Actually my situation is the following:
> 
> I have a large cache where I keep a lot of indexed news.
> This cache is updated regularly from a database whith a sceduler.
> Then there is a class which grabs specific news and creates rss and xml
> files.
> The velocity contexts are feeded mostly by java lists which contain
> objects.
> So in the template am using the objects get methods to get particular
> attributes.
> Its true that some files are almost 5MB so all the process of the template
> looping through the
> Lists and using the get methods it's a bit slow. Maybe it's the way am
> constructing the objects...
> Are you using class resource loader? Me am using file, maybe this is also
> a
> drawback?
> 
> Best regards
> 
> Georgios Mantzakos
> 
> 
> 
> 
> -----Original Message-----
> From: Matthias Hendler [mailto:hendler2@gmx.de] 
> Sent: Friday, July 28, 2006 9:11 AM
> To: Velocity Users List; velocity-user@jakarta.apache.org
> Subject: Re: Creating HashMaps from within the template for temporary
> processing
> 
> 
> Hello,
> 
> I think the only solution is to create the instance of the map in java.
> Then put the instance into the velocity context.
> Thats it.
> 
> 
> As I faced the same problem, I have written my own java class to start
> velocity.
> Then I have a property to instantiate HashMaps and ArrayList in this class
> which will be added to the velocity context. After a template was
> processed,
> the Maps and Lists are cleared by my java class.
> (But you can also clear the Maps/Lists in the template before using them.)
> 
> Well, I dont know how this approach will work with the velocity resource
> loaders. I use velocity to generate plsql code from templates and
> therefore
> I read the template files by myself.
> 
> 
> Matthias
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -------- Original-Nachricht --------
> Datum: Thu, 27 Jul 2006 16:43:04 +0530
> Von: Santosh Puranshettiwar <santosh@wirkle.com>
> An: Velocity Users List <velocity-user@jakarta.apache.org>
> Betreff: Creating HashMaps from within the template for temporary
> processing
> 
> > Hello everyone,
> > 
> > The situation goes like this.
> > 
> > 1. There runs a for loop based on which I need to keep record of a key 
> > value pair.
> > 2. Based on these key value pairs some more text is added later, outside
> > the for loop (in step1).
> > 
> > For example: -
> > #foreach( $person in $person_list )
> > $person.name
> > #if( $person.details )
> > #set( $hyperLink = ${person.name}details )
> > #set( $personDetailsMap.put(${person.name}details, $person.details)
> > <a href="$hyperLink">Details</a>
> > #end
> > #end
> > 
> > #set( $perseonDetailKeyList  = $personDetailsMap.keySet() )
> > #foreach( $personDetail in $personDetailKeyList )
> > <a name="person.html#$personDetail">$personDetail</a>
> > 
> > ##Person details go here
> > 
> > #end
> > 
> > 
> > The only difficulty I am facing here is, how do I instantiate 
> > $personDetailsMap within the velocity template.
> > 
> > Thanks,
> > Santosh.
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> -- 
> 
> 
> Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
> "Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org

-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message