def _seek(self, index, offsets=None): data_stream = self._data_stream data_base = self._data_base if offsets is None: offset = self.offsetof(index) else: offset = offsets[sequence_index(index, len(offsets))] data_stream.seek(data_base + offset)
def extract_chunk(self, index): chunk_count = self._chunk_count data_stream = self._data_stream huffman_nodes = self._huffman_nodes index = sequence_index(index, chunk_count) chunk = b'' chunk_size = self.sizeof(index) if chunk_size: self._seek(index) compressed_size, expanded_size = self._read_sizes(index) chunk = stream_read(data_stream, compressed_size) chunk = huffman_expand(chunk, expanded_size, huffman_nodes) return chunk
def extract_chunk(self, index): self._log_extract_chunk(index) chunk_count = self._chunk_count data_stream = self._data_stream huffman_nodes = self._huffman_nodes index = sequence_index(index, chunk_count) chunk = b'' chunk_size = self.sizeof(index) if chunk_size: self._seek(index) compressed_size, expanded_size = self._read_sizes(index) chunk = stream_read(data_stream, compressed_size) chunk = huffman_expand(chunk, expanded_size, huffman_nodes) return chunk
def sizeof(self, index): chunk_offsets = self._chunk_offsets index = sequence_index(index, len(self)) return chunk_offsets[index + 1] - chunk_offsets[index]
def offsetof(self, index): return self._chunk_offsets[sequence_index(index, len(self))]
def sizeof(self, index): chunk_offsets = self._chunk_offsets index = sequence_index(index, self._chunk_count) return chunk_offsets[index + 1] - chunk_offsets[index]
def offsetof(self, index): return self._chunk_offsets[sequence_index(index, self._chunk_count)]