dataframe-core-2.2.0.0: Core data structures for the dataframe library.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Internal.DictEncode

Description

Dictionary-encode a text (or factor) group key to dense Int codes: each row gets a first-appearance code 0..card-1 (NULL reserved) plus the cardinality. A tested building block; profiled slower than the hash group-by, so unused for now.

Synopsis

Documentation

dictEncodeColumn :: Column -> Maybe (Vector Int, Int) Source #

Dictionary-encode a text-like column to dense first-appearance Int codes, returning Just (codes, cardinality) (a NULL row gets its own reserved code). Nothing for non-text columns or cardinality above dictMaxCardinality.

dictEncodeColumnUpTo :: Int -> Column -> Maybe (Vector Int, Int) Source #

Dictionary-encode like dictEncodeColumn but bail to Nothing as soon as the distinct count would exceed maxCard, letting a low-cardinality probe avoid a full high-cardinality pass.

dictMaxCardinality :: Int Source #

Largest distinct-value count we will dictionary-encode. Above this the codes no longer index a reasonable direct accumulator and the encode pass is pure overhead, so the caller keeps the plain hash group-by.