What is VInt in Lucene?

I want to know what is VInt in Lucene?

I have read this article but I do not understand what it is and where does Lucene use? Why doesn't Lucene use a simple whole or a large whole?

Thanks.

+2


a source to share


3 answers


VInt is extremely space efficient. This can theoretically save up to 75% of space.

In Lucene, many structures are a list of integers. For example, a list of documents for a given term, positions (and offsets) of conditions in documents, among others. These lists make up the bulk of lucene's data.



Think of Lucene's metrics for millions of documents that require tens of GB of space. Reducing space by more than half reduces disk space requirements. While the disk space savings may not be a big win given that disk space is cheap, the real gain results in less disk I / O. Disk IO reading VInt data is lower than reading integers, which automatically translates to better performance.

+4


a source


VInt refers to the Lucene variable width integer encoding scheme. It encodes integers in one or more bytes using only the least significant seven bits of each byte. The high bit is set to zero for all bytes except the last one, which encodes the length.



+1


a source


For your first question: This defines a variable length format for positive integers, where the most significant bit of each byte indicates if there are more bytes to read. The seven least significant bits are added as more significant bits resulting in an integer value. Thus, values ​​from zero to 127 can be stored in one byte, values ​​from 128 to 16, 383 can be stored in two bytes, and so on. https://lucene.apache.org/core/3_0_3/fileformats.html .

So, to store a list of n integers, the amount of memory you need is [for example] 4 * n bytes. But with Vint, all numbers up to 128 will be stored using only 1 byte [etc.], saving a lot of memory.

Vint provides a condensed representation of integers, and Shashikant's answer already explains the requirements and benefits of compression in Lucene.

+1


a source







All Articles