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

criteraFind

 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To all those guys who passed. How did you implement criteria find? Did you guys use a linear algorithm or some other optimised one? I personally cant see of any way other than going though all records one by one. Caching records may be good, but then which do you cach, cache handling is a pain and may be over kill.
Any suggestions, tips, would be great...
Thanks oh guru's of java
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I just looped through record by record and checked to see if that record matched. If it did, I put it into an ArrayList of matches.
Mark
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You Sir are the most helpful man there is on the forum. God bless.
 
Gennady Shapiro
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest that you search this forum for any question you have, not only post it.
This topic was too extensively discussed in this forum
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gennady, I apologise for creating a new post. As I am new to posting I wrongfully assumed that old topics would never resurface on the top . My mistake.
I have another question on this topic. The assignment gives an example for the criteriaFind that looks like "FLIGHT='SFO', LV='OHARE'". Why the ticks? Do we need to handle ticks or just parse them out? Why would I need to create a query on the client with ticks when the db values dont have ticks? Looks like extra work to me
 
Gennady Shapiro
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you mean the single quotation mark by 'tick'... Why ticks? No particular reason, except clear demarkation of values. For this protocol to be extendable you should be able to do something like Airline='Airline, Inc'...here you value includes a comma but it is within the tick boundaries so its value is easily extracted.
This is a simple variation of name/value protocol:name1='value1',name2='value2' and the quotation mark is assumed a special symbol demarkator -- seems reasonable to me. Although if you ever programmed ODBC you know what pain these symbols can be.
For your projects you may construct your own protocol but here we dont get to choose: the spec says use ticks, so we use them.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks quite right, the thoughts of a separator appearing inbetween ticks never crossed my mind . How about things like 'jack's airline's'. When do we tell the end of a string?
 
Gennady Shapiro
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's excatly why I said it's a pain doing it in ODBC, try getting a name like O'Reilly out of a database using ODBC.
The way out of this ... there is none -- you need a symbol to demarkate values, one way or another. Syntaxically, comma is much more likely to appear than "'" in common words of european languages and it is a traditional natural demarkator.
If you wanna be really diligent about it you may escape-encode tick that are part of your value when you write them to DB and escape-decode when reading, just like HTTP does it.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Optimal processing? Can a StreamTokenizer be used instread of a StringTokenizer? I think the best way to parse would be to chop the name value to a map and then process. However a check needs to be made to see if the name is there. Any algorithm suggestions would be appreciated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic