• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

criteriaFind method question

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are we suppose to create this function and place it in the data class. Also do we only use this function for an exact match or to populate all records via a wild character such as *.* or all?
etc etc... Thanks any examples of this search method would be appreciated.
Thanks Randy.
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I have the same question I just started my assignment.
Any Help graetly appreciated for I am new to Java.
Thanks Lisa
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
criteriaFind method is a method that you need to implement. It basically does the searching of the database. A client will enter a query "Original ariport=SFO", it should return all records that have SFO as its' Original airport.
The "any" criteria is just like a wild card.
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot I believe I will use the find method and use alot of its implementation in my criteriaFind method. Am I on the right track?
Thanks Lisa
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion, you are not able to use the given find() method to implement your criteriaFind() because it is of limited usuage. For my case, I overload the find() method to extend the usuage, and call ed overloaded find() method from within the criterFind() method.
Hope this helps.
Rudy
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rudy,
If you call find() from criteriaFind you will be searching
the whole database per EACH column in your search criteria.
More efficient way would be to use the code from find()
as an example of how to write criteriaFind() which will
do one database scan per all columns in the search criteria.
Sun does look at the efficiency of criteriaFind.
Regards, Ihor
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ihor,
My overloaded find() method will not scan the whole database per column. Instead it will scan the whole database per record. Simply speaking, I have the criteriaFind() method tokenizes the string criteria passed in. The tokenized criteria in the form of key/value pair will then be passed into my overloaded find() method in the form of a collection object like vector. Inside my overloaded find() method, I will read record one by one, and any record that does not satisfy the criteria specified in the collection object will be skipped.
Please feel free to give comments or any better way to improve the efficiency based on my approach.
Rudy
 
Ihor Strutynskyj
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rudy,
Now it's more clear what your overloaded find() does. I did the same but inside the criteriaFind() with the little difference that my criteria is stored in the array of ArrayLists which is a bit more efficient to traverse than synchronized Vector. I also keep separate int[] of indexes for even faster scanning of search criteria.
Regards, Ihor
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic