Frames-map-reduce-0.3.0.0: Frames wrapper for map-reduce-folds and some extra folds helpers.

Safe HaskellNone
LanguageHaskell2010

Frames.MapReduce.General

Contents

Synopsis

Documentation

class RecGetFieldC t record f rs where Source #

Minimal complete definition

rgetF

Methods

rgetF :: (KnownField t, ElemOf rs t) => record (f :. ElField) rs -> (f :. ElField) t Source #

rgetFieldF :: (KnownField t, Functor f, ElemOf rs t) => record (f :. ElField) rs -> f (Snd t) Source #

Instances
FieldOffset (f :. ElField) rs t => RecGetFieldC t (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f rs Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

rgetF :: SRec (f :. ElField) rs -> (f :. ElField) t Source #

rgetFieldF :: SRec (f :. ElField) rs -> f (Snd t) Source #

RecGetFieldC t (ARec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f rs Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

rgetF :: ARec (f :. ElField) rs -> (f :. ElField) t Source #

rgetFieldF :: ARec (f :. ElField) rs -> f (Snd t) Source #

RecGetFieldC t (Rec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f rs Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

rgetF :: Rec (f :. ElField) rs -> (f :. ElField) t Source #

rgetFieldF :: Rec (f :. ElField) rs -> f (Snd t) Source #

class RCastC rs ss record f where Source #

Methods

rcastF :: record (f :. ElField) ss -> record (f :. ElField) rs Source #

Instances
(RPureConstrained (FieldOffset (f :. ElField) ss) rs, RPureConstrained (FieldOffset (f :. ElField) rs) rs, RFoldMap rs, RMap rs, RApply rs, Storable (Rec (f :. ElField) rs)) => RCastC (rs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

rcastF :: SRec (f :. ElField) ss -> SRec (f :. ElField) rs Source #

(IndexWitnesses (RImage rs ss), NatToInt (RLength rs)) => RCastC (rs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) (ARec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

rcastF :: ARec (f :. ElField) ss -> ARec (f :. ElField) rs Source #

RecSubset (Rec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) rs ss (RImage rs ss) => RCastC (rs :: [(Symbol, Type)]) (ss :: [(Symbol, Type)]) (Rec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

rcastF :: Rec (f :. ElField) ss -> Rec (f :. ElField) rs Source #

class IsoRec rs record f where Source #

Methods

toRec :: record (f :. ElField) rs -> Rec (f :. ElField) rs Source #

fromRec :: Rec (f :. ElField) rs -> record (f :. ElField) rs Source #

Instances
(NatToInt (RLength rs), RecApplicative rs, RPureConstrained (IndexableField rs) rs) => IsoRec rs (ARec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

toRec :: ARec (f :. ElField) rs -> Rec (f :. ElField) rs Source #

fromRec :: Rec (f :. ElField) rs -> ARec (f :. ElField) rs Source #

Storable (Rec (f :. ElField) rs) => IsoRec rs (SRec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

toRec :: SRec (f :. ElField) rs -> Rec (f :. ElField) rs Source #

fromRec :: Rec (f :. ElField) rs -> SRec (f :. ElField) rs Source #

IsoRec rs (Rec :: ((Symbol, Type) -> Type) -> [(Symbol, Type)] -> Type) f Source # 
Instance details

Defined in Frames.MapReduce.General

Methods

toRec :: Rec (f :. ElField) rs -> Rec (f :. ElField) rs Source #

fromRec :: Rec (f :. ElField) rs -> Rec (f :. ElField) rs Source #

isoRecAppend :: forall f record (as :: [(Symbol, Type)]) bs. (IsoRec as record f, IsoRec bs record f, IsoRec (as ++ bs) record f) => record (f :. ElField) as -> record (f :. ElField) bs -> record (f :. ElField) (as ++ bs) Source #

unpackNoOp :: Unpack (record (f :. ElField) rs) (record (f :. ElField) rs) Source #

Don't do anything

unpackFilterRow :: (record (f :. ElField) rs -> Bool) -> Unpack (record (f :. ElField) rs) (record (f :. ElField) rs) Source #

Filter records using a function on the entire record.

unpackFilterOnField :: forall t rs record f. (Functor f, KnownField t, ElemOf rs t, RecGetFieldC t record f rs) => (f (Snd t) -> Bool) -> Unpack (record (f :. ElField) rs) (record (f :. ElField) 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.

unpackFilterOnGoodField :: forall t rs record f. (Functor f, KnownField t, ElemOf rs t, RecGetFieldC t record f rs) => (forall a. f a -> Maybe a) -> (Snd t -> Bool) -> Unpack (record (f :. ElField) rs) (record (f :. ElField) rs) Source #

unpackGoodRows :: forall cs rs record f. RCastC cs rs record f => (record (f :. ElField) cs -> Bool) -> Unpack (record (f :. ElField) rs) (record (f :. ElField) rs) Source #

An unpack step which specifies a subset of columns, cs, (via a type-application) and then filters a record (Maybe :. Elfield) rs to only rows which have all good data in that subset.

assignKeysAndData :: forall ks cs rs record f. (RCastC ks rs record f, RCastC cs rs record f) => Assign (record (f :. ElField) ks) (record (f :. ElField) rs) (record (f :. ElField) 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.

splitOnKeys :: forall ks rs cs record f. (RCastC ks rs record f, RCastC cs rs record f, cs ~ RDeleteAll ks rs) => Assign (record (f :. ElField) ks) (record (f :. ElField) rs) (record (f :. ElField) cs) Source #

Assign keys and leave the rest of the columns, excluding the keys, in the data passed to reduce.

assignKeys :: forall ks rs record f. RCastC ks rs record f => Assign (record (f :. ElField) ks) (record (f :. ElField) rs) (record (f :. ElField) rs) Source #

Assign keys and leave all columns, including the keys, in the data passed to reduce.

reduceAndAddKey Source #

Arguments

:: (IsoRec ks record f, IsoRec cs record f, IsoRec (ks ++ cs) record f) 
=> (forall h. Foldable h => h x -> record (f :. ElField) cs)

reduction step

-> Reduce (record (f :. ElField) ks) x (record (f :. ElField) (ks ++ cs)) 

Reduce the data to a single row and then re-attach the key. | NB: for all but Rec case, this will have to convert record to Rec and back for the append

foldAndAddKey Source #

Arguments

:: (IsoRec ks record f, IsoRec cs record f, IsoRec (ks ++ cs) record f) 
=> Fold x (record (f :. ElField) cs)

reduction fold

-> Reduce (record (f :. ElField) ks) x (record (f :. ElField) (ks ++ cs)) 

Reduce by folding the data to a single row and then re-attaching the key.

makeRecsWithKey Source #

Arguments

:: (Functor g, Foldable g, IsoRec ks record f, IsoRec as record f, IsoRec (ks ++ as) record f) 
=> (y -> record (f :. ElField) as)

map a result to a record

-> Reduce (record (f :. ElField) ks) x (g y)

original reduce

-> Reduce (record (f :. ElField) ks) x (g (record (f :. ElField) (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 foldable (based on the original reduce) of the result records with the key re-attached.

makeRecsWithKeyM Source #

Arguments

:: (Monad m, Functor g, Foldable g, IsoRec ks record f, IsoRec as record f, IsoRec (ks ++ as) record f) 
=> (y -> record (f :. ElField) as)

map a result to a record

-> ReduceM m (record (f :. ElField) ks) x (g y)

original reduce

-> ReduceM m (record (f :. ElField) ks) x (g (record (f :. ElField) (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 foldable (based on the original reduce) of the result records with the key re-attached.

Orphan instances

(KnownField t, Functor f, RecGetFieldC t record f (t ': rs), RCastC rs (t ': rs) record f, Hashable (f (Snd t)), Hashable (record (f :. ElField) rs)) => Hashable (record (f :. ElField) (t ': rs)) Source # 
Instance details

Methods

hashWithSalt :: Int -> record (f :. ElField) (t ': rs) -> Int #

hash :: record (f :. ElField) (t ': rs) -> Int #

Hashable (record (f :. ElField) ([] :: [k])) Source #

This is only here so we can use hash maps for the grouping step. This should properly be in Frames itself.

Instance details

Methods

hashWithSalt :: Int -> record (f :. ElField) [] -> Int #

hash :: record (f :. ElField) [] -> Int #