Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creteriaFind method.

 
mark polo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
let me start by saying that find method works as following it looks at the first field only in the db and if mathc is found it returns the DataInfo[] for it. Now would be right of me if i do the following. Let's say the user is searching for Origin=SFO and Destination = DEN now after parsing this i would have SFO and DEN value that i am looking for. Now i compare what readRecord returns with my parsed values and if they match i pass that info to DataInfo and then show results to the user.Woudl this be fine or not?
thank you.
 
J Hartley
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes that sounds right. My criteria find is very similar to find, except that is uses the StringTokenizer to split the criteria up. You just need a few more "for" loops in there to take into account the numerous criteria you have, and the fact that you have to compare these criteria to the fields in each row.
Hope this is ok,
Thanks
Joe
 
Kevin Cary
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess my approach is a little different. I'm using the methods getFields and getValues directly then us loops to build strings so I can compare based on value and field location. The problem I have with find is it compares only values and not names. What do you think?
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have implemented by criteriaFind method differently because searching record by record is inneficient. I keep them in a cach but what happends is now if someone deletes a record or adds a record my cach has to reflect these changes. I must now modify add and delete methods a little , has anyone done that ?
 
Aleksey Matiychenko
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an Index class that works on a particular field.
Basically I added addIndex(String FieldName) to my data class. The index creates a hash of all records and allows instant retrieveal of all records matching the search.
My criteriaFind method finds the index on a first field in the search and then loops only through those few records.
This method works about 5 times faster.
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi aleksey do you call addIndex() method every time the search is about to be made or is it just loads once ?
Here is how i build mine
I have to hashtables one contains key from Destination column and values an array of integer position of that record. The other hash contains the Dest as the key and array of integers the position of that record. Now once the search is made all i have to do is pass to them the key like DAL and it wlil give me the record positions now i compare them with both hash and if they match i retrieve that record it should work reall fast. What do you think ?
 
Aleksey Matiychenko
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only call addIndex once when I initialize my Data Server.
I made my Index class generic so it works on any specified column.
[This message has been edited by Aleksey Matiychenko (edited May 24, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic