Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
... This would require a major overhaul of the Data class and seems, to me, out of the intended scope of the project.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
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.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Even crazy and silly looking problems are sometimes real.
Even crazy and silly looking problems are sometimes real.
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 ..
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Even crazy and silly looking problems are sometimes real.
... 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 ..
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Even crazy and silly looking problems are sometimes real.
Even crazy and silly looking problems are sometimes real.
Suggestions please......
Originally posted by Eugene Kononov:
... That way, if database schema changes, not a single line of code in your criteriaFind() method need to change.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Even crazy and silly looking problems are sometimes real.
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.Search Algorithm
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.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
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.
nextRecord
Aadhi
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
Aadhi
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|