A few thoughts: If any columns have the same name as a function in the cfc, the functions will get overwritten. The get, sets, etc may not be an issue, but hasnext, hasprevious, isfirst, and islast actually appear in queries we have! You might want to throw an exception during init if a column name conflicts with a function name.
You could also (in place of setting the columns that way) add a
getColumn("columnname") that would return the current value instead of using
the query.column notation. That would even more closely mirror .NET and
Java query objects. It would also cut a _lot_ of overhead since you don't
always need every column in a query, and setting every value every time can
add up to a lot of overhead since you're looping over every column on every
record advancement. With a getColumn() method, you just pull the fields
when you need them instead of doing the assignment every time.
Also, you could cut a lot of overhead by removing the "local" structure and
doing a straight return in most of the functions. Example:
<cffunction name="moveNext" access="public" returntype="boolean"
output="false">
<cfif hasNext()>
<cfset variables.currentRow = variables.currentRow + 1>
<cfset setAttributes()>
<cfreturn true/>
</cfif>
<cfreturn false/>
</cffunction>
That can be applied to most of the functions to cut overhead. Otherwise,
you're creating a structure during every record advance - this will add up
to quite a bit when you iterate over a large query!
I made my changes to your code and they are attached. Iterating over 24,555
records with the original version took 7 - 8 seconds on average on my
machine. With my proposed changes, it takes between .7 and 1 seconds on
average.
The modified version and a test script are attached. You can change the
query to anything of a relatively decent size to see the performance
difference. For large queries, it's quite significant :)
Hope this helps!
Roland
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of John Farrar
Sent: Wednesday, February 23, 2005 9:43 PM
To: [email protected]
Subject: Re: [CFCDev] query object CFC Beta
Here it is... the guys on this list should be able to understand it's
usage. (If anyone wants to help document... that would be great also.)
This version is somewhat tested... but don't have a full QA on this, so
let me know if you find any "fixes" or "enhancements".
Thanks again,
John Farrar
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
test.cfm
Description: Binary data
QueryIterator2.cfc
Description: Binary data
QueryIterator.cfc
Description: Binary data
