Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 840873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:41:56+00:00 2026-05-15T05:41:56+00:00

I noticed that in Jeff’s slides Challenges in Building Large-Scale Information Retrieval Systems, which

  • 0

I noticed that in Jeff’s slides “Challenges in Building Large-Scale Information Retrieval Systems”, which can also be downloaded here: http://research.google.com/people/jeff/WSDM09-keynote.pdf, a method of integers compression called “group varint encoding” was mentioned. It was said much faster than 7 bits per byte integer encoding (2X more). I am very interested in this and looking for an implementation of this, or any more details that could help me implement this by myself.

I am not a pro and new to this, and any help is welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:41:57+00:00Added an answer on May 15, 2026 at 5:41 am

    That’s referring to “variable integer encoding”, where the number of bits used to store an integer when serialized is not fixed at 4 bytes. There is a good description of varint in the protocol buffer documentation.

    It is used in encoding Google’s protocol buffers, and you can browse the protocol buffer source code.

    The CodedOutputStream contains the exact encoding function WriteVarint32FallbackToArrayInline:

    inline uint8* CodedOutputStream::WriteVarint32FallbackToArrayInline(
        uint32 value, uint8* target) {
      target[0] = static_cast<uint8>(value | 0x80);
      if (value >= (1 << 7)) {
        target[1] = static_cast<uint8>((value >>  7) | 0x80);
        if (value >= (1 << 14)) {
          target[2] = static_cast<uint8>((value >> 14) | 0x80);
          if (value >= (1 << 21)) {
            target[3] = static_cast<uint8>((value >> 21) | 0x80);
            if (value >= (1 << 28)) {
              target[4] = static_cast<uint8>(value >> 28);
              return target + 5;
            } else {
              target[3] &= 0x7F;
              return target + 4;
            }
          } else {
            target[2] &= 0x7F;
            return target + 3;
          }
        } else {
          target[1] &= 0x7F;
          return target + 2;
        }
      } else {
        target[0] &= 0x7F;
        return target + 1;
      }
    }
    

    The cascading ifs will only add additional bytes onto the end of the target array if the magnitude of value warrants those extra bytes. The 0x80 masks the byte being written, and the value is shifted down. From what I can tell, the 0x7f mask causes it to signify the “last byte of encoding”. (When OR’ing 0x80, the highest bit will always be 1, then the last byte clears the highest bit (by AND’ing 0x7f). So, when reading varints you read until you get a byte with a zero in the highest bit.

    I just realized you asked about “Group VarInt encoding” specifically. Sorry, that code was about basic VarInt encoding (still faster than 7-bit). The basic idea looks to be similar. Unfortunately, it’s not what’s being used to store 64bit numbers in protocol buffers. I wouldn’t be surprised if that code was open sourced somewhere though.

    Using the ideas from varint and the diagrams of “Group varint” from the slides, it shouldn’t be too too hard to cook up your own 🙂

    Here is another page describing Group VarInt compression, which contains decoding code. Unfortunately they allude to publicly available implementations, but they don’t provide references.

    void DecodeGroupVarInt(const byte* compressed, int size, uint32_t* uncompressed) {
      const uint32_t MASK[4] = { 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF };
      const byte* limit = compressed + size;
      uint32_t current_value = 0;
      while (compressed != limit) {
        const uint32_t selector = *compressed++;
        const uint32_t selector1 = (selector & 3);
        current_value += *((uint32_t*)(compressed)) & MASK[selector1];
        *uncompressed++ = current_value;
        compressed += selector1 + 1;
        const uint32_t selector2 = ((selector >> 2) & 3);
        current_value += *((uint32_t*)(compressed)) & MASK[selector2];
        *uncompressed++ = current_value;
        compressed += selector2 + 1;
        const uint32_t selector3 = ((selector >> 4) & 3);
        current_value += *((uint32_t*)(compressed)) & MASK[selector3];
        *uncompressed++ = current_value;
        compressed += selector3 + 1;
        const uint32_t selector4 = (selector >> 6);
        current_value += *((uint32_t*)(compressed)) & MASK[selector4];
        *uncompressed++ = current_value;
        compressed += selector4 + 1;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that you can call Queue.Synchronize to get a thread-safe queue object, but
I noticed that I can start a program with it's associated handler by writing
I noticed that I had a project named RemoteSystemTempFiles which I never have created.
I noticed that I can extend a class and at the same time pass
I noticed that I can place subview outside of superview's bound (either partly or
I've noticed that you can reference a function with or without the parentheses. Why?,
I noticed that Google maps is providing directions in my local language (hungarian) when
I noticed that my Designer.vb file of one of my forms has a lot
We noticed that lots of bugs in our software developed in C# (or Java)
i noticed that paypal displays a very different favicon, one that's not just a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.