How to index the flat file like mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Man4ish
    New Member
    • Mar 2008
    • 151

    How to index the flat file like mysql

    In mysql values can be retrieved like less than a given value.
    select * from table where number > 12. But using mysql will be slower, so planning to implement the same methodology but that should be very fast. Which data structure can be used? In my previous thread i have already asked about B Tree and got very good reply but now my planning is to implement the same methodology as used in mysql for key retrieval. Thanks in advance.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Then you can use memorymap in which and you can maintaina map with key and position so that you can easily retreive the values.

    raghu

    Comment

    • Man4ish
      New Member
      • Mar 2008
      • 151

      #3
      Originally posted by gpraghuram
      Then you can use memorymap in which and you can maintaina map with key and position so that you can easily retreive the values.

      raghu
      Can i retrieve the value with less than a given value if yes then how we can implement it.

      Comment

      • Man4ish
        New Member
        • Mar 2008
        • 151

        #4
        [QUOTE=Man4ish;3 475178]I have one example. I have one data of only supervisor in company for past 50 years.

        Supervisor Joining_date leaving date height
        A.M kadik 23/2/51 23/4/57 165
        M.A. Khan 25/4/57 2/02/64 179
        R. A. Sharma 3/02/64 05/09/79 169
        K.Kandaswamy 6/09/79 07/07/91 174
        R.A.Brown 09/07/91 09/08/2000 165


        I need to get data (name ,height and data of joining) for all the supervisors which were there in period 2/02/71 to 03/05/95. This is very easy in mysql but how efficiently this can be done in C/C++.Since MySQL uses the B+ Tree structure. Can B+ Tree be used here?if yes how? I have no idea at all.Thanks in advance.

        Regards
        Manish

        Comment

        • gpraghuram
          Recognized Expert Top Contributor
          • Mar 2007
          • 1275

          #5
          The data can be in any format.
          But if u want to retreive values with some specific logic then you have to maintain keys accordingly.
          You can maintain one map with name as the key and the position.
          You can maintain a second map with the age as key or the period of stay and position.
          So when retreiving you have to use the right map and then get the values accordingly.

          raghu

          Comment

          • Man4ish
            New Member
            • Mar 2008
            • 151

            #6
            Originally posted by gpraghuram
            The data can be in any format.
            But if u want to retreive values with some specific logic then you have to maintain keys accordingly.
            You can maintain one map with name as the key and the position.
            You can maintain a second map with the age as key or the period of stay and position.
            So when retreiving you have to use the right map and then get the values accordingly.

            raghu
            Thank you very much for your answer. For small file it seems ok. but if i have a file of around 100MB then i have to read the whole file sequentially which may reduce the speed. How this can be done randomly?
            Thanks in advance.

            Comment

            Working...