Data Structure for mapping flat fliles to in memory.

Discussions

Performance and scalability: Data Structure for mapping flat fliles to in memory.

  1. 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, Maria

    Threaded Messages (6)

  2. 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..
  3. 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..
    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
  4. plz clarify[ Go to top ]

    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 ?
  5. Re: plz clarify[ Go to top ]

    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
  6. Re: plz clarify[ Go to top ]

    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
    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?
  7. Re: plz clarify[ Go to top ]

    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.