Copyright | (c) Adam Conner-Sax 2019 |
---|---|
License | BSD-3-Clause |
Maintainer | adam_conner_sax@yahoo.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Frames-map-reduce provides helper functions for using map-reduce-folds with Frames. Please see those packages for more details.
Synopsis
- unpackFilterRow :: (Record rs -> Bool) -> Unpack (Record rs) (Record rs)
- unpackFilterOnField :: forall t rs. (KnownField t, ElemOf rs t) => (Snd t -> Bool) -> Unpack (Record rs) (Record rs)
- unpackGoodRows :: forall cs rs. cs ⊆ rs => Unpack (Rec (Maybe :. ElField) rs) (Record cs)
- assignKeysAndData :: forall ks cs rs. (ks ⊆ rs, cs ⊆ rs) => Assign (Record ks) (Record rs) (Record cs)
- assignKeys :: forall ks rs. ks ⊆ rs => Assign (Record ks) (Record rs) (Record rs)
- splitOnKeys :: forall ks rs cs. (ks ⊆ rs, cs ~ RDeleteAll ks rs, cs ⊆ rs) => Assign (Record ks) (Record rs) (Record cs)
- reduceAndAddKey :: forall ks cs x. RecVec (ks ++ cs) => (forall h. Foldable h => h x -> Record cs) -> Reduce (Record ks) x (FrameRec (ks ++ cs))
- foldAndAddKey :: RecVec (ks ++ cs) => Fold x (Record cs) -> Reduce (Record ks) x (FrameRec (ks ++ cs))
- makeRecsWithKey :: (Functor g, Foldable g, RecVec (ks ++ as)) => (y -> Record as) -> Reduce (Record ks) x (g y) -> Reduce (Record ks) x (FrameRec (ks ++ as))
- makeRecsWithKeyM :: (Monad m, Functor g, Foldable g, RecVec (ks ++ as)) => (y -> Record as) -> ReduceM m (Record ks) x (g y) -> ReduceM m (Record ks) x (FrameRec (ks ++ as))
- module Control.MapReduce
- module Control.MapReduce
Unpackers
unpackFilterRow :: (Record rs -> Bool) -> Unpack (Record rs) (Record rs) Source #
Filter records using a function on the entire record.
unpackFilterOnField :: forall t rs. (KnownField t, ElemOf rs t) => (Snd t -> Bool) -> Unpack (Record rs) (Record rs) Source #
Filter records based on a condition on only one field in the row. Will usually require a Type Application to indicate which field.
unpackGoodRows :: forall cs rs. cs ⊆ rs => Unpack (Rec (Maybe :. ElField) rs) (Record cs) Source #
An unpack step which specifies a subset of columns, cs, (via a type-application) and then filters a Rec (Maybe :. Elfield) rs
to only rows which have all good data in that subset.
Assigners
assignKeysAndData :: forall ks cs rs. (ks ⊆ rs, cs ⊆ rs) => Assign (Record ks) (Record rs) (Record cs) Source #
Assign both keys and data cols. Uses type applications to specify them if they cannot be inferred. Keys usually can't. Data sometimes can.
assignKeys :: forall ks rs. ks ⊆ rs => Assign (Record ks) (Record rs) (Record rs) Source #
Assign keys and leave all columns, including the keys, in the data passed to reduce.
splitOnKeys :: forall ks rs cs. (ks ⊆ rs, cs ~ RDeleteAll ks rs, cs ⊆ rs) => Assign (Record ks) (Record rs) (Record cs) Source #
Assign keys and leave the rest of the columns, excluding the keys, in the data passed to reduce.
Reduce and Re-Attach Key Cols
:: RecVec (ks ++ cs) | |
=> (forall h. Foldable h => h x -> Record cs) | reduction step |
-> Reduce (Record ks) x (FrameRec (ks ++ cs)) |
Reduce the data to a single row and then re-attach the key.
:: RecVec (ks ++ cs) | |
=> Fold x (Record cs) | reduction fold |
-> Reduce (Record ks) x (FrameRec (ks ++ cs)) |
Reduce by folding the data to a single row and then re-attaching the key.
Re-Attach Key Cols
:: (Functor g, Foldable g, RecVec (ks ++ as)) | |
=> (y -> Record as) | map a result to a record |
-> Reduce (Record ks) x (g y) | original reduce |
-> Reduce (Record ks) x (FrameRec (ks ++ as)) |
Transform a reduce which produces a container of results, with a function from each result to a record, into a reduce which produces a FrameRec of the result records with the key re-attached.
:: (Monad m, Functor g, Foldable g, RecVec (ks ++ as)) | |
=> (y -> Record as) | map a result to a record |
-> ReduceM m (Record ks) x (g y) | original reduce |
-> ReduceM m (Record ks) x (FrameRec (ks ++ as)) |
Transform an effectful reduce which produces a container of results, with a function from each result to a record, into a reduce which produces a FrameRec of the result records with the key re-attached.
Re-Exports
module Control.MapReduce
module Control.MapReduce