Documentation ¶
Overview ¶
Package stringcoding provides an easy way to deal with strings in a bit-to-bit fashion Each compressed/uncompressed string will be represented in the structure in right to left order (from the least significant bit to the most significant). i.e: The list of two strings [cia, cio] (without loss of generality we suppose to work with characters instead
bits), will be encoded as [aic|o] (the vertical bar here is simply used to divide the two encoded string)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyString is returned when you are trying to access to an empty string using Elias Gamma's methods ErrEmptyString = errors.New("elias Gamma coding is undefined for the empty string") )
var ( // ErrTooShortString is returned when you are trying to access given an index that isn't defined ErrTooShortString = errors.New("the string is too short to contain a prefix of that length") )
Functions ¶
This section is empty.
Types ¶
type Coding ¶
type Coding struct { // Strings consists of all the concatenated bit sequences // corresponding to the suffixes L[i] of S's strings. Strings *bd.BitData // Starts consists of a sequence of bits in which each bit // set to 1 marks the first bit of each of those suffixes // in the aforementioned array (Strings). Starts *bd.BitData // Lengths encodes a value associated to each string in strings. // The value depends from the particular compression scheme used Lengths *bd.BitData // LastString contains the last processed string as a sequence // of bit. It can be used for a more efficient processing of the // current string to deal with. LastString *bd.BitData // NextIndex marks the last index in Strings (risp. Starts) arrays. NextIndex uint64 // NextLengthsIndex marks the last index in the Lengths array. NextLengthsIndex uint64 }
Coding is a type that contains some of the data structures to run LPRC and PSRC
type LPRC ¶
type LPRC struct { Epsilon float64 // contains filtered or unexported fields }
LPRC contains all the data structures to run LPRC algorithm
func NewLPRC ¶
NewLPRC returns a LPRC (Locality Preserving Rear Coding): a storage method based on RC (Rear Coding) that stores a string s in an uncompressed way if the latest c|s| bits do not contain an uncompressed string.
func (*LPRC) FullPrefixSearch ¶
FullPrefixSearch , given a prefix *prefix* returns all the strings that start with that prefix.
func (*LPRC) GetBitDataSize ¶
GetBitDataSize returns the size in bits of the BitData used to compress the strings
type LPRCBitDataSize ¶
type LPRCBitDataSize struct { StringsSize uint64 StartsSize uint64 LengthsSize uint64 IsUncompressedSize uint64 }
LPRCBitDataSize contains the size of all the data structures
type PSRC ¶
type PSRC struct { Epsilon float64 // contains filtered or unexported fields }
PSRC contains all the data structures to run PSRC algorithm
func NewPSRC ¶
NewPSRC return an implementation of PSRC: a storage method based on RC (Rear Coding) that stores a string s in an uncompressed way if the latest c|s| bits do not contain an uncompressed string.
func (*PSRC) FullPrefixSearch ¶
FullPrefixSearch , given a prefix *prefix* returns all the strings that start with that prefix.
func (*PSRC) GetBitDataSize ¶
GetBitDataSize returns the size in bits of the BitData used to compress the strings
type PSRCBitDataSize ¶
type PSRCBitDataSize struct { StringsSize uint64 StartsSize uint64 LengthsSize uint64 IsUncompressedSize uint64 PrefixOrSuffixSize uint64 }
PSRCBitDataSize contains the size of all the data structures for PSRC
type PrefixSearch ¶
type PrefixSearch interface { Populate() error Retrieval(uint64, uint64) (string, error) FullPrefixSearch(prefix string) ([]string, error) GetBitDataSize() map[string]uint64 // contains filtered or unexported methods }
PrefixSearch interface contains all the methods in order to run both LPRC and PSRC