Checking for a duplicate value question

48 views
Skip to first unread message

hofar...@houseoffusion.com

unread,
May 3, 2012, 12:37:39 AM5/3/12
to ColdFusion Technical Talk

Got an app that sends out email to various lists - CF8

I'm checking to be sure there are any duplicates between the two lists

req.this list - usually pretty small - ten or so email addresses
req.groupLIST - is the problem - it could be a500 or more addresses at
times.

<cfloop list="#req.thisLIST#" index="i">
<cfif NOT listfindnocase(req.groupLIST,#i#)>
DO MY STUFF HERE
</cfif>
</cfloop>

Is there a more efficient way to do the above? If req.groupLIST ends up
being a HUGE list - at what point will this choke down and time out?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350969

hofar...@houseoffusion.com

unread,
May 3, 2012, 1:10:46 AM5/3/12
to ColdFusion Technical Talk

When getting the information out of the database, us distinct on the field.

--
Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/108193156965451149543
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350970

hofar...@houseoffusion.com

unread,
May 3, 2012, 7:13:25 AM5/3/12
to ColdFusion Technical Talk

As Andrew says, it's best done in the DB before your data becomes a list.

If you can't do that for some reason, convert your list to an array and loop over that. Arrays are much faster than long lists. The longer the list/array, the bigger the performance difference.

- Cameron
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350971

hofar...@houseoffusion.com

unread,
May 3, 2012, 12:10:06 PM5/3/12
to ColdFusion Technical Talk

> When getting the information out of the database, us distinct on the
field.

Only one list is coming from the database, the other is from a
completely different source.

> convert your list to an array and loop over that

The small list is the one that will have the operations done to it. The
large list is the one that I need to search for duplicate values. If the
server was running CF9 then I could use ArrayFind but that's not
available in CF8.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350975

hofar...@houseoffusion.com

unread,
May 3, 2012, 12:38:37 PM5/3/12
to ColdFusion Technical Talk

In reading through this thread, it appears as though one of your lists (not clear whether it's the short or long list) is sourced from database, and the other not. But if you've got one list of key column values in a CF List var, then you should be able to query the database to pull out everything NOT IN that list. Something like:

<cfquery name="UniqueRecords" datasource="MyDatasource">
SELECT DISTINCT SomeColumn
FROM SomeTable
WHERE SomeColumn NOT IN (<cfqueryparam cfsqltype="cf_sql_varchar" list="yes" value="#OtherList#">)
</cfquery>

Then ValueList the column from that result, append your other list, and you should have your comprehensive list, with no dupes:

<cfset ComprehensiveList = "#ValueList(UniqueRecords.SomeColumn)#,#OtherList#">

-Christopher

> I'm checking to be sure there are any duplicates between the two lists
> ...
> [other content and sample code clipped]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350978

hofar...@houseoffusion.com

unread,
May 3, 2012, 4:29:31 PM5/3/12
to ColdFusion Technical Talk

On Thu, May 3, 2012 at 12:10 PM, Les Mizzell <les...@bellsouth.net> wrote:

> > convert your list to an array and loop over that
>
> The small list is the one that will have the operations done to it. The
> large list is the one that I need to search for duplicate values. If the
> server was running CF9 then I could use ArrayFind but that's not
> available in CF8.


Soooo.... You don't want to convert to an array and loop over that rather
than a list?

ArrayFind() is a shortcut for looping over an array, but you can also do
that manually. Small lists aren't much of a problem, just big ones. So
convert the long list to an array, or maybe even just use the query object
from the DB on the long list. Leave the short list as is, it's unlikely to
ever cause performance issues at 10 items.

Psudocode:

loop array=biglist
{
if (listFind(biglistItem,smalllist))
{
smalllist = listDeleteAt(smalllist, listFind(biglistItem,smalllist)));
}
}

Now you have a de-duped small list.

-Cameron

...


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350989

hofar...@houseoffusion.com

unread,
May 3, 2012, 4:45:50 PM5/3/12
to ColdFusion Technical Talk

You could also use a query-of-queries with where biglistitem not in
(smalllistitems).

On 5/3/12 1:29 PM, Cameron Childress wrote:
> On Thu, May 3, 2012 at 12:10 PM, Les Mizzell<les...@bellsouth.net> wrote:
>
>> > convert your list to an array and loop over that
>>
>> The small list is the one that will have the operations done to it. The
>> large list is the one that I need to search for duplicate values. If the
>> server was running CF9 then I could use ArrayFind but that's not
>> available in CF8.
>
> Soooo.... You don't want to convert to an array and loop over that rather
> than a list?
>
> ArrayFind() is a shortcut for looping over an array, but you can also do
> that manually. Small lists aren't much of a problem, just big ones. So
> convert the long list to an array, or maybe even just use the query object
> from the DB on the long list. Leave the short list as is, it's unlikely to
> ever cause performance issues at 10 items.
>
> Psudocode:
>
> loop array=biglist
> {
> if (listFind(biglistItem,smalllist))
> {
> smalllist = listDeleteAt(smalllist, listFind(biglistItem,smalllist)));
> }
> }
>
> Now you have a de-duped small list.
>
> -Cameron
>
> ...
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350990

hofar...@houseoffusion.com

unread,
May 3, 2012, 5:09:02 PM5/3/12
to ColdFusion Technical Talk

Ever since ColdFusion 6, ColdFusion has always had the feature to do an
ArrayFind()....

http://www.andyscott.id.au/2012/5/3/ColdFusion-and-using-ArrayFind-prior-to-ColdFusion-9
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350991

hofar...@houseoffusion.com

unread,
May 3, 2012, 11:24:57 PM5/3/12
to ColdFusion Technical Talk

> Ever since ColdFusion 6, ColdFusion has always had the feature to do anArrayFind()....

True. Though indexOf() has a few additional nuances over arrayFind. It is both case and data type sensitive.


-Leig

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350992

hofar...@houseoffusion.com

unread,
May 4, 2012, 4:48:32 AM5/4/12
to ColdFusion Technical Talk

ArrayFind() is case senstive, that is why there is an ArrayFindNoCase().
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350993

hofar...@houseoffusion.com

unread,
May 4, 2012, 5:12:47 AM5/4/12
to ColdFusion Technical Talk

>� ArrayFind() is case senstive, that is why there is an ArrayFindNoCase().

Yes but the indexOf(..) method is _always_ case sensitive. Also, unlike arrayFind/FindNoCase it is data type sensitive as well. ie indexOf(15) does not produce the same results as indexOf("15"). So it is good to be aware of the nuances.

-Lei

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350994

hofar...@houseoffusion.com

unread,
May 4, 2012, 5:43:29 AM5/4/12
to ColdFusion Technical Talk

Not sure how you tested this, but if you have

<cfset myArray = ["1","2","3","4"] />

<cfoutput>

#myArray.indexOf(1)+1#

</cfoutput>

It returns the index of the value, secondly if you wish to do a case
insenstive index then it is still possible.

Lets take the following code for example that returns true or false if it
contains the string

<cfset myArray = ["myTest","2","3","4"] />

<cfoutput>
#myArray.indexOf(lcase('mytest'))+1#
#containsIgnoreCase(myArray, 'myTest1')#
</cfoutput>

<cfscript>
public boolean function containsIgnoreCase(required array arrayList,
required string s) {
var it = arrayList.iterator();
while(it.hasNext()) {
if(it.next().equalsIgnoreCase(s))
return true;
}
return false;
}
</cfscript>

So as you can see it is extremely possible, But what would be better is if
ColdFusion used Java as part of its language and was OOP, that would mean
you could write a component that extended the ArrayList / Array and
override the equals to do the case insensitive compare.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350995

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:10:33 AM5/4/12
to ColdFusion Technical Talk

> Not sure how you tested this

Define a variable representing a number as a double:

��������� <cfset y = val("15")>

� ������� <cfset arr = [y]>

Now run indexOf("15"). The value is not found because unlike CF functions, java lists also consider data type when determining element equality.

������� 15 = #arr.indexOf("15")#� ==> -1 / not found
�������� y = #arr.indexOf(y)# ==> 0 / found

> It returns the index of the value, secondly if you wish to do a case
> insenstive index then it is still possible.

Well my point was not that it is _not_ possible ;-) It was that indexOf is not a straight equivalent of CF9's array functions. So before using it,� be aware of these two differences.

