-
Data Structure for mapping flat fliles to in memory. (6 messages)
- Posted by: Maria J
- Posted on: May 29 2008 12:03 EDT
Hi All, I am trying to create a data structure that would map a database search result that is stored as flat files, to in memory, so that I have to just call the mapped structure to retrieve my search result. Could someone help me by giving ideas how to implement it using java programming. Thank you in advance, MariaThreaded Messages (6)
- Re: Data Structure for mapping flat fliles to in memory. by Jyothish John on June 01 2008 04:53 EDT
- Re: Data Structure for mapping flat fliles to in memory. by Maria J on June 02 2008 12:22 EDT
- plz clarify by shalon toy on June 02 2008 16:50 EDT
-
Re: plz clarify by Maria J on June 02 2008 05:01 EDT
-
Re: plz clarify by Jyothish John on June 03 2008 12:54 EDT
- Re: plz clarify by Maria J on June 04 2008 04:20 EDT
-
Re: plz clarify by Jyothish John on June 03 2008 12:54 EDT
-
Re: plz clarify by Maria J on June 02 2008 05:01 EDT
-
Re: Data Structure for mapping flat fliles to in memory.[ Go to top ]
- Posted by: Jyothish John
- Posted on: June 01 2008 04:53 EDT
- in response to Maria J
SCJD? Read each line from your fat file, tokenize each field by the delimitters, then access each filed by the index of the token;) Get a hashed value for each line data for the Primary key.. -
Re: Data Structure for mapping flat fliles to in memory.[ Go to top ]
- Posted by: Maria J
- Posted on: June 02 2008 12:22 EDT
- in response to Jyothish John
SCJD?
Thank you for your reply :) How do I read directly from the console window?? I want to map the search result that I get from my output in the console window to in memory. thanks Maria
Read each line from your fat file, tokenize each field by the delimitters, then access each filed by the index of the token;)
Get a hashed value for each line data for the Primary key.. -
plz clarify[ Go to top ]
- Posted by: shalon toy
- Posted on: June 02 2008 16:50 EDT
- in response to Jyothish John
foo.txt O123 jeans blue 10 O123 shirts white 15 so after tokenizing each line, we would have for example : O123jeansblue10 now what ? Are you suggesting to have each line converted into a string object and generate its hashcode String line = new String("O123jeansblue10") int hashvalue = line.hashCode() Then insert this value into a hashtable where (key, value) is (O123, hashValue). How does this solve the authors question. plz clarify ? -
Re: plz clarify[ Go to top ]
- Posted by: Maria J
- Posted on: June 02 2008 17:01 EDT
- in response to shalon toy
foo.txt
Yes, I think it is closer to solving my problem. I will try it and let you know. Thanks for a better picture. Maria
O123 jeans blue 10
O123 shirts white 15
so after tokenizing each line, we would have for example :
O123jeansblue10
now what ? Are you suggesting to have each line converted into a string object and generate its hashcode
String line = new String("O123jeansblue10")
int hashvalue = line.hashCode()
Then insert this value into a hashtable where (key, value) is (O123, hashValue). How does this solve the authors question. plz clarify ? -
Re: plz clarify[ Go to top ]
- Posted by: Jyothish John
- Posted on: June 03 2008 12:54 EDT
- in response to Maria J
Lets Assume The file has just one line O123 jeans blue 10 Hashtable records = new Hastable(1); StringTokenizer tokens ; for each line read from the file, { tokens = new StringTokenizer(file.readLine(), " ") Hashtable fieldRecords = new Hashtable() for(int i=0, i<tokens.countTokens();i++) { fieldRecords.put(new Integer(i),tokens.nextToken()); } records.put(file.readLine().getHashCode(),fieldRecords) } and later you can get the element in the record as a Hashtable , and access any field in that record using the index of each field. As in Hashtable record = (Hashtable) fieldRecords.get("GJHG%%"); String jeans = record.get(1) etc etc.. Please treat this as an indicative algorithm. Was something similar , the author had in mind?foo.txt
O123 jeans blue 10
O123 shirts white 15
so after tokenizing each line, we would have for example :
O123jeansblue10
now what ? Are you suggesting to have each line converted into a string object and generate its hashcode
String line = new String("O123jeansblue10")
int hashvalue = line.hashCode()
Then insert this value into a hashtable where (key, value) is (O123, hashValue). How does this solve the authors question. plz clarify ?
Yes, I think it is closer to solving my problem. I will try it and let you know.
Thanks for a better picture.
Maria -
Re: plz clarify[ Go to top ]
- Posted by: Maria J
- Posted on: June 04 2008 16:20 EDT
- in response to Jyothish John
I think that works too, I have to try it. But how do i implement the same using hashmap or hashset? I want to ultimately get a huge structure that I can traverse through fast and is saved in memory. So that my following searches will just refer to this big structure and find its structure from it.