svb

package
v0.0.0-...-4e81e9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2017 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package svb is a Go port of the Stream VByte algorithm, as designed by Lemire/Kurz/Rupp (https://arxiv.org/abs/1709.08990).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetU32Block

func GetU32Block(ctrl byte, data []byte, diff bool) (quad [4]uint32, n int)

GetU32Block decodes a single quad of uint32 values. (This function is the read-side parallel to PutU32Block. These operations are optimized for read- side speed.)

The ctrl byte conveys information about the block being decoded. The data parameter is the buffer where we will be pulling the raw data from, and may require up to 16 bytes to be available. The diff parameter indicates whether the values were encoded using "differential coding" (for more efficient storage).

The results are the quad of data decoded along with an indication of the number of bytes consumed from the data buffer.

Panics will be thrown if there are too few bytes available in the data buffer.

func PutU32Block

func PutU32Block(data []byte, quad []uint32, diff bool) (ctrl byte, n int)

PutU32Block encodes a single quad of uint32 values. (This function is the write-side parallel to GetU32Block. These operations are optimized for read-side speed, but the write-side is still pretty quick.)

The data parameter is the buffer where the encoded values are written, and may need up to 16 bytes available. The quad parameter is the buffer of integers that are to be encoded, and needs to have 4 values available. The diff value signifies that you want to use "differential coding" (for more efficient storage of the values), but this requires that the values must be in ascending sorted order.

The ctrl byte returned is a required hint for decoding, and is expected to be stored in parallel to the data buffer. And the return value n represents the number of bytes used in the data buffer, as per the algorithm.

Panics will be thrown if there are too few bytes available in the data buffer, or too few values in the quad buffer.

func PutUint32s

func PutUint32s(data []byte, num0, num1, num2, num3 uint32) (ctrl byte, n int)

PutUint32s encodes a quad of uint32 into the data buffer, returning the control byte that signifies the encoded byte lengths, and the length of how many bytes got written to the data buffer. If the buffer is too small, PutUStreamVByte will panic

func ReadUint32s

func ReadUint32s(ctrl byte, d io.ByteReader) (nums [4]uint32, err error)

ReadUint32s reads a quad of uint32 from d, using the information encoded in the ctrl byte.

func Uint32s

func Uint32s(ctrl byte, data []byte) (nums [4]uint32, n int)

Uint32s decodes a quad of uint32 from the data buffer, returning the four uint32s and the number of bytes consumed from the buffer. If there aren't enough bytes in the data buffer to match what is required by the ctrl byte, the quad is returned as zeros with n = 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL