Skip to content
Prev Previous commit
Next Next commit
remove from bytearray
  • Loading branch information
Mark Costello committed Mar 22, 2013
commit 5ceb3955a011239f0ef874241e309a66656a8e95
13 changes: 9 additions & 4 deletions rdbtools/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
except ImportError:
from io import StringIO

import array

REDIS_RDB_6BITLEN = 0
REDIS_RDB_14BITLEN = 1
REDIS_RDB_32BITLEN = 2
Expand Down Expand Up @@ -576,7 +578,9 @@ def read_ziplist_entry(self, f) :

def read_zipmap(self, f) :
raw_string = self.read_string(f)
buff = io.BytesIO(bytearray(raw_string))
# raw_byte_arr = bytearray(raw_string)
raw_byte_arr = array.array('B', raw_string)
buff = io.BytesIO(raw_byte_arr.tostring())
num_entries = read_unsigned_char(buff)
self._callback.start_hash(self._key, num_entries, self._expiry, info={'encoding':'zipmap', 'sizeof_value':len(raw_string)})
while True :
Expand Down Expand Up @@ -658,10 +662,10 @@ def get_logical_type(self, data_type):
return DATA_TYPE_MAPPING[data_type]

def lzf_decompress(self, compressed, expected_length):
in_stream = bytearray(compressed)
in_stream = array.array('B', compressed)
in_len = len(in_stream)
in_index = 0
out_stream = bytearray()
out_stream = array.array('B')
out_index = 0

while in_index < in_len :
Expand Down Expand Up @@ -689,7 +693,8 @@ def lzf_decompress(self, compressed, expected_length):
out_index = out_index + 1
if len(out_stream) != expected_length :
raise Exception('lzf_decompress', 'Expected lengths do not match %d != %d for key %s' % (len(out_stream), expected_length, self._key))
return str(out_stream)
# return str(out_stream)
return out_stream.tostring()

def skip(f, free):
if free :
Expand Down