mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-20 18:20:41 +00:00
278 lines
31 KiB
HTML
278 lines
31 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="generator" content="rustdoc">
|
||
<meta name="description" content="API documentation for the Rust `BitPacker` trait in crate `bitpacking`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, BitPacker">
|
||
|
||
<title>bitpacking::BitPacker - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../normalize.css">
|
||
<link rel="stylesheet" type="text/css" href="../rustdoc.css"
|
||
id="mainThemeStyle">
|
||
|
||
<link rel="stylesheet" type="text/css" href="../dark.css">
|
||
<link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle">
|
||
<script src="../storage.js"></script>
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc trait">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
<div class="sidebar-menu">☰</div>
|
||
|
||
<p class='location'>Trait BitPacker</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-const">Associated Constants</a><div class="sidebar-links"><a href="#associatedconstant.BLOCK_LEN">BLOCK_LEN</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.new">new</a><a href="#tymethod.compress">compress</a><a href="#tymethod.compress_sorted">compress_sorted</a><a href="#tymethod.decompress">decompress</a><a href="#tymethod.decompress_sorted">decompress_sorted</a><a href="#tymethod.num_bits">num_bits</a><a href="#tymethod.num_bits_sorted">num_bits_sorted</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.compressed_block_size">compressed_block_size</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>bitpacking</a></p><script>window.sidebarCurrent = {name: 'BitPacker', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
|
||
</nav>
|
||
|
||
<div class="theme-picker">
|
||
<button id="theme-picker" aria-label="Pick another theme!">
|
||
<img src="../brush.svg" width="18" alt="Pick another theme!">
|
||
</button>
|
||
<div id="theme-choices"></div>
|
||
</div>
|
||
<script src="../theme.js"></script>
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content"><h1 class='fqn'><span class='in-band'>Trait <a href='index.html'>bitpacking</a>::<wbr><a class="trait" href=''>BitPacker</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/bitpacking/lib.rs.html#161-255' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust trait'>pub trait BitPacker: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
|
||
const <a href='#associatedconstant.BLOCK_LEN' class="constant"><b>BLOCK_LEN</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
||
|
||
fn <a href='#tymethod.new' class='fnname'>new</a>() -> Self;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.compress' class='fnname'>compress</a>(<br> &self, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br> ) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.compress_sorted' class='fnname'>compress_sorted</a>(<br> &self, <br> initial: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br> ) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.decompress' class='fnname'>decompress</a>(<br> &self, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br> ) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.decompress_sorted' class='fnname'>decompress_sorted</a>(<br> &self, <br> initial: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br> ) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.num_bits' class='fnname'>num_bits</a>(&self, decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>;
|
||
<div class='item-spacer'></div> fn <a href='#tymethod.num_bits_sorted' class='fnname'>num_bits_sorted</a>(&self, initial: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>;
|
||
|
||
fn <a href='#method.compressed_block_size' class='fnname'>compressed_block_size</a>(num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> { ... }
|
||
}</pre></div><div class='docblock'><h1 id="examples-without-delta-encoding" class="section-header"><a href="#examples-without-delta-encoding">Examples without delta-encoding</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">bitpacking</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">bitpacking</span>::{<span class="ident">BitPacker4x</span>, <span class="ident">BitPacker</span>};
|
||
|
||
|
||
<span class="kw">let</span> <span class="ident">bitpacker</span> <span class="op">=</span> <span class="ident">BitPacker4x</span>::<span class="ident">new</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">num_bits</span>: <span class="ident">u8</span> <span class="op">=</span> <span class="ident">bitpacker</span>.<span class="ident">num_bits</span>(<span class="kw-2">&</span><span class="ident">my_data</span>);
|
||
|
||
<span class="comment">// A block will be take at most 4 bytes per-integers.</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">compressed</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">4</span> <span class="op">*</span> <span class="ident">BitPacker4x</span>::<span class="ident">BLOCK_LEN</span>];
|
||
|
||
<span class="kw">let</span> <span class="ident">compressed_len</span> <span class="op">=</span> <span class="ident">bitpacker</span>.<span class="ident">compress</span>(<span class="kw-2">&</span><span class="ident">my_data</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">compressed</span>[..], <span class="ident">num_bits</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="ident">num_bits</span> <span class="kw">as</span> <span class="ident">usize</span>) <span class="op">*</span> <span class="ident">BitPacker4x</span>::<span class="ident">BLOCK_LEN</span> <span class="op">/</span> <span class="number">8</span>, <span class="ident">compressed_len</span>);
|
||
|
||
<span class="comment">// Decompressing</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">decompressed</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u32</span>; <span class="ident">BitPacker4x</span>::<span class="ident">BLOCK_LEN</span>];
|
||
<span class="ident">bitpacker</span>.<span class="ident">decompress</span>(<span class="kw-2">&</span><span class="ident">compressed</span>[..<span class="ident">compressed_len</span>], <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">decompressed</span>[..], <span class="ident">num_bits</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">my_data</span>, <span class="kw-2">&</span><span class="ident">decompressed</span>);</pre>
|
||
<h1 id="examples-with-delta-encoding" class="section-header"><a href="#examples-with-delta-encoding">Examples with delta-encoding</a></h1>
|
||
<p>Delta-encoding makes it possible to store sorted integers in an efficient manner.
|
||
Rather than encoding the integers directly, the interval (or deltas) between each of them
|
||
are computed and then encoded.</p>
|
||
<p>Decoding then requires to first decode the deltas and then operate a cumulative sum (also called
|
||
integration or prefix sum) on them.</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">bitpacking</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">bitpacking</span>::{<span class="ident">BitPacker4x</span>, <span class="ident">BitPacker</span>};
|
||
|
||
|
||
|
||
<span class="comment">// The initial value is used to compute the first delta.</span>
|
||
<span class="comment">// In most use cases, you will be compressing long increasing</span>
|
||
<span class="comment">// integer sequences.</span>
|
||
<span class="comment">//</span>
|
||
<span class="comment">// You should probably pass an initial value of `0u32` to the</span>
|
||
<span class="comment">// first block if you do not have any information.</span>
|
||
<span class="comment">//</span>
|
||
<span class="comment">// When encoding the second block however, you will want to pass the last</span>
|
||
<span class="comment">// value of the first block.</span>
|
||
<span class="kw">let</span> <span class="ident">initial_value</span> <span class="op">=</span> <span class="number">0u32</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">bitpacker</span> <span class="op">=</span> <span class="ident">BitPacker4x</span>::<span class="ident">new</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">num_bits</span>: <span class="ident">u8</span> <span class="op">=</span> <span class="ident">bitpacker</span>.<span class="ident">num_bits_sorted</span>(<span class="ident">initial_value</span>, <span class="kw-2">&</span><span class="ident">my_data</span>);
|
||
|
||
<span class="comment">// A block will be take at most 4 bytes per-integers.</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">compressed</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u8</span>; <span class="number">4</span> <span class="op">*</span> <span class="ident">BitPacker4x</span>::<span class="ident">BLOCK_LEN</span>];
|
||
|
||
|
||
<span class="kw">let</span> <span class="ident">compressed_len</span> <span class="op">=</span> <span class="ident">bitpacker</span>.<span class="ident">compress_sorted</span>(<span class="ident">initial_value</span>, <span class="kw-2">&</span><span class="ident">my_data</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">compressed</span>[..], <span class="ident">num_bits</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="ident">num_bits</span> <span class="kw">as</span> <span class="ident">usize</span>) <span class="op">*</span> <span class="ident">BitPacker4x</span>::<span class="ident">BLOCK_LEN</span> <span class="op">/</span> <span class="number">8</span>, <span class="ident">compressed_len</span>);
|
||
|
||
<span class="comment">// Decompressing</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">decompressed</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0u32</span>; <span class="ident">BitPacker4x</span>::<span class="ident">BLOCK_LEN</span>];
|
||
|
||
<span class="comment">// The initial value must be the same as the one passed</span>
|
||
<span class="comment">// when compressing the block.</span>
|
||
<span class="ident">bitpacker</span>.<span class="ident">decompress_sorted</span>(<span class="ident">initial_value</span>, <span class="kw-2">&</span><span class="ident">compressed</span>[..<span class="ident">compressed_len</span>], <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">decompressed</span>[..], <span class="ident">num_bits</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">my_data</span>, <span class="kw-2">&</span><span class="ident">decompressed</span>);</pre>
|
||
</div>
|
||
<h2 id='associated-const' class='small-section-header'>
|
||
Associated Constants<a href='#associated-const' class='anchor'></a>
|
||
</h2>
|
||
<div class='methods'>
|
||
<h3 id='associatedconstant.BLOCK_LEN' class='method'><span id='BLOCK_LEN.v' class='invisible'><code>const <a href='#associatedconstant.BLOCK_LEN' class="constant"><b>BLOCK_LEN</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>Number of <code>u32</code> per compressed block</p>
|
||
</div></div>
|
||
<h2 id='required-methods' class='small-section-header'>
|
||
Required Methods<a href='#required-methods' class='anchor'></a>
|
||
</h2>
|
||
<div class='methods'>
|
||
<h3 id='tymethod.new' class='method'><span id='new.v' class='invisible'><code>fn <a href='#tymethod.new' class='fnname'>new</a>() -> Self</code></span></h3><div class='docblock'><p>Checks the available instructions set on the current
|
||
CPU and returns the best available implementation.</p>
|
||
<p>Calling <code>.new()</code> is extremely cheap, and does not
|
||
require any heap allocation. It is <em>not</em> required to cache
|
||
its result too aggressively.</p>
|
||
</div><h3 id='tymethod.compress' class='method'><span id='compress.v' class='invisible'><code>fn <a href='#tymethod.compress' class='fnname'>compress</a>(<br> &self, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>Compress a block of <code>u32</code>.</p>
|
||
<p>Assumes that the integers are all lower than <code>2^num_bits</code>.
|
||
The result is undefined if they are larger.</p>
|
||
<p>Returns the amount of bytes of the compressed block.</p>
|
||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||
<ul>
|
||
<li>Panics if the compressed destination array is too small</li>
|
||
<li>Panics if <code>decompressed</code> length is not exactly the <code>BLOCK_LEN</code>.</li>
|
||
</ul>
|
||
</div><h3 id='tymethod.compress_sorted' class='method'><span id='compress_sorted.v' class='invisible'><code>fn <a href='#tymethod.compress_sorted' class='fnname'>compress_sorted</a>(<br> &self, <br> initial: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>Delta encode and compressed the <code>decompressed</code> array.</p>
|
||
<p>Assumes that the elements in the <code>decompressed</code> array are sorted.
|
||
<code>initial</code> will be used to compute the first <code>delta</code>.</p>
|
||
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
||
<ul>
|
||
<li>Panics if <code>initial</code> is greater than <code>decompressed[0]</code></li>
|
||
<li>Panics if <code>decompressed</code> is not sorted</li>
|
||
<li>Panics if <code>decompressed</code>'s length is not exactly <code>BLOCK_LEN</code></li>
|
||
<li>Panics if <code>compressed</code> is not large enough to receive the compressed data</li>
|
||
<li>Panics if the compressed destination array is too small.</li>
|
||
</ul>
|
||
<p>Returns the amount of bytes of the compressed block.</p>
|
||
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
|
||
<ul>
|
||
<li>Panics if the compressed array is too short.</li>
|
||
<li>Panics if the decompressed array is not exactly the <code>BLOCK_LEN</code>.</li>
|
||
</ul>
|
||
</div><h3 id='tymethod.decompress' class='method'><span id='decompress.v' class='invisible'><code>fn <a href='#tymethod.decompress' class='fnname'>decompress</a>(<br> &self, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>Decompress the <code>compress</code> array to the <code>decompressed</code> array.</p>
|
||
<p>Returns the amount of bytes that were consumed.</p>
|
||
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
|
||
<p>Panics if the compressed array is too short, or the decompressed array is too short.</p>
|
||
</div><h3 id='tymethod.decompress_sorted' class='method'><span id='decompress_sorted.v' class='invisible'><code>fn <a href='#tymethod.decompress_sorted' class='fnname'>decompress_sorted</a>(<br> &self, <br> initial: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, <br> compressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><br>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>Decompress the<code>compress</code>array to the <code>decompressed</code> array.
|
||
The <code>compressed</code> array is assumed to have been delta-encoded and compressed.</p>
|
||
<p><code>initial</code> must be the value that was passed as the <code>initial</code> argument compressing
|
||
the block.</p>
|
||
<p>Returns the amount of bytes that have been read.</p>
|
||
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
|
||
<ul>
|
||
<li>Panics if the compressed array is too short to contain <code>BLOCK_LEN</code> elements</li>
|
||
<li>Panics if the decompressed array is too short.</li>
|
||
</ul>
|
||
</div><h3 id='tymethod.num_bits' class='method'><span id='num_bits.v' class='invisible'><code>fn <a href='#tymethod.num_bits' class='fnname'>num_bits</a>(&self, decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code></span></h3><div class='docblock'><p>Returns the minimum number of bits used to represent the largest integer in the
|
||
<code>decompressed</code> array.</p>
|
||
</div><h3 id='tymethod.num_bits_sorted' class='method'><span id='num_bits_sorted.v' class='invisible'><code>fn <a href='#tymethod.num_bits_sorted' class='fnname'>num_bits_sorted</a>(&self, initial: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>, decompressed: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code></span></h3><div class='docblock'><p>Returns the minimum number of bits used to represent the largest <code>delta</code> in the deltas in the
|
||
<code>decompressed</code> array.</p>
|
||
</div></div>
|
||
<h2 id='provided-methods' class='small-section-header'>
|
||
Provided Methods<a href='#provided-methods' class='anchor'></a>
|
||
</h2>
|
||
<div class='methods'>
|
||
<h3 id='method.compressed_block_size' class='method'><span id='compressed_block_size.v' class='invisible'><code>fn <a href='#method.compressed_block_size' class='fnname'>compressed_block_size</a>(num_bits: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></h3><div class='docblock'><p>Returns the size of a compressed block.</p>
|
||
</div></div>
|
||
<h2 id='implementors' class='small-section-header'>
|
||
Implementors<a href='#implementors' class='anchor'></a>
|
||
</h2>
|
||
<ul class='item-list' id='implementors-list'>
|
||
<li><table class='table-display'><tbody><tr><td><code>impl BitPacker for <a class="struct" href="../bitpacking/struct.BitPacker1x.html" title="struct bitpacking::BitPacker1x">BitPacker1x</a></code><td><div class='out-of-band'><a class='srclink' href='../src/bitpacking/bitpacker1x.rs.html#66-122' title='goto source code'>[src]</a></div></td></tr></tbody></table></li>
|
||
<li><table class='table-display'><tbody><tr><td><code>impl BitPacker for <a class="struct" href="../bitpacking/struct.BitPacker4x.html" title="struct bitpacking::BitPacker4x">BitPacker4x</a></code><td><div class='out-of-band'><a class='srclink' href='../src/bitpacking/bitpacker4x.rs.html#163-257' title='goto source code'>[src]</a></div></td></tr></tbody></table></li>
|
||
<li><table class='table-display'><tbody><tr><td><code>impl BitPacker for <a class="struct" href="../bitpacking/struct.BitPacker8x.html" title="struct bitpacking::BitPacker8x">BitPacker8x</a></code><td><div class='out-of-band'><a class='srclink' href='../src/bitpacking/bitpacker8x.rs.html#195-289' title='goto source code'>[src]</a></div></td></tr></tbody></table></li>
|
||
</ul><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
|
||
src="../implementors/bitpacking/trait.BitPacker.js">
|
||
</script></section>
|
||
<section id='search' class="content hidden"></section>
|
||
|
||
<section class="footer"></section>
|
||
|
||
<aside id="help" class="hidden">
|
||
<div>
|
||
<h1 class="hidden">Help</h1>
|
||
|
||
<div class="shortcuts">
|
||
<h2>Keyboard Shortcuts</h2>
|
||
|
||
<dl>
|
||
<dt><kbd>?</kbd></dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt><kbd>S</kbd></dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt><kbd>↑</kbd></dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt><kbd>↓</kbd></dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt><kbd>↹</kbd></dt>
|
||
<dd>Switch tab</dd>
|
||
<dt><kbd>⏎</kbd></dt>
|
||
<dd>Go to active search result</dd>
|
||
<dt><kbd>+</kbd></dt>
|
||
<dd>Expand all sections</dd>
|
||
<dt><kbd>-</kbd></dt>
|
||
<dd>Collapse all sections</dd>
|
||
</dl>
|
||
</div>
|
||
|
||
<div class="infos">
|
||
<h2>Search Tricks</h2>
|
||
|
||
<p>
|
||
Prefix searches with a type followed by a colon (e.g.
|
||
<code>fn:</code>) to restrict the search to a given type.
|
||
</p>
|
||
|
||
<p>
|
||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||
<code>struct</code>, <code>enum</code>,
|
||
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
||
and <code>const</code>.
|
||
</p>
|
||
|
||
<p>
|
||
Search functions by type signature (e.g.
|
||
<code>vec -> usize</code> or <code>* -> vec</code>)
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../";
|
||
window.currentCrate = "bitpacking";
|
||
</script>
|
||
<script src="../main.js"></script>
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |