... This would require a major overhaul of the Data class and seems, to me, out of the intended scope of the project.
I'm confused. Since the db.db file of flights is not sorted, the only possible search algorithm is a record-by-record search of the entire file. This is clear but nowhere near efficient.
1.validating the column name is not required but its a simple thing to do.. i have implemented it is this a overkill am doing ??
2. if the caller of this method forgets to specify a value for the field he wants to search am just giving it empty string ..
//instead i can throw an exception back
3, i have implemented both the AND and OR way of searching the underlying db right now the client can't specify whether he wants to perform a AND or a OR in the supplied columns .. future enhancements and overloading the criteria method can be done to achieve this effect ..right now am using the AND based search method
not required .. but serves a basic purpose of future search's
4, it takes .. 2 seconds for the whole search operation to complete for 1000 clients searching at the same times supplying 5 column and values to match both in AND and OR ..
... goin by the way u sugest .. just returnig a empty datainfo makes my life easy but serves no purpose to the sollutin we are providing .. what shall i do .. stick to the specifications or justify my implementation ..
Originally posted by Eugene Kononov:
... That way, if database schema changes, not a single line of code in your criteriaFind() method need to change.
Exactly my implementation. I had a criteriaFind(String criteria) which would do the parsing, and at the end call an overloaded private criteriaFind(String fieldCriteria) that did the actual search. The second method expected an array element for each field in the database, and a null String would indicate the absence of any criteria for that field.
Originally posted by Richard Yip:
From all the ideas gathered, I have decided break the functionality of criteriaFind into two task.
The first task is the parsing algorithm which breaksdown the criteria string into a search critera object.
The second task is the searching algorithm. This uses the search criteria object in searching the records.
What happens if it does?
My assumption for the criteraString is that it has no duplicate field.
Would a StringTokenizer simplify matters? I split on "=',", returning tokens.
1. Iterate the criteria string character by character.
Here our implementations start to diverge. Two remarks.
5. put value token into the map.
6. put the map into a vector.
Whoa. What with the cloning of Vectors and nested iterations, this is really seriously convoluted and suboptimal.
1. Iterate the list of records.
2. At each record, create a copy of the parsed vector. Each record will make changes to this copy.
3. Iterate the list of record fields.
4. At each record field,
5. Iterate the parsed vector.
6. Compare the record field with parsed vector field.
7. If the field matches, compare the values.
8. If the values matches, delete the matching field/value pair in the copy of the parsed vector. This will indicate that one search criteria is successful.
9. Check if parse vector is empty. If empty (i.e. all search criteria is successful, positive record found), add record to record list.
10. Break out of record.
split the field, Value of searchString into HashMap
for each record
for each field
if field macthes searchField
add into HashMap
compare searchMap and recordMap
if equals add to result.
i am confused about the second point. i will extract the field,Value from the record (goes into HashMap) , matching the fied,Value of criteriaString passed (goes into HashMap) and compare it . i dont understand why this is not advisable. maybe that the 1st and 2nd options are referring the same "ANY" usage
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!https://www.kickstarter.com/projects/paulwheaton/greenhouse-1