How to use an array to solve the following...

Glen Bojsza gbojsza at gmail.com
Tue Feb 21 09:36:14 EST 2012


Once the final list has been made it could have up to 10 ?t columns but the
query is only for the lines identified as start and end based on the first
column which is xs.

There would be no other queries involving the data in the ?t columns the
whole line that meets the xs query is moved to a new list.

YES xs column will ALWAYS be sequential.

The good news is that the lists may grow as high as 1,000,000 lines and are
as little as 30,000.

The methods you have described are fast enough not to justify going to
sqlite (which in itself has a learning curve and adds to the stack
overhead).

thanks again.

On Tue, Feb 21, 2012 at 7:06 AM, Kay C Lan <lan.kc.macmail at gmail.com> wrote:

> On Tue, Feb 21, 2012 at 4:29 PM, Glen Bojsza <gbojsza at gmail.com> wrote:
>
> >
> > For example a user wants an starting xs value of 10 and an ending xs
> value
> > of 40 I think that if the keys are sequential (the keys being the first
> > column - xs) then it would be a fast solution using arrays since you
> should
> > be able to determine the starting line and ending line of the array
> without
> > needing to cycle through every line and then just produce a new array /
> > list. Again, is this a good use for an array?
> >
>
> Looking at your example more closely it could be possible to achieve some
> extremely fast results with arrays. But as always, if speed is really
> important to you you'd need to do some comparitive tests. As I think I've
> demonstrated it's not too hard to whip up a couple of test script to time
> solutions.
>
> Some determining factors.
>
> In a previous post you indicated that there would be 10 ?t columns. When
> you are doing your search are you after all data from every column? Then
> setting up flat data and doing repeat for each line will probably be the
> fastest. Alternatively you could create an array with the xs as the key and
> the entire line as the data.
>
> You indicate that your searches would be of sequential lines. If that is
> ALWAYS true, then repeat for each line will be very fast, if there is any
> possibility that the searches will not be of sequential lines, then some
> overhead will be introduced. Even so repeat for each line will still be
> fast. Conversely, it would be quite easy to create a list of every xs
> values from, in your example 10 to 40 and do a repeat for each to extract
> the data from an array. If there was a possibility that you didn't require
> the whole line of data, but just an ht or gt value, then this would not
> carry any overhead with an array search.
>
> On average you could get quicker results with an array but they are only
> small differences, and if your queries are less than 10s of thousands, then
> the amounts are so small they are probably unnoticeable.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list