Variable-Width Integer Type (VInt)

Learned in CS451.

Uses 1-5 bytes to represent an Int (same range as 4 byte fixed width).

When to use?

Very useful when you are dealing with lots of small numbers, but sometimes need to represent big numbers. Instead of storing 4 bytes for each number, you only need to use up 2 bytes.

  • In the context of CS451, useful when building an inverted index

Main Idea

How? Need a way to indicate the length, that’s all.

I'm not sure if this is exactly how it works..

this is the way the prof presented it in CS451, but I don’t think that’s actually how it works all the time. It’s a variant. This version needs at least 2 bytes to represent a number, since the first byte is always a control flag.