You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
Motivation: I am trying to use snappy and snappy-stream along each other they write different output because of the framed format, I would assume snappy library should handle the framed format case ideally? At minimum would make sense to detect it and raise a more developer friendly error message than "Invalid input"?
constfs=require('fs')constsnappy=require('snappy')constsnappyStream=require('snappy-stream')// ==================================// SNAPPY// ------------------------------constinData=fs.readFileSync('data.txt')constsnappyCompressData=snappy.compressSync(inData)console.log('snappy.compressSync DATA',snappyCompressData)// ==================================// SNAPPY-STREAM// ------------------------------constsnappyCompressStream=snappyStream.createCompressStream()constinStream=fs.createReadStream('./data.txt')constoutStream=fs.createWriteStream('./compressed.sz')// NOTE: "snappy" and "snappy framed" are not identical: https://github.com/google/snappy/blob/master/framing_format.txtinStream.pipe(snappyCompressStream).on('data',(chunk)=>{this.buffers=this.buffers||[]this.buffers.push(chunk)}).on('end',()=>{constdata=Buffer.concat(this.buffers)console.log('snappyCompressStream DATA',data,snappy.uncompressSync(data))// console.log('snappyCompressStream DATA', data)}).pipe(outStream)
Output:
➜ node-snappy-stream-test node compress.js
snappy.compressSync DATA <Buffer 13 48 7b 0a 20 20 20 20 22 66 6f 6f 22 3a 20 62 61 72 0a 7d 0a>
/home/jonas/Desktop/node-snappy-stream-test/node_modules/snappy/snappy.js:49
return binding.uncompressSync(compressed, uncompressOpts(opts));
^
Error: Invalid input
at Object.exports.uncompressSync (/home/jonas/Desktop/node-snappy-stream-test/node_modules/snappy/snappy.js:49:18)
at CompressStream.<anonymous> (/home/jonas/Desktop/node-snappy-stream-test/compress.js:36:63)
at CompressStream.emit (events.js:208:15)
at endReadableNT (_stream_readable.js:1154:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
The text was updated successfully, but these errors were encountered:
grimen
changed the title
Bug: Don't support reading "snappy framed" format
Don't support reading "snappy framed" format - bug or feature?
Jul 15, 2019
Well, the Google do point out that it is not part of core specification but rather an optional - but yea, would be neat if it was handled. Not sure otherwise how to ensure data integrity. 🤔
Motivation: I am trying to use
snappy
andsnappy-stream
along each other they write different output because of the framed format, I would assumesnappy
library should handle the framed format case ideally? At minimum would make sense to detect it and raise a more developer friendly error message than "Invalid input"?Output:
The text was updated successfully, but these errors were encountered: