Menu

Query Range

Help
fpdeguzman
2007-10-26
2013-04-09
  • fpdeguzman

    fpdeguzman - 2007-10-26

    hi, i'm using the berkeley db for .net 2.0. i would like to ask if you have a c# sample code of a function that performs a range search of data by specifying a start key and an end key. for ex. i want to get key 4,5,6 from the database containing 1,2,3,4,5,6,7,8,9,..., the start key is 4 and the end key is 6. thanks you very much!

     
    • Karl Waclawek

      Karl Waclawek - 2007-10-26

      AFAIK, the only way to do this with BDB is to do a regular forward search, and compare each retrieved record against the end of range condition.

       
      • fpdeguzman

        fpdeguzman - 2007-10-30

        will it not be efficient? because if we have a table containing million of records and we are performing linear or forward search and the starting range is somehow located at the near end. is there a way that we can point the cursor at the starting range and then do a forward search until it reaches the ending range? thank you very much...

         
        • Karl Waclawek

          Karl Waclawek - 2007-10-30

          That is what I meant. First you point the cursor at the range start, using the GetAt() method with the appropriate GetAtMode value (see the official BDB docs) then you iterate.

           
          • fpdeguzman

            fpdeguzman - 2007-10-30

            thank you very much for the input. have a nice day! =)

             

Log in to post a comment.