rethinkdb- A driver for the RethinkDB database server

Safe HaskellNone




termToMapReduce :: (ReQL -> ReQL) -> State QuerySettings (ReQL -> ReQL)Source

Takes a function that takes a sequence as an argument, and returns a function that only uses that sequence once, by merging the map and reduce operations. This is used by groupBy.

sameVar :: Int -> [Term] -> BoolSource

Compares the two representations of a variable

notConst :: Chain -> BoolSource

notNone checks that it is a map/reduce and not a constant

wrap :: Term -> ReQLSource

Helper function for casting up from Term into ReQL

toFun1 :: Term -> ReQL -> ReQLSource

Build a single argument function from a constant ReQL expression

toFun2 :: Term -> ReQL -> ReQL -> ReQLSource

Build a two argument function from a constant ReQL expression

data MRF Source

Represents a map/reduce operation split into its map and reduce parts




_mrfMapFun :: MapFun
_mrfReduceFun :: ReQL -> ReQL -> ReQL
_mrfBase :: Maybe ReQL
_mrfFinally :: ReQL -> ReQL

data Chain Source

A Chain of ReQL expressions that might be transformed into a map/reduce operation


None ReQL

A constant, not really a map/reduce operation

Map [Map]

Just a map

MapReduceChain [Map] Reduce

map/reduce operations represented as parts

MapReduce MRF

A rewritten map/reduce

SingletonArray ReQL

Special cases for reduce with base

AddBase ReQL Chain 

data Map Source

A built-in map operation

data MapFun Source


MapFun (ReQL -> ReQL) 
ConcatMapFun (ReQL -> ReQL) 

applyChain :: Chain -> ReQL -> ReQLSource

Convert a Chain back into a ReQL function

applyMRF :: MRF -> ReQL -> ReQLSource

Convert an MRF into a ReQL function

toMapReduce :: Int -> Term -> ChainSource

Rewrites the term in the second argument to merge all uses of the variable whose id is given in the first argument.

mrChain :: TermType -> Chain -> [Term] -> [TermAttribute] -> Maybe ChainSource

Chain a ReQL command onto a MapReduce operation

mapMRF :: TermType -> [Term] -> [TermAttribute] -> Maybe MapFunSource

Convert some builtin operations into a map

reduceMRF :: TermType -> [Term] -> [TermAttribute] -> Maybe MRFSource

Convert some of the built-in operations into a map/reduce

TODO: these have not been tested

baseAttrToOptArg :: TermAttribute -> OptArgSource

Convert from one representation to the other

noRecurse :: OptArgSource

This undocumented optional argument circumvents stream polymorphism on some operations

rewrite1 :: TermType -> [Chain] -> [(Text, Chain)] -> MRFSource

Rewrite a command into a map/reduce.

This is a special case for when only one of the arguments is itself a map/reduce

rewritex :: TermType -> [Chain] -> [(Key, Chain)] -> MRFSource

Rewrite a command that combines the result of multiple map/reduce operations into a single map/reduce operation

extract :: Maybe Int -> TermType -> [Chain] -> [(Key, Chain)] -> (ReQL -> ReQL, [MRF])Source

Extract the inner map/reduce objects, also returning a function which, given the result of all the map/reduce operations, returns the result of the given command