Results 1 to 4 of 4

Thread: Freeze::map.lower_bound

  1. #1
    sylvain is offline Registered User
    Name: Sylvain Fasel
    Organization: university of Geneva
    Project: quantum cryptographic systems
    Join Date
    Feb 2003
    Location
    Geneva (Switzerland)
    Posts
    42

    Freeze::map.lower_bound

    Hi,

    As I read in other post, or as I saw when looking at some part of the code, Freeze is very tightly coupled with Berkeley db. I am not familiar at all with Berkeley db, but looking at the documentation it seems that "search" possibilities are limited.

    I suppose that this is the reason why Freeze::map doesn't implement the lower_bound and upper_bound that are part of the STL standard for maps.

    It seems however, that it is possible to store data in berkeley db using some kind of Btree. So, my question is: are you planning to implement Freeze::map.lower_bound for a future release, or is it not possible?

    If not, do you have a hint on how I could implement this kind of features in a way that it smoothly interact with Freeze?

    The reason is of course to implement some simple "wildcards" searches, for example if a STL map contains some key/value pairs like : {"A","001"},{"Ba","002"},{"Bb","003"},{"C","004 "}, then lower_bound("B") will return an iterator on {"Ba","002"} and lower_bound("C") will return an iterator on {"C","004"} so by looping from the first iterator to the second (but not including it) I can extract record with keys beggining with "B".

    I would very happy if I could do the same with Freeze::map...

    Thanks in advance.

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Sylvain,

    Although a Freeze Map uses for storage a Btree Berkeley DB database, currently it is not "really" sorted. The Freeze:: DBMap template has no sorting argument, so the sorting on disk is the default: keys are marshalled using the Ice encoding (see the Ice Protocal chapter in the Ice book) , and Berkeley DB sorts the resulting binary strings.

    If you'd like to improve these Maps to make them sortable, you'll need to add a template parameter to specify the key sorting, and somehow pass it down to Berkeley DB. See http://www.sleepycat.com/docs/api_cx..._compare.html.
    and DB_SET_RANGE in http://www.sleepycat.com/docs/api_cxx/dbc_get.html.
    (In the next Ice release, the Freeze DBMap will be implemented using Berkeley DB/C++).

    Maybe you could also consider to use Berkeley DB directly?

    Cheers,
    Bernard

  3. #3
    sylvain is offline Registered User
    Name: Sylvain Fasel
    Organization: university of Geneva
    Project: quantum cryptographic systems
    Join Date
    Feb 2003
    Location
    Geneva (Switzerland)
    Posts
    42
    I just add a method lower_bound in DBMap that is exactly similar to find except that it calls a _db->getCursorAtKeyRange(k) method (instead of your _db->getCursorAtKey(k)).

    I added a getCursorAtKeyRange in DBI.cpp that is exactly similar to the getCursorAtKeyRange, except that is calls the Berkeley db c_get method with the argument DB_SET_RANGE instead of DB_SET for the flag argument (and of course I had to modife also DB.ice)

    As key in a db managed through freeze (in XML) always begin with the same <Key> tag, the default lexicographical ordering of the key of the freeze map is not altered. Thus, the method lower_bound discribed above works exactly as expected (I just made a few however) and this is perfeclty fine for my application.

    Thanks a lot.

  4. #4
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    I guess this works fine for strings as keys, and structs with only strings as keys, but it might not work for other key types.

    But since strings are the most common type of keys, perhaps we should add this for maps with strings or structs with strings as keys.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Freeze::ConnectionPtr from Freeze::Map Obj
    By paolo in forum Comments
    Replies: 1
    Last Post: 01-05-2008, 05:02 PM
  2. Freeze::Map and versioning
    By borax00 in forum Help Center
    Replies: 2
    Last Post: 05-10-2007, 06:34 PM
  3. getting normal map from freeze map
    By ctennis in forum Help Center
    Replies: 2
    Last Post: 03-09-2007, 07:48 AM
  4. Freeze Map doubt
    By pradeep in forum Help Center
    Replies: 1
    Last Post: 11-30-2006, 09:28 AM
  5. Freeze map ordering
    By dwk in forum Help Center
    Replies: 1
    Last Post: 04-26-2004, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •