Variable-length bytecode algorithm

Source: Internet
Author: User
: This article mainly introduces the variable length bytecode algorithm. if you are interested in the PHP Tutorial, you can refer to it. I recently read the book large-scale WEB service development technology. The book mentions the "variable length bytecode algorithm" to compress data and reduce disk I/O.
Variable length bytecode algorithm:
The maximum bit (subscript 7) of any byte is used only as the flag, and is multiplied by the corresponding power of 128 according to the location of the byte;

This is his pseudocode.

After careful research, I translated it into a PHP version:


  Int (133) [1] => string (1) "1" [2] => int (130) [3] => string (1) "2" [4] => int (160)} array (3) {[0] => int (5) [1] => int (130) [2] => int (288)} // write binary $ h = fopen('ejz3.txt ', 'wb'); foreach ($ a as $ k => $ v) {$ str3 = pack ('H * ', sprintf ("% 02x", $ v); fwrite ($ H, $ str3);} fclose ($ h ); // read binary $ str2 = file_get_contents('ejz3.txt '); $ str2 = unpack ("H *", $ str2); $ value = str_split ($ str2 [1], 2 ); foreach ($ value as $ k =>$ v) {$ value [$ k] = base_convert ($ v, 16, 10 );}

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces the variable-length bytecode algorithm, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.