I'm not going to disagree with the other replies ....
Plan A. use your database
Plan B. create an in-memory SQLite database.
Plan C. use an array, kind of like you are doing.
And *only* if there are good reasons for not doing Plans A or B, then :
C1. Instead of
repeat for each key x in aPlaylist
repeat for each key y in aPlayList[x]
do
repeat for each key x in aPlaylist
repeat for each element ey in aPlayList[x]
Also, instead of
put aPlayList[x] into aFilteredPlayList[z]
do
put x into aFilteredPlayListIndex[z]
(there's no need to replicate all the data when the array will continue to
exist, just keep the indices you want).
C2. Did you really mean "check *all* columns in the array" ?
Should it not be "check all the 'properties' columns" ?
If so - that's another reason to use a/the database :-)
C3. Create an 'allproperties' column ?
There's probably a fast/easy way to do that either in the database, or as you
extract from it - but a database expert would have to tell us how to do that.
Alternatively, when you extract, just do
repeat for each key x in aPlayList
repeat for each item y in thePropertyColumns
put aPlayList[x][y] & SPACE after aPlayList[x]["allproperties"]
end repeat
end repeat
or, delay this until first search :
repeat for each key x in aPlayList
if aPlayList[x]["allproperties"] is empty then
repeat for each item y in thePropertyColumns
put aPlayList[x][y] & SPACE after aPlayList[x]["allproperties"]
end repeat
if aPlayList[x]["allproperties"] is empty then -- so that subsequent
searches never rebuild this
put SPACE into aPlayList[x]["allproperties"]
end if
end if
if aPlayList[x]["allproperties"] contains pFilterPattern then
put x & CR after z
end if
end repeat
Alex.
On 23/08/2017 16:24, Sannyasin Brahmanathaswami via use-livecode wrote:
We use these arrays with media metadata that is extracted from our database of media
metadata. The dbase was originally designed for lots of columns so that "there is
nothing we cannot know about a media item" incorporating DCIM columns and also W3C
media metadata initiative's recommended properties. In actually usage for any give media
item only a small subset of columns containe any data. but we do use almost all the
columns at one time or another. There are no blobs, so this is very light weight data.
Anyway… this results in arrays which contain 1 top level key per record and that element
contains another 40 or so keys for the columns of the database. most of which are
empty/unused. So these arrays are never "heavy" in terms of bytes.
e.g.
aPlayList may have 1000 keys (numeric 1-1000)
where each top level key contains a whole record:
in each one we have
aPlayList [1]["title"]
aPlayList [1]["subtitle"]
aPlayList [1]["genre"]
aPlayList [1]["description"]
aPlayList [1]["artist"]
aPlayList [1]["theme"]
aPlayList [1]["creator"]
aPlayList [1]["audience"]
# and 30+ more "properties" for the media item
OK so let's say user want sto search "blues" and I want the UX to check *all*
columns in the array. What is the best way to do this?
I tried a simple test.
on mouseup
put "apple" into aFruits["1"]
put "orange" into aFruits["2"]
put "plum" into aFruits ["3"]
put aFruits contains "orange"
end mouseup
and it returns "false"
The only other strategy I can see would be
put 1 into z # for our new filtered play list
repeat for each key x in aPlaylist
repeat for each key y in aPlayList[x]
if aPlayList[x][y]contains "blues" then
put aPlayList[x] into aFilteredPlayList[z]
add 1 to z
end if
end repeat
end repeat
So then if we started with 1000 "records" in the array and we found "blues" in
any column of any record, for, say 20 of them, we end up with a new array.
aFilteredPlayList # containing top level keys 1-20 for 20 records, put the
titles into a list field and viola: the clickline number matches the array key
and away we go.
OK I can make this work, (have to since I don't see another way)
But it seems like a lot of looping.
Is there a more efficient approach?
BR
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode