iView home page
iView Multimedia Forum Index

FAQ FAQ     SearchSearch     MemberlistMemberlist     UsergroupsUsergroups    RegisterRegister  
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Faster Search?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    iView Multimedia Forum Index -> VB Script
View previous topic :: View next topic  
Author Message
blueman541



Joined: 21 Dec 2005
Posts: 23

PostPosted: Mon Nov 20, 2006 11:22 am    Post subject: Faster Search? Reply with quote

I want to be able to search for a filename and then put it into a specified catalog set.

I have a about 20k images and doing a for loop comparing string names to find a match takes a long time. Is there any faster way?

When i manually use the 'find' feature of iView, it locates filenames superfast, just my VBscript code is superslow.

im doing

For index=1 to count
if strcomp("blah.jpg", cat.mediaItems.Item(index).Name) = 0 Then
mySet.Add(cat.mediaItems.Item(index))
End If
Back to top
View user's profile Send private message
johnbeardy



Joined: 22 Nov 2004
Posts: 1137
Location: Dulwich, South ("Sarf") London

PostPosted: Mon Nov 20, 2006 1:36 pm    Post subject: Reply with quote

Yes, because you're having to loop through interrogating each record. You really need to be able to code the Find function, but that's not in the scripting engine. I've asked already, but you should also put in a feature request .

Secondly, coding catalog sets isn't 100% reliable - one or two bugs there. You could script the filename into a custom field though.

One workaround is to export the metadata to a text file or xml and use that in an external app for searching. It's q a bit of work though.

John
_________________
PC and Mac too
iView scripts & utilities
Back to top
View user's profile Send private message Visit poster's website
blueman541



Joined: 21 Dec 2005
Posts: 23

PostPosted: Mon Nov 20, 2006 7:47 pm    Post subject: Reply with quote

Quote:
When you script you can be much more flexible than the Find feature within the application. For instance the 'Landscape' script, that comes with iView MediaPro, finds items that are longer horizontally than vertically but this cannot be done using the 'Find' dialog. Using normal VB script you can query any aspect of the media items in a catalog in a much more creative way than when you are constrained by the options in a dialog.


In the same way there is no rename script function in iView MediaPro. But using standard VB script you can rename a media file in a much more flexible way.


Well... this is the response i got from iView. I guess tuff luck to me. No Find scripting feature.
Back to top
View user's profile Send private message
polas



Joined: 27 Nov 2006
Posts: 4
Location: sydney

PostPosted: Mon Nov 27, 2006 4:39 am    Post subject: Reply with quote

I used to use showAnnotation to narrow my search:

app.ActiveCatalog.ShowAll
app.ActiveCatalog.ShowAnnotation(search_string)

and than I loop through what remaining.

it looks that there is a bug in showAnnotation as without showAll it will work only with visible items but once you narrow selection using showAnnotation you cannot narrow it again as it keeps searching in All again.
_________________
Pawel
Back to top
View user's profile Send private message Visit poster's website
blueman541



Joined: 21 Dec 2005
Posts: 23

PostPosted: Mon Nov 27, 2006 5:01 am    Post subject: Reply with quote

What i do is load all the mediaItems into a Dictionary Object, im assuming its like a hash table, using the filename path as the key.

Searches are much faster once it is in the dictionary
Back to top
View user's profile Send private message
polas



Joined: 27 Nov 2006
Posts: 4
Location: sydney

PostPosted: Mon Nov 27, 2006 5:46 am    Post subject: Reply with quote

bluemen:

could you please post some sample code how you do this? to be honest I know nothing about Dictionaries in VB. thanks :-)
_________________
Pawel
Back to top
View user's profile Send private message Visit poster's website
blueman541



Joined: 21 Dec 2005
Posts: 23

PostPosted: Mon Nov 27, 2006 6:04 am    Post subject: Reply with quote

http://www.devguru.com/technologies/vbscript/QuickRef/dictionary.html


Site above has examples of almost everything you need to know about VBscript with simple examples.[/url]
Back to top
View user's profile Send private message
drmrbrewer



Joined: 24 Sep 2005
Posts: 510
Location: UK

PostPosted: Fri Jul 06, 2007 11:14 am    Post subject: Reply with quote

I'm running up against speed problems too. Normally I restrict my looping to a smallish selection of images, so the speed issue isn't a problem. But in a script I'm coding up now, I'd really rather like it if I could do a filename search on the whole catalog, instead of having to jump through hoops to limit the search first. Should be possible to do quick searches across the entire catalog in a cataloging application.

Strangely enough, I already implemented a kind of Dictionary object independently of the suggestion above -- just using an Nx2 array where N = no. of items in catalog and 2 is: one for filename (the key) and the other for the media item itself.

Something like this (sorry, it's javascript, but this thread is quite relevant to both JS and VB):

Code:

   var catLength = iViewCat.MediaItems.Count;
   var itemStore = MultiDimensionalArray(catLength, 2);
   for(j = 1; j <= catLength; j++)
   {
      mediaItem = iViewCat.MediaItems.Item(j);
      itemStore[j-1][0] = mediaItem.Name;
      itemStore[j-1][1] = mediaItem;
   }


Trouble is... I find even the above loop -- just getting the information into the array for later lookup operations -- takes forever... roughly 1 minute per 100 images... which still makes it completely impractical to run such a script on a large catalog.

Is using a VB Dictionary object any faster? I'm not sure why it would be... there isn't much in the above loop that wouldn't apply in getting the same information into a Dictionary object.

Any thoughts on how I can do this any faster?

Thanks,

Mike

P.S. the ShowAnnotation() function at first seemed quite helpful -- but for me it is completely useless on further inspection because: if media items are found, it leaves just those items visible -- which is fine -- but if no media items are found then it leaves all media items visible -- so what use is that, exactly?

I suppose I could do a Count of visible items before and after the search, and if they are the same, then make the bold assumption that no items have been found... maybe I'll try that.

(Trouble with this approach anyway is that the view created by the user just before running the script is destroyed -- because of the need to apply a ShowAll() operation before each ShowAnnotation() operation.)

Any other thoughts?
Back to top
View user's profile Send private message
drmrbrewer



Joined: 24 Sep 2005
Posts: 510
Location: UK

PostPosted: Mon Jul 09, 2007 9:34 am    Post subject: Reply with quote

Just an update: I tried the ShowAll() / ShowAnnotation() approach to finding a list of media items in the catalog -- and it works *much* faster than just looping through each media item in the entire catalog and doing a comparison for each.

There are at least three issues to be aware of:

(1) if no media item is found, the visible media items are left unchanged (instead of the view being reduced to one with no media items)... so the only way of telling your search was unsuccessfull is to compare no. of visible media items before and after, and assume that if they're equal, then nothing was found.

(2) the view selected by the user before running the script is destroyed... so either warn them of this and give them the option to bail out, or save the view to a catalog set for later retrieval.

(3) if you rely on the user selecting a bunch of images before running the script, and you perform some search actions relating to each selected file, you need to save the list of selected media items in an array because the selection will be lost -- and do this saving *after* a ShowAll() operation otherwise you'll be indexing into the wrong set of items later. Or stick them in a temporary catalog set.

Cheers,

Mike
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    iView Multimedia Forum Index -> VB Script All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



  © iView Multimedia Ltd. | All Rights Reserved Privacy Policy | Copyright | Site Map