def encode_query_key(self, txid, namespace, ancestor_path): if not isinstance(ancestor_path, tuple): ancestor_path = Path.flatten(ancestor_path) section_prefix = self._txid_prefix(txid) + self.QUERIES encoded_ancestor = Text.encode(namespace) + Path.pack(ancestor_path[:2]) return section_prefix + encoded_ancestor
def encode_key(self, group_path): """ Encodes a key for a given entity group. Args: group_path: A tuple containing path elements. Returns: A byte string containing the relevant FDB key. """ return b''.join([ self.directory.rawPrefix, hash_tuple(group_path), Text.encode(group_path[0]) + Path.encode_id_or_name(group_path[1])])
def _encode_keys(self, keys): return b''.join( [Text.encode(decode_str(key.name_space())) + Path.pack(key.path()) for key in keys])