एक ही सामग्री के साथ एकाधिक फ़ाइलों से बेहतर एकल फ़ाइलों को संपीड़ित करने के लिए ज़िप सक्षम क्यों है?

विषयसूची:

एक ही सामग्री के साथ एकाधिक फ़ाइलों से बेहतर एकल फ़ाइलों को संपीड़ित करने के लिए ज़िप सक्षम क्यों है?
एक ही सामग्री के साथ एकाधिक फ़ाइलों से बेहतर एकल फ़ाइलों को संपीड़ित करने के लिए ज़िप सक्षम क्यों है?

वीडियो: एक ही सामग्री के साथ एकाधिक फ़ाइलों से बेहतर एकल फ़ाइलों को संपीड़ित करने के लिए ज़िप सक्षम क्यों है?

वीडियो: एक ही सामग्री के साथ एकाधिक फ़ाइलों से बेहतर एकल फ़ाइलों को संपीड़ित करने के लिए ज़िप सक्षम क्यों है?
वीडियो: How To Delete Downloaded Music On Your Apple Watch Series 7 - YouTube 2024, अप्रैल
Anonim
हमारी फाइलों को संपीड़ित करने में सक्षम होने के कारण यह साझा करना आसान है और / या उन्हें परिवहन करना हमारे इलेक्ट्रॉनिक जीवन को अधिक आसान बना सकता है, लेकिन कभी-कभी हम उन्हें संपीड़ित करने के बाद अजीब या अप्रत्याशित आकार के परिणाम देख सकते हैं। ऐसा क्यों है? आज के सुपर यूज़र क्यू एंड ए पोस्ट में एक भ्रमित पाठक के सवालों के जवाब हैं।
हमारी फाइलों को संपीड़ित करने में सक्षम होने के कारण यह साझा करना आसान है और / या उन्हें परिवहन करना हमारे इलेक्ट्रॉनिक जीवन को अधिक आसान बना सकता है, लेकिन कभी-कभी हम उन्हें संपीड़ित करने के बाद अजीब या अप्रत्याशित आकार के परिणाम देख सकते हैं। ऐसा क्यों है? आज के सुपर यूज़र क्यू एंड ए पोस्ट में एक भ्रमित पाठक के सवालों के जवाब हैं।

आज का प्रश्न और उत्तर सत्र हमारे पास सुपरयूसर की सौजन्य है - स्टैक एक्सचेंज का एक उपविभाग, क्यू एंड ए वेब साइट्स का एक समुदाय संचालित समूह।

जीन-एटियेन मिन्ह-डुय पोइरियर (फ़्लिकर) की फोटो सौजन्य।

प्रश्न

सुपर यूज़र रीडर sixtyfootersdude जानना चाहता है कि ज़िप एक ही प्रकार की सामग्री के साथ एकाधिक फ़ाइलों की तुलना में एकल फ़ाइलों को बेहतर तरीके से संपीड़ित करने में सक्षम क्यों है:

Suppose that I have 10,000 XML files and want to send them to a friend. Before sending them, I would like to compress them.

Method 1: Do Not Compress Them

Results:

Image
Image

Method 2: Zip Every File Separately and Send Him 10,000 Zipped XML Files

Command:

Results:
Results:
Image
Image

Method 3: Create a Single Zip File Containing All 10,000 XML Files

Command:

Results:
Results:
Image
Image

Method 4: Concatenate the Files Into a Single File and Zip It

Command:

Results:
Results:
Image
Image

Questions

  • Why do I get such dramatically better results when I am just zipping a single file?
  • I was expecting to get drastically better results using method 3 rather than method 2, but I do not. Why is this?
  • Is this behaviour specific to zip? If I tried using Gzip, would I get different results?

Additional Info

Image
Image

Meta Data

One of the answers given suggests that the difference is the system meta data that is stored in the zip file. I do not believe that this can be the case. To test it, I did the following:

The resulting zip file is 1.4 MB. This means that there is still approximately ten MB of unexplained space.
The resulting zip file is 1.4 MB. This means that there is still approximately ten MB of unexplained space.

ज़िप एक ही प्रकार की सामग्री के साथ एकाधिक फ़ाइलों की तुलना में एकल फ़ाइलों को बेहतर बनाने में सक्षम क्यों है?

उत्तर

सुपरयूसर योगदानकर्ता एलन शुतको और आंगजू के पास हमारे लिए जवाब है। सबसे पहले, एलन Shutko:

Zip compression is based on repetitive patterns in the data to be compressed, and the compression gets better the longer the file is, as more and longer patterns can be found and used.

Simplified, if you compress one file, the dictionary that maps (short) codes to (longer) patterns is necessarily contained in each resulting zip file; if you zip one long file, the dictionary is ‘reused’ and grows even more effective across all content.

If your files are even a bit similar (as text always is), reuse of the ‘dictionary’ becomes very efficient and the result is a much smaller total zip file.

आंगनजू से जवाब का पालन किया:

In zip, each file is compressed separately. The opposite is solid compression, that is, files are compressed together. 7-zip and Rar use solid compression by default. Gzip and Bzip2 cannot compress multiple files, so Tar is used first, having the same effect as solid compression.

As xml files have similar structure (and probably similar content), if the files are compressed together then the compression will be higher.

For example, if a file contains the string “” and the compressor has already found that string in another file, it will replace it with a small pointer to the previous match. If the compressor does not use solid compression, the first occurrence of the string in the file will be recorded as a literal, which is larger.

स्पष्टीकरण में जोड़ने के लिए कुछ है? टिप्पणियों में विचार व्यक्त करो। अन्य तकनीक-समझदार स्टैक एक्सचेंज उपयोगकर्ताओं से अधिक उत्तरों पढ़ना चाहते हैं? यहां पूर्ण चर्चा धागा देखें।

सिफारिश की: