| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
DataFrame.Internal.PackedText
Description
Packed-text payload + byte-slice primitives. A PackedTextData shares one
UTF-8 byte buffer across all rows of a string column, with n+1 row offsets, so
no per-row Text header is materialized until decode is demanded.
Offsets and selection vectors are stored Int32 whenever their values fit
(Arrow-style), halving the per-row footprint of large string columns.
Synopsis
- data PackedTextData = PackedTextData {
- ptBytes :: !Array
- ptOffsets :: !PackedOffsets
- ptSel :: !(Maybe PackedSel)
- ptCanonicalSel :: !Bool
- data PackedOffsets
- data PackedSel
- offAt :: PackedOffsets -> Int -> Int
- offCount :: PackedOffsets -> Int
- selAt :: PackedSel -> Int -> Int
- selLength :: PackedSel -> Int
- mkPackedContiguous :: Array -> Vector Int -> PackedTextData
- mkPackedContiguous32 :: Array -> Vector Int32 -> PackedTextData
- mkOffsets :: Vector Int -> PackedOffsets
- mkSel :: Int -> Vector Int -> PackedSel
- packedGather :: Vector Int -> PackedTextData -> PackedTextData
- packedTake :: Int -> PackedTextData -> PackedTextData
- packedRowOffsets :: PackedTextData -> Maybe (Array, PackedOffsets)
- packedLength :: PackedTextData -> Int
- packedSlice :: PackedTextData -> Int -> (Array, Int, Int)
- packedIndexText :: PackedTextData -> Int -> Text
- sliceEqBytes :: Array -> Int -> Int -> Array -> Int -> Int -> Bool
- sliceCmpBytes :: Array -> Int -> Int -> Array -> Int -> Int -> Ordering
Documentation
data PackedTextData Source #
A shared UTF-8 byte buffer plus n+1 row offsets (base row r spans bytes
[offsets!r, offsets!(r+1))); validity lives in the column's bitmap. ptSel is
an optional selection layer letting a gatherjoinsort result share the buffer.
ptCanonicalSel marks a selection that is a canonical dictionary encoding:
equal byte slices always map to the same base row (codes). Set by dictionary
compaction; preserved by gather/take over an already-canonical selection (a
row keeps its code); False for a gather over an unselected base, where two
logical rows can select different but equal-byted base rows. Grouping keys on
codes directly when it holds.
Constructors
| PackedTextData | |
Fields
| |
data PackedOffsets Source #
A selection layer mapping logical rows to base rows; -1 marks an
invalid/null row. Int32 when the base row count fits.
offCount :: PackedOffsets -> Int Source #
Number of offset entries (row count + 1).
mkPackedContiguous :: Array -> Vector Int -> PackedTextData Source #
Build a contiguous packed payload (no selection): the freeze-path shape.
mkPackedContiguous32 :: Array -> Vector Int32 -> PackedTextData Source #
mkPackedContiguous from offsets already produced at Int32 width.
mkOffsets :: Vector Int -> PackedOffsets Source #
Narrow an Int offset vector when the final offset (total bytes) fits.
packedGather :: Vector Int -> PackedTextData -> PackedTextData Source #
Reindex a packed payload by a selection vector, sharing the byte buffer;
logical row i becomes base row indices!i. A negative or out-of-range index
decodes to the empty slice. Composes with an existing selection; canonicality
survives composition (a kept row keeps its code) but not a first selection
over the unselected base.
packedTake :: Int -> PackedTextData -> PackedTextData Source #
Take the first k logical rows, sharing the byte buffer via a capped
selection layer. O(k), no byte copy or decode — cheap take/display on a
large packed column.
packedRowOffsets :: PackedTextData -> Maybe (Array, PackedOffsets) Source #
The shared buffer + contiguous n+1 offsets when the payload is the
unselected base; a selected (gathered) payload returns Nothing (its rows are
non-contiguous). Lets contiguous consumers skip the selection indirection.
packedLength :: PackedTextData -> Int Source #
Row count: length sel when selected, else length offsets - 1.
packedSlice :: PackedTextData -> Int -> (Array, Int, Int) Source #
Raw byte slice for logical row i: (buffer, offset, length). The hot accessor.
packedIndexText :: PackedTextData -> Int -> Text Source #
On-demand single Text for row i, using the same
validate-or-lenient decode as the freeze path so output is bit-identical.