node_erlastic icon indicating copy to clipboard operation
node_erlastic copied to clipboard

Compressed binary support

Open harshagarwal00 opened this issue 3 years ago • 2 comments

Getting error: Unexpected BERT type: 80

when trying to decode. I am using: Compressed Term Format

The first byte after 131 is "80"

Screenshot 2022-07-20 at 11 43 28 AM

harshagarwal00 avatar Jul 20 '22 06:07 harshagarwal00

Fix was very non-intutive:

const { unzip } = require('node:zlib');
const { promisify } = require('node:util');
const do_unzip = promisify(unzip);

//remove the first 6 bytes and inflate using zlib
const inflated = await do_unzip(buffer.subarray(6));
//we are skipping check for 131 in decode function rest of logic in decode function is the same
var Obj = Bert.decode_inner(inflated);
  if (Obj.rest.length !== 0) {
            throw ("Invalid BERT.");
  }
 return Obj.value;

harshagarwal00 avatar Jul 21 '22 11:07 harshagarwal00

Hi, thanks for the inputs, I don't have the time to look further into it yet, but I'll come back to it as soon as possible.

Shakadak avatar Jul 25 '22 14:07 Shakadak