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

DataFrame.Internal.Interpreter

Synopsis

New core API

data Value a where Source #

The result of interpreting an expression. Keeps literals as scalars until the point where a concrete column is needed, avoiding premature broadcast allocations.

Constructors

Scalar :: forall a. Columnable a => !a -> Value a

A single value, not yet broadcast to any length.

Flat :: forall a. Columnable a => !Column -> Value a

A flat column (one element per row in the flat case, or one element per group after aggregation).

Group :: forall a. Columnable a => !(Vector Column) -> Value a

A grouped column: one Column slice per group. Only produced when interpreting inside a GroupCtx.

Instances

Instances details
Show a => Show (Value a) Source # 
Instance details

Defined in DataFrame.Internal.Interpreter

Methods

showsPrec :: Int -> Value a -> ShowS #

show :: Value a -> String #

showList :: [Value a] -> ShowS #

data Ctx Source #

The interpretation context.

eval :: Columnable a => Ctx -> Expr a -> Either DataFrameException (Value a) Source #

Evaluate an expression in a given context, producing a Value. This single function replaces both the old interpret (flat) and interpretAggregation (grouped) code paths.

materialize :: Columnable a => Int -> Value a -> Column Source #

Force a Value into a flat Column of the given length. Scalars are broadcast; flat columns are returned as-is.

Backward-compatible API

interpret :: Columnable a => DataFrame -> Expr a -> Either DataFrameException (TypedColumn a) Source #

Interpret an expression against a flat DataFrame, producing a typed column. Calls eval then materialize; Lit values are broadcast here at the boundary rather than eagerly.

interpretAggregation :: Columnable a => GroupedDataFrame -> Expr a -> Either DataFrameException (AggregationResult a) Source #

Interpret an expression against a GroupedDataFrame, distinguishing aggregated results from bare column references. Internally calls eval.

data AggregationResult a Source #

Result of interpreting an expression in a grouped context. Retained for backward compatibility with aggregate and friends.