Example #1
0
 def range(self, lower, upper, max_=-1):
     """Get range matching ID numbers in a fixed-length database
     object."""
     tclist_objs = tc.fdb_range3(self.db, lower, upper, max_)
     if not tclist_objs:
         raise tc.TCException(tc.fdb_errmsg(tc.fdb_ecode(self.db)))
     return util.deserialize_tclist(tclist_objs, str)
Example #2
0
 def _getdup(self, key, raw_key=False, value_type=None):
     """Retrieve Python objects in a B+ tree database object."""
     (c_key, c_key_len) = util.serialize(key, raw_key)
     tclist_objs = tc.bdb_get4(self.db, c_key, c_key_len)
     if not tclist_objs:
         raise KeyError(key)
     return util.deserialize_tclist(tclist_objs, value_type)
Example #3
0
 def metasearch(qrys, type_, as_type=None):
     """Retrieve records with multiple query objects and get the
     set of the result."""
     qrys = [q.qry for q in qrys]
     tclist_pkeys = tc.tdb_metasearch(qrys, len(qrys), type_)
     pkeys = util.deserialize_tclist(tclist_pkeys, as_type=as_type)
     return pkeys
Example #4
0
 def metasearch(qrys, type_, as_type=None):
     """Retrieve records with multiple query objects and get the
     set of the result."""
     qrys = [q.qry for q in qrys]
     tclist_pkeys = tc.tdb_metasearch(qrys, len(qrys), type_)
     pkeys = util.deserialize_tclist(tclist_pkeys, as_type=as_type)
     return pkeys
Example #5
0
 def fwmkeys(self, prefix, max_=-1):
     """Get forward matching string keys in a B+ tree database
     object."""
     tclist_objs = tc.bdb_fwmkeys2(self.db, prefix, max_)
     if not tclist_objs:
         raise tc.TCException(tc.bdb_errmsg(tc.bdb_ecode(self.db)))
     return util.deserialize_tclist(tclist_objs, str)
Example #6
0
 def fwmkeys(self, prefix, max_=-1, as_raw=True):
     """Get forward matching string keys in a hash database object."""
     (c_prefix, c_prefix_len) = util.serialize(prefix, as_raw)
     tclist_objs = tc.hdb_fwmkeys(self.db, c_prefix, c_prefix_len, max_)
     if not tclist_objs:
         raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
     as_type = util.get_type(prefix, as_raw)
     return util.deserialize_tclist(tclist_objs, as_type)
Example #7
0
 def fwmkeys(self, prefix, max_=-1, as_raw=True):
     """Get forward matching string keys in a hash database object."""
     (c_prefix, c_prefix_len) = util.serialize(prefix, as_raw)
     tclist_objs = tc.hdb_fwmkeys(self.db, c_prefix, c_prefix_len, max_)
     if not tclist_objs:
         raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
     as_type = util.get_type(prefix, as_raw)
     return util.deserialize_tclist(tclist_objs, as_type)
Example #8
0
 def fwmkeys(self, prefix, max_=-1):
     """Get forward matching string keys in an abstract database
     object."""
     tclist_objs = tc.adb_fwmkeys2(self.db, prefix, max_)
     if not tclist_objs:
         self._raise('Error forward matching string keys in an abstract ' \
                         'database object.')
     return util.deserialize_tclist(tclist_objs, str)
Example #9
0
 def fwmkeys(self, prefix, max_=-1):
     """Get forward matching string keys in an abstract database
     object."""
     tclist_objs = tc.adb_fwmkeys2(self.db, prefix, max_)
     if not tclist_objs:
         self._raise('Error forward matching string keys in an abstract ' \
                         'database object.')
     return util.deserialize_tclist(tclist_objs, str)
Example #10
0
 def getdup(self, key, default=None):
     """Retrieve Python objects in a B+ tree database object."""
     (c_key, c_key_len) = util.serialize(key, True)
     tclist_objs = tc.bdb_get4(self.db, c_key, c_key_len)
     if tclist_objs:
         value = util.deserialize_tclist(tclist_objs, str)
     else:
         value = default
     return value
Example #11
0
 def fwmkeys(self, prefix, max_=-1, as_raw=True):
     """Get forward matching string keys in an abstract database
     object."""
     (c_prefix, c_prefix_len) = util.serialize(prefix, as_raw)
     tclist_objs = tc.adb_fwmkeys(self.db, c_prefix, c_prefix_len, max_)
     if not tclist_objs:
         self._raise('Error forward matching string keys in an abstract ' \
                         'database object.')
     as_type = util.get_type(prefix, as_raw)
     return util.deserialize_tclist(tclist_objs, as_type)
Example #12
0
 def fwmkeys(self, prefix, max_=-1, as_raw=True):
     """Get forward matching string keys in an abstract database
     object."""
     (c_prefix, c_prefix_len) = util.serialize(prefix, as_raw)
     tclist_objs = tc.adb_fwmkeys(self.db, c_prefix, c_prefix_len, max_)
     if not tclist_objs:
         self._raise('Error forward matching string keys in an abstract ' \
                         'database object.')
     as_type = util.get_type(prefix, as_raw)
     return util.deserialize_tclist(tclist_objs, as_type)
Example #13
0
 def range(self,
           keya=None,
           inca=True,
           keyb=None,
           incb=True,
           max_=-1,
           as_raw=True):
     """Get keys of ranged records in a B+ tree database object."""
     (c_keya, c_keya_len) = util.serialize(keya, as_raw)
     (c_keyb, c_keyb_len) = util.serialize(keyb, as_raw)
     tclist_objs = tc.bdb_range(self.db, c_keya, c_keya_len, inca, c_keyb,
                                c_keyb_len, incb, max_)
     if not tclist_objs:
         raise tc.TCException(tc.bdb_errmsg(tc.bdb_ecode(self.db)))
     as_type = util.get_type(keya, as_raw)
     return util.deserialize_tclist(tclist_objs, as_type)
Example #14
0
 def fwmkeys(self, prefix, max_=-1):
     """Get forward matching string keys in a hash database object."""
     tclist_objs = tc.hdb_fwmkeys2(self.db, prefix, max_)
     if not tclist_objs:
         raise tc.TCException(tc.hdb_errmsg(tc.hdb_ecode(self.db)))
     return util.deserialize_tclist(tclist_objs, str)
Example #15
0
 def search(self, as_type=None):
     """Execute the search of a query object."""
     tclist_pkeys = tc.tdb_qrysearch(self.qry)
     pkeys = util.deserialize_tclist(tclist_pkeys, as_type=as_type)
     return pkeys
Example #16
0
 def search(self, as_type=None):
     """Execute the search of a query object."""
     tclist_pkeys = tc.tdb_qrysearch(self.qry)
     pkeys = util.deserialize_tclist(tclist_pkeys, as_type=as_type)
     return pkeys
Example #17
0
 def range(self, keya=None, inca=True, keyb=None, incb=True, max_=-1):
     """Get keys of ranged records in a B+ tree database object."""
     tclist_objs = tc.bdb_range2(self.db, keya, inca, keyb, incb, max_)
     if not tclist_objs:
         raise tc.TCException(tc.bdb_errmsg(tc.bdb_ecode(self.db)))
     return util.deserialize_tclist(tclist_objs, str)