mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-07 01:32:53 +00:00
Fast Field Codecs
This crate contains various fast field codecs, used to compress/decompress fast field data in tantivy.
Contributing
Contributing is pretty straightforward. Since the bitpacking is the simplest compressor, you can check it for reference.
A codec needs to implement 2 traits:
- A reader implementing
FastFieldCodecReaderto read the codec. - A serializer implementing
FastFieldCodecSerializerfor compression estimation and codec name + id.
Download real world datasets for codecs comparison
Before comparing codecs, you need to execute make download to download real world datasets hosted on AWS S3.
Tests
Once the traits are implemented test and benchmark integration is pretty easy (see test_with_codec_data_sets and bench.rs).
Make sure to add the codec to the main.rs, which tests the compression ratio and estimation against different data sets. You can run it with:
cargo run --features bin
TODO
- Add codec to cover sparse data sets
Codec Comparison
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| | Compression ratio | Compression ratio estimation | Compression time (micro) | Reading time (micro) |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Autoincrement | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.000039572664 | 0.000004396963 | 731 | 0 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.022707172 | 0.17275847 | 1050 | 282 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.0051544965 | 0.17251475 | 963 | 216 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.28126493 | 0.28125 | 473 | 112 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Monotonically increasing concave | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.25003937 | 0.26562938 | 758 | 113 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.05403 | 0.1883836 | 902 | 223 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.005955 | 0.18813984 | 896 | 217 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.31251436 | 0.3125 | 476 | 113 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Monotonically increasing convex | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.25003937 | 0.28125438 | 757 | 113 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.053845 | 0.2040086 | 897 | 223 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.00613 | 0.20376484 | 912 | 217 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.31251436 | 0.3125 | 510 | 113 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Almost monotonically increasing | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.14066513 | 0.1406294 | 752 | 112 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.1472926 | 0.17275847 | 917 | 222 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.14537804 | 0.17251475 | 931 | 216 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.28126493 | 0.28125 | 468 | 112 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Random | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.14066513 | 0.1406294 | 769 | 112 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.1473328 | 0.14150847 | 960 | 222 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.14549863 | 0.14126475 | 907 | 216 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.12501445 | 0.125 | 412 | 114 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| HDFS logs timestamps | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.39063287 | 0.40625086 | 4808 | 606 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.39983186 | 0.40713495 | 5704 | 1197 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.39826187 | 0.4068908 | 5914 | 1167 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.39062786 | 0.390625 | 2768 | 618 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| HDFS logs timestamps SORTED | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.39063287 | 0.40625086 | 4118 | 573 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.034706876 | 0.09463495 | 5046 | 1118 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.032736875 | 0.094390824 | 5098 | 1164 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.39062786 | 0.390625 | 2802 | 606 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| HTTP logs timestamps SORTED | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.21875787 | 0.23437588 | 3953 | 567 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.050024875 | 0.20400995 | 4872 | 1179 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.047942877 | 0.20376582 | 5389 | 1163 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.26562786 | 0.265625 | 2572 | 618 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Amazon review product ids | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.40625787 | 0.42187586 | 4302 | 606 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.42106587 | 0.42275995 | 5720 | 1241 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.41900787 | 0.4225158 | 5285 | 1092 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.40625286 | 0.40625 | 2846 | 578 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Amazon review product ids SORTED | | | | |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| LinearInterpol | 0.35938287 | 0.39062586 | 4445 | 607 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpol | 0.18557687 | 0.25088495 | 5554 | 1312 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| MultiLinearInterpolV2 | 0.18364687 | 0.25064084 | 5371 | 1088 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+
| Bitpacked | 0.40625286 | 0.40625 | 2699 | 567 |
+----------------------------------+-------------------+------------------------------+--------------------------+----------------------+