def truncate(self, txn, rebuild_indexes=True):
key_from = struct.pack('<STR_LIT>', self._slot)<EOL>key_to = struct.pack('<STR_LIT>', self._slot + <NUM_LIT:1>)<EOL>cursor = txn._txn.cursor()<EOL>cnt = <NUM_LIT:0><EOL>if cursor.set_range(key_from):<EOL><INDENT>key = cursor.key()<EOL>while key < key_to:<EOL><INDENT>if not cursor.delete(dupdata=True):<EOL><INDENT>break<EOL><DEDENT>cnt += <NUM_LIT:1><EOL>if txn._stats:<EOL><INDENT>txn._stats.dels += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>if rebuild_indexes:<EOL><INDENT>deleted, _ = self.rebuild_indexes(txn)<EOL>cnt += deleted<EOL><DEDENT>return cnt<EOL>
:param txn:
:param rebuild_indexes:
:return: