def enumerate(self): index, res = 0, self.header() while bitmap.size(res) > 1: # check to see if the msize moves us to a header bit that's unset if bitmap.int(bitmap.get(res, 0, 1)) == 0: fixup = bitmap.runlength(res, 0, 0) logging.warn('Index {:d} of header is not set. Possibly corrupt? Forced to consume {:d} bits.'.format(index, fixup)) res, _ = bitmap.consume(res, fixup) if bitmap.size(res) == 0: break # search for how long this run is msize = bitmap.runlength(res, 0, 1) + 1 yield index, msize # consume msize bits index += msize res, _ = bitmap.consume(res, msize) return
def used(self): m, res = self.getparent(magazine_t), self.header() index = m['mag_bytes_free_at_start'].int() / self.QUANTUM sentinel = (m['num_bytes_in_magazine'].int() - m['mag_bytes_free_at_end'].int()) / self.QUANTUM while index <= sentinel: # check to see if the msize moves us to a header bit that's unset if bitmap.int(bitmap.get(res, 0, 1)) == 0: fixup = bitmap.runlength(res, 0, 0) logging.warn('Index {:d} of header is not set. Possibly corrupt? Forced to consume {:d} bits.'.format(index, fixup)) res, _ = bitmap.consume(res, fixup) if bitmap.size(res) == 0: break # search for how long this run is msize = bitmap.runlength(res, 0, 1) + 1 yield index, msize # consume msize bits index += msize res, _ = bitmap.consume(res, msize) return
def enumerate(self): index, res = 0, self.header() while bitmap.size(res) > 1: # check to see if the msize moves us to a header bit that's unset if bitmap.int(bitmap.get(res, 0, 1)) == 0: fixup = bitmap.runlength(res, 0, 0) logging.warn( 'Index {:d} of header is not set. Possibly corrupt? Forced to consume {:d} bits.' .format(index, fixup)) res, _ = bitmap.consume(res, fixup) if bitmap.size(res) == 0: break # search for how long this run is msize = bitmap.runlength(res, 0, 1) + 1 yield index, msize # consume msize bits index += msize res, _ = bitmap.consume(res, msize) return
def used(self): m, res = self.getparent(magazine_t), self.header() index = m['mag_bytes_free_at_start'].int() / self.QUANTUM sentinel = (m['num_bytes_in_magazine'].int() - m['mag_bytes_free_at_end'].int()) / self.QUANTUM while index <= sentinel: # check to see if the msize moves us to a header bit that's unset if bitmap.int(bitmap.get(res, 0, 1)) == 0: fixup = bitmap.runlength(res, 0, 0) logging.warn( 'Index {:d} of header is not set. Possibly corrupt? Forced to consume {:d} bits.' .format(index, fixup)) res, _ = bitmap.consume(res, fixup) if bitmap.size(res) == 0: break # search for how long this run is msize = bitmap.runlength(res, 0, 1) + 1 yield index, msize # consume msize bits index += msize res, _ = bitmap.consume(res, msize) return
def msizeQ(self, index): index = self.__check_header(index) res = self.header() return bitmap.runlength(res, 0, index+1) + 1
def msizeQ(self, index): index = self.__check_header(index) res = self.header() return bitmap.runlength(res, 0, index + 1) + 1