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
The wiki for BlockDecoder (link) has an example for using snappy. It uses Buffer#slice, which is deprecated. It also mixes up async (callback-based) and sync (throwing an Error) error handling. I propose to update the example in the wiki to
constcrc32=require('buffer-crc32');constsnappy=require('snappy');constblockDecoder=newavro.streams.BlockDecoder({codecs: {null: (buf,cb)=>cb(null,buf),snappy: async(buf,cb)=>{// Avro appends checksums to compressed blocks.constlen=buf.lengthconstchecksum=buf.subarray(len-4,len)try{constinflated=awaitsnappy.uncompress(buf.subarray(0,len-4))if(!checksum.equals(crc32(inflated))){// We make sure that the checksum matches.thrownewError('invalid checksum')}cb(null,inflated)}catch(err){cb(err)}},},})
BlockEncoder
The wiki for BlockEncoder (link) relies on the old snappy sync behaviour. snappy.compress is now an async call (snappy 7.x.x). I propose to update the example to
(Note that both examples also include the null codec, which is technically not needed for the example, but helps as an extra example on how to implement codecs)
The text was updated successfully, but these errors were encountered:
BlockDecoder
The wiki for
BlockDecoder
(link) has an example for usingsnappy
. It usesBuffer#slice
, which is deprecated. It also mixes up async (callback-based) and sync (throwing anError
) error handling. I propose to update the example in the wiki toBlockEncoder
The wiki for
BlockEncoder
(link) relies on the oldsnappy
sync behaviour.snappy.compress
is now an async call (snappy
7.x.x). I propose to update the example to(Note that both examples also include the
null
codec, which is technically not needed for the example, but helps as an extra example on how to implement codecs)The text was updated successfully, but these errors were encountered: