def lz4_encode_old_kafka(payload):
 data = lz4_encode(payload)
 header_size = 7
 if isinstance(data[4], int):
  flg = data[4]
 else:
  flg = ord(data[4])
 content_size_bit = ((flg >> 3) & 1)
 if content_size_bit:
  header_size += 8
 hc = xxhash.xxh32(data[0:(header_size - 1)]).digest()[(-2):(-1)]
 return ''.join([data[0:(header_size - 1)], hc, data[header_size:]])

def lz4_encode_old_kafka ( payload ) : data = lz4_encode ( payload ) header_size = 7 if isinstance ( data [ 4 ] , int ) : flg = data [ 4 ] else : flg = ord ( data [ 4 ] ) content_size_bit = ( ( flg >> 3 ) & 1 ) if content_size_bit : header_size += 8 hc = xxhash . xxh32 ( data [ 0 : ( header_size - 1 ) ] ) . digest ( ) [ ( - 2 ) : ( - 1 ) ] return '' . join ( [ data [ 0 : ( header_size - 1 ) ] , hc , data [ header_size : ] ] )
encode payload for 0 .