>� public boolean function containsIgnoreCase(required array arrayList,
> var it = arrayList.iterator();
> while(it.hasNext()) {

Honestly, I do not see the benefit of down to the java level for this. If you are going to end up looping anyway, may as well use a native cfloop array="...". It is

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350996

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:15:59 AM5/4/12
to ColdFusion Technical Talk

Grr.. my responses keep getting cut off.� Anyway, the very last sentence was:

"Honestly, I do not see the benefit of down to the java level for this.
If you are going to end up looping anyway, may as well use a native
cfloop array="...". It is simpler and is less code".



-Leigh
</testWhereResponseIsCutOff

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350997

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:40:29 AM5/4/12
to ColdFusion Technical Talk

The point is that it is still possible...
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350998

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:47:22 AM5/4/12
to ColdFusion Technical Talk

>� The point is that it is still possible...

{tap, tap} Is this thing on?

-Leig

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350999

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:56:41 AM5/4/12
to ColdFusion Technical Talk

Leight I am not going to get into any more of a debate over this, the point
that I made is that you can use Java to do the ArrayFind to be used in
ColdFusion 6 - 8, now although you have brought up a good point any decent
developer can run with this, and write an ArrayFind to do the same thing.

It took me a whole 2 mins to write the ArrayFind(array, object, [case])
that can do the same thing as ColdFusion 9's ArrayFind() and
ArrayFindNoCase(), I will stand by the fact that just because it is not in
an older version doesn't mean you can't do it.

Your point of the orignal indexOf() is very valid, but I maintain that it
is do able if one is to think outside the box.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351000

hofar...@houseoffusion.com

unread,
May 4, 2012, 9:01:49 AM5/4/12
to ColdFusion Technical Talk

Andrew - Sorry if you misunderstood me. It is not a debate. It is a simple explanation of how the method actually works. As the earlier example demonstrated, indexOf does not behave in a typeless manner - as most would expect from CF - and as arrayFind/FindNoCase do.� So it does quite nicely for case sensitive string searches. But if you fail to account for its detection of data types, the results for numbers, dates, etcetera will frequently be wrong.� So like any other function, it is important to understand how it operates so you can use it properly and avoid common gotchas.�

-Leigh
====

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351001

hofar...@houseoffusion.com

unread,
May 4, 2012, 9:06:18 AM5/4/12
to ColdFusion Technical Talk

Yeah I know which is why I agree with that point you made, I have created a
new blog post where I have taken the code for indexOf() from java and
modified it to work in this manner for ColdFusion.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351002

hofar...@houseoffusion.com

unread,
May 4, 2012, 10:19:04 AM5/4/12
to ColdFusion Technical Talk

Is anyone using the CF9/OpenOffice to convert Word/Excel documents to PDF? How well is it working? What sort of issues did you run into? How did you get around them?

Trying to evaluate this option before diving in...

Thanks,
Justin

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351003

hofar...@houseoffusion.com

unread,
May 4, 2012, 10:27:05 AM5/4/12
to ColdFusion Technical Talk

> Is anyone using the CF9/OpenOffice to convert Word/Excel documents to PDF? How well is it working?
> What sort of issues did you run into? How did you get around them?
>
> Trying to evaluate this option before diving in...

We're using it, and haven't run into any significant issues, except
for one - the process itself is fairly slow, and you wouldn't want to
be doing a whole lot of these concurrently. But you can program around
that via queuing, threads, etc.

If you have questions about how it would handle specific documents,
it's very easy to set up a test environment and just try it out with
those documents.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351004

hofar...@houseoffusion.com

unread,
May 4, 2012, 10:34:21 AM5/4/12
to ColdFusion Technical Talk

Excellent! I will go ahead and give it a shot. Thanks for the input Dave!

-----Original Message-----
From: Dave Watts [mailto:dwa...@figleaf.com]
Sent: Friday, May 04, 2012 9:27 AM
To: cf-talk
Subject: Re: CF9/OpenOffice for Word to PDF


> Is anyone using the CF9/OpenOffice to convert Word/Excel documents to PDF? How well is it working?
> What sort of issues did you run into? How did you get around them?
>
> Trying to evaluate this option before diving in...

We're using it, and haven't run into any significant issues, except for one - the process itself is fairly slow, and you wouldn't want to be doing a whole lot of these concurrently. But you can program around that via queuing, threads, etc.

If you have questions about how it would handle specific documents, it's very easy to set up a test environment and just try it out with those documents.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351005

hofar...@houseoffusion.com

unread,
May 4, 2012, 4:28:42 PM5/4/12
to ColdFusion Technical Talk

>>Is anyone using the CF9/OpenOffice to convert Word/Excel documents to PDF? How well is it working?

Pretty badly. I even didn't try it under CF since I never was able to get a proper conversion from MS Word to Open Office. It might work well with plain text, but forget about formating.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351006

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:24:40 PM5/4/12
to ColdFusion Technical Talk

On Fri, May 4, 2012 at 4:19 PM, Justin Hansen wrote:
> Is anyone using the CF9/OpenOffice to convert Word/Excel documents to PDF? How well is it working? What sort of issues did you run into? How did you get around them?

If you have a history / archive of documents that have not been
created with PDF conversion in mind any conversion project is going to
be painful. That is not because of either OpenOffice or ColdFusion,
but because Office type of documents tend to be of very poor quality.
I have done one project in particular for one of the Big Four where we
basically pointed LiveCycle PDF Generator + MS Office + OpenOffice at
a network drive with 12 years of documents to convert \and the things
we ran into were:
- password protection;
- missing fonts;
- no print permissions;
- incorrect print ranges;
- wrong paper format;
- missing linked documents;
- Office apps hanging on various dialogues (updates, missing
references files, macros etc.).
I believe the project ended up sending a significant part to India for
manual conversion.

But if you are dealing with current documents it is a whole different
ballgame. Take a CMS like Razuna or Alfresco and configure / program
it to run an automated PDF conversion for every document that is being
saved. All errors get returned to the person who uploaded the document
and people will learn fast. Fix the permissions so that only the owner
can download the source format and the rest has to use the PDF file
and you have turned the rest of the users into a large QA group.

Jochem


--
Jochem van Dieten
http://jochem.vandieten.net/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351007

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:40:45 PM5/4/12
to ColdFusion Technical Talk

>>12 years of documents to convert

For 12 years old MS Word documents, I can believe Open Office is capable of interpreting the document properly, but for more recent ones, Op.Of seems to be far behind.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351008

hofar...@houseoffusion.com

unread,
May 4, 2012, 6:44:31 PM5/4/12
to ColdFusion Technical Talk

Thanks for this post. I've not had time to get back into this yet, but
will run some experiments against the data I've got to see what actually
works best. Worst case would be three or four email addresses being
searched for in a result list of 4000 or so returned from the database.


> I have created a new blog post where I have taken the code for indexOf() from java and
> modified it to work in this manner for ColdFusion.
>
> -- Regards, Andrew Scott WebSite: http://www.andyscott.id.au/


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351009

hofar...@houseoffusion.com

unread,
May 5, 2012, 2:41:46 PM5/5/12
to ColdFusion Technical Talk

I did two test using the basic code below.
First test exactly like below using a list.
2nd test, modifying the below to build an array instead of a list and
checking for a duplicate value in the array

The query used returned a list of close to 14,000 email addresses....

Average total time in both cases was around 400 milliseconds (out of
running the code 20 times or so)
On the average, the list compare method edged out the array by 10 or 20
milliseconds, BUT - sometimes the array method won out.
Not sure what I learned from that. The list method is slightly less code
and I've got that working already. Think I'll leave it as is.
At the most, this type of thing only gets run a few times a day, so it's
not constantly chewing server resources.
---------------------------------------------------------------------------------------------------------------------------------

<cfset req.thisLIST = "les...@bellsouth.net,someo...@somewhere.com">
<cfset sTime = getTickCount()>
<cfquery name="rmailLIST">BIG QUERY HERE THAT RETURNS 14,000 email
addresses</cfquery>

<p>Time after Initial Query: <cfoutput>#evaluate(getTickCount() -
sTime)# milliseconds</cfoutput></p>

<cfset req.groupLIST = #valuelist(rmailLIST.ml_email)# />

<p>Time after Build List: <cfoutput>#evaluate(getTickCount() - sTime)#
milliseconds</cfoutput></p>

<cfoutput>
<cfloop list="#req.thisLIST#" index="i">
<cfif IsDefined("i") AND isVALID("email", "#i#") AND NOT
listfindnocase(req.groupLIST,#i#)>
<p>#i# wasn't found</p>
<cfelse>
<p>#i# was found</p>
</cfif>
</cfloop>
</cfoutput>

<p>Time after CHECK LIST: <cfoutput>#evaluate(getTickCount() - sTime)#
milliseconds</cfoutput></p>


> I have created a new blog post where I have taken the code for
indexOf() from java and
> modified it to work in this manner for ColdFusion.
> -- Regards, Andrew Scott WebSite: http://www.andyscott.id.au/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351010

hofar...@houseoffusion.com

unread,
May 5, 2012, 9:51:23 PM5/5/12
to ColdFusion Technical Talk

Anyways if you are looping why don't u add it like a key of structure in that case all keys are your unique email id's.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351011
Reply all
Reply to author
Forward
0 new messages