def __update_count(self): """Update the bookkeeping structure at the head of the file with the total count of reusable IDs Parameters ---------- None Returns ------- None""" self.db_map.seek(0) bin_str = structs.pack_garbage(self.__count) self.db_map.write(bin_str)
def append(self, _id): """Append an object ID to be "garbage collected" to this GarbageFile. Once appended, the ID will be available for reuse by the ObjectFile that this GarbageFile is associated with. Parameters ---------- _id: the integer ID to append to this GarbageFile Returns ------- None""" self._ids.insert(0, _id) self.db_map.seek((structs._SIZEOF_GARBAGE * self.__count) + structs._SIZEOF_GARBAGE) bin_str = structs.pack_garbage(_id) self.db_map.write(bin_str) self.__count += 1 self.__update_count()