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)
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)
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
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)
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)
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)
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
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)
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)
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)
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
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)