1 / 30

Compression of documents

Compression of documents. Paolo Ferragina Dipartimento di Informatica Università di Pisa. Raw docs are needed. LZ77. Algorithm ’ s step: Output <dist, len, next-char> Advance by len + 1 A buffer “ window ” has fixed length and moves. a. a. c. a. a. c. a. b. c. a. a. a. a.

drockwood
Download Presentation

Compression of documents

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Compression of documents Paolo Ferragina Dipartimento di Informatica Università di Pisa

  2. Raw docs are needed

  3. LZ77 Algorithm’s step: • Output <dist, len, next-char> • Advance by len + 1 A buffer “window” has fixed length and moves a a c a a c a b c a a a a a a a c <6,3,a> Dictionary(all substrings starting here) a c a a c a a c a b c a a a a a a c <3,4,c>

  4. (3,3,a) a a a a c c a a a a c c a a b b c c a a b b a a a a a a c c (0,0,a) a c a a c a b c a b a a a c a (1,1,c) a a a a c c a a a a c c a a b b c c a a b b a a a a a a c c (3,4,b) a a a a c c a a a a c c a a b b c c a a b b a a a a a a c c (1,2,c) a a a a c c a a a a c c a a b b c c a a b b a a a a a a c c within W Example: LZ77 with window Window size = 6 Longest match Next character Gzip -1…-9

  5. Which is faster in decompression among gzip -1…-9 ? LZ77 Decoding Decoder keeps same dictionary window as encoder. • Finds substring <len,dist,char> in previously decoded text • Inserts a copy of it What if len > dist ? (overlap with text to be compressed) • E.g. seen = abcd, next codeword is <2,9,e> for (i = 0; i < len; i++) out[cursor+i] = out[cursor-d+i] • Output is correct: abcdcdcdcdcdce

  6. You find this at: www.gzip.org/zlib/

  7. Transfer + Decompression

  8. https://quixdb.github.io/squash-benchmark/

  9. Compression & Networking

  10. Background data knowledge about data at receiver sender receiver • network links are getting faster and faster but • many clients still connected by fairly slow links (mobile?) • people wish to send more and more data • battery life is a king problem how can we make this transparent to the user?

  11. Two standard techniques • caching: “avoid sending the same object again” • Done on the basis of “atomic” objects • Thus only works if objects are unchanged • How about objects that are slightly changed? • compression: “remove redundancy in transmitted data” • avoid repeated substrings in transmitted data • can be extended to history of past transmissions (overhead) • How if the sender has never seen data at receiver ?

  12. Types of Techniques • Common knowledge between sender & receiver • Unstructured file: delta compression • “partial” knowledge • Unstructured files: file synchronization • Record-based data: set reconciliation

  13. Formalization • Delta compression[diff, zdelta, REBL,…] • Compress file f deploying known file f’ • Compress a group of files • Speed-up web access by sending differences between the requested page and the ones available in cache • File synchronization [rsynch, zsync] • Client updates its old file fold with fnewavailable on a server • Mirroring, Shared Crawling, Content Distr. Net • Set reconciliation • Client updates its structured file fold with file fnewavailable on server • Update of contacts or appointments, intersect IL in P2P search engine

  14. Z-delta compression (one-to-one) Problem: We have two files fknown and fnew (known to both parties) and the goal is to compute a file fd of minimum size such that fnew can be derived from fknown and fd • Assume that block moves and copies are allowed • Find an optimal covering set of fnew based on fknown • LZ77-scheme provides and efficient, optimal solution • fknown is “previously encoded text”, compress fknownfnew starting from fnew • zdeltais one of the best implementations • Uses e.g. in Version control, Backups, and Transmission.

  15. Efficient Web Access Dual proxy architecture: pair of proxies (client cache + proxy) located on each side of the slow link use a proprietary protocol to increase comm perf • Use zdelta to reduce traffic: • Old version is available at both proxies (one on client cache, and one on proxy) • Restricted to pages already visited (30% cache hits), or URL-prefix match web request request Client Proxy Slow-link Fast-link Cache reference reference Delta-encoding Page Small cache

  16. 2000 620 2 1 20 220 20 5 123 3 Cluster-based delta compression Problem: We wish to compress a group of files F • Useful on a dynamic collection of web pages, back-ups, … • Apply pairwisezdelta: find a good reference for each f  F • Reduction to the Min Branching problem on DAGs • Build a (complete?) weighted graph GF, nodes=files, weights= zdelta-size • Insert a dummy node connected to all, and weights are gzip-coding • Compute the directed spanning tree of min tot cost, covering G’s nodes. 90

  17. Improvement (group of files) Problem: Constructing G is very costly, n2 edge calculations (zdelta exec) • We wish to exploit some pruning approach • Collection analysis: Cluster the files that appear similar and thus good candidates for zdelta-compression. Build a sparse weighted graph G’F containing only edges between pairs of files in the same cluster • Assign weights: Estimate appropriate edge weights for G’F thus saving zdelta execution. Nonetheless, strict n2 time

  18. File Synchronization

  19. File synch: The problem client request to update an old file server has new file but does not know the old file updates f_old without sending the entire f_new rsync: file synch tool, distributed with Linux request f_new f_old update Server Client Delta compression is a sort of local synch Since the server knows both files

  20. The rsync algorithm few hashes f_new f_old encoded file Server Client

  21. The rsync algorithm (contd) • simple, widely used, single roundtrip • optimizations: 4-byte rolling hash + 2-byte MD5, gzipfor literals • choice of block size problematic (default: max{700, √n} bytes) • not good in theory: granularity of changes may disrupt use of blocks

  22. A new framework: zsync Server sends hashes (unlike the client in rsync), clients checks them Server deploys the common fref to compress the new ftar (rsync compress just it).

  23. Small differences (e.g. agenda) If d differences, then on each level  d hashes not match, and need to continue Communication complexity is O(d lg(n/k) * lg n) bits [1 upward path per different k-block] Server sends hashes to client per levels Client checks equality with hash-substrings Log n/k levels match n/k blocks of k elems each

More Related