compression

Does zgrep unzip a file before searching? [closed]

此生再无相见时 提交于 2021-02-19 09:40:06
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Improve this question Does zgrep unzip a gzip file and make a temporary copy before searching or does it search directly on the compressed file? 回答1: This source of zgrep uncompresses the file with zcat and pipes the result to grep . So, no, it does not use a temporary file, but yes,

LZ4 compressed text is larger than uncompressed

假如想象 提交于 2021-02-16 20:11:09
问题 I have read that lz4 algorithm is very fast and has pretty good compression. But in my test app compressed text is larger than the source text. What is the problem? srand(time(NULL)); std::string text; for (int i = 0; i < 65535; ++i) text.push_back((char)(0 + rand() % 256)); cout << "Text size: " << text.size() << endl; char *compressedData = new char[text.size() * 2]; int compressedSize = LZ4_compress(text.c_str(), text.size(), compressedData); cout << "Compressed size: " << compressedSize <

LZ4 compressed text is larger than uncompressed

亡梦爱人 提交于 2021-02-16 20:10:25
问题 I have read that lz4 algorithm is very fast and has pretty good compression. But in my test app compressed text is larger than the source text. What is the problem? srand(time(NULL)); std::string text; for (int i = 0; i < 65535; ++i) text.push_back((char)(0 + rand() % 256)); cout << "Text size: " << text.size() << endl; char *compressedData = new char[text.size() * 2]; int compressedSize = LZ4_compress(text.c_str(), text.size(), compressedData); cout << "Compressed size: " << compressedSize <

Speed up reading in a compressed bz2 file ('rb' mode)

若如初见. 提交于 2021-02-11 14:21:37
问题 I have a BZ2 file of more than 10GB. I'd like to read it without decompressing it into a temporary file (it would be more than 50GB). With this method: import bz2, time t0 = time.time() time.sleep(0.001) # to avoid / by 0 with bz2.open("F:\test.bz2", 'rb') as f: for i, l in enumerate(f): if i % 100000 == 0: print('%i lines/sec' % (i/(time.time() - t0))) I can only read ~ 250k lines per second. On a similar file, first decompressed , I get ~ 3M lines per second, i.e. a x10 factor: with open("F

How to decompress text in Python that has been compressed with gzip?

安稳与你 提交于 2021-02-10 23:18:23
问题 How can you decompress a string of text in Python 3, that has been compressed with gzip and converted to base 64? For example, the text: EgAAAB+LCAAAAAAABAALycgsVgCi4vzcVAWFktSKEgC9n1/fEgAAAA== Should convert to: This is some text The following C# code successfully does this: var gzBuffer = Convert.FromBase64String(compressedText); using (var ms = new MemoryStream()) { int msgLength = BitConverter.ToInt32(gzBuffer, 0); ms.Write(gzBuffer, 4, gzBuffer.Length - 4); var buffer = new byte

ZSTD String compression using luben

我与影子孤独终老i 提交于 2021-02-10 14:14:58
问题 I have been struggling to compress a regular string to ZSTD format using the Luben library (v1.4.0-1). I do the following: byte[] zstdBytes = Zstd.compress(payload.getBytes(StandardCharsets.UTF_8)); ZstdInputStream zstdInputStream= new ZstdInputStream(new ByteArrayInputStream(zstdBytes)); However while reading the zstdInputStream I get the following error: java.io.IOException: Decompression error: Unknown frame descriptor at com.github.luben.zstd.ZstdInputStream.readInternal(ZstdInputStream

PHP Compress array of bits into shortest string possible

ぐ巨炮叔叔 提交于 2021-02-10 05:44:26
问题 I have an array that contains values of 1 or 0 representing true or false values. e.g. array(1,0,0,1,0,1,1,1,1); I want to compress/encode this array into the shortest string possible so that it can be stored within a space constrained place such as a cookie. It also need to be able to be decoded again later. How do I go about this? ps. I am working in PHP 回答1: Here is my proposal: $a = array(1,0,0,1,0,1,1,1,1,1,0,0,1,0,1,1,1,1,1,0,0,1,0,1,1,1,1); $compressed = base64_encode(implode('', array

How to reduce video size with java/kotlin on Android?

浪子不回头ぞ 提交于 2021-02-08 17:00:56
问题 I want reduce the video size at Android Studio and for upload to PlayStore needs to be compatible for 64 bits arquitecture, I tried before with ffmpeg and it compress mp4 succefully but take longer time and this solution with 3gp not include the audio. Theres another option or library to compress mp4 and 3gp with audio and video? 回答1: Here is another library to compress videos. This library can compress videos in low, medium and high quality. Usage example: VideoCompress.compressVideoMedium("

How to reduce video size with java/kotlin on Android?

回眸只為那壹抹淺笑 提交于 2021-02-08 17:00:21
问题 I want reduce the video size at Android Studio and for upload to PlayStore needs to be compatible for 64 bits arquitecture, I tried before with ffmpeg and it compress mp4 succefully but take longer time and this solution with 3gp not include the audio. Theres another option or library to compress mp4 and 3gp with audio and video? 回答1: Here is another library to compress videos. This library can compress videos in low, medium and high quality. Usage example: VideoCompress.compressVideoMedium("

How to compress a file with bzip2 in Python?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 15:25:18
问题 Here is what I have: import bz2 compressionLevel = 9 source_file = '/foo/bar.txt' #this file can be in a different format, like .csv or others... destination_file = '/foo/bar.bz2' tarbz2contents = bz2.compress(source_file, compressionLevel) fh = open(destination_file, "wb") fh.write(tarbz2contents) fh.close() I know first param of bz2.compress is a data, but it's the simple way that I found to clarify what I need. And I know about BZ2File but, I cannot find any good example to use BZ2File.