随机访问gzip流 [英] Random access gzip stream

查看:133
本文介绍了随机访问gzip流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要能够随机访问gzip压缩文件。
我可以对它进行一些预处理(比如,构建某种索引),前提是预处理的结果比文件本身小得多。

I'd like to be able to do random access into a gzipped file. I can afford to do some preprocessing on it (say, build some kind of index), provided that the result of the preprocessing is much smaller than the file itself.

任何建议?

我的想法是:


  • 现有的gzip实现和序列化其解压缩器状态,例如1兆字节的压缩数据。然后做随机访问,反序列化解压缩器状态并从兆字节边界读取。这看起来很难,特别是因为我使用Java,我找不到一个纯java的gzip实现:(

  • 重新压缩大小为1Mb的文件,

  • 编写gzip格式的简单解析器,它不进行任何解压缩,只检测和索引块边界(如果有的话)是任何块:我尚未阅读gzip格式说明)

推荐答案

请查看此链接(C代码示例)。

Have a look at this link (C code example).

/* zran.c -- example of zlib/gzip stream indexing and random access
...

Gzip只是带有信封的zlib。

Gzip is just zlib with an envelope.

这篇关于随机访问gzip流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