cascalog.logic.parse documentation
->Application
(->Application source operation)
Positional factory function for class cascalog.logic.parse.Application.
->ExistenceNode
(->ExistenceNode source output-field)
Positional factory function for class cascalog.logic.parse.ExistenceNode.
->FilterApplication
(->FilterApplication source filter)
Positional factory function for class cascalog.logic.parse.FilterApplication.
->Grouping
(->Grouping source aggregators grouping-fields options)
Positional factory function for class cascalog.logic.parse.Grouping.
->Join
(->Join sources join-fields type-seq)
Positional factory function for class cascalog.logic.parse.Join.
->Merge
(->Merge sources)
Positional factory function for class cascalog.logic.parse.Merge.
->Projection
(->Projection source fields)
Positional factory function for class cascalog.logic.parse.Projection.
->Rename
(->Rename source fields)
Positional factory function for class cascalog.logic.parse.Rename.
->TailStruct
(->TailStruct node ground? available-fields operations)
Positional factory function for class cascalog.logic.parse.TailStruct.
->Unique
(->Unique source fields options)
Positional factory function for class cascalog.logic.parse.Unique.
<-
macro
(<- outvars & predicates)
Constructs a query or predicate macro from a list of
predicates. Predicate macros support destructuring of the input and
output variables.
accept?
(accept? this tail)
Returns true if this op can be applied to the current tail
add-ops-fixed-point
(add-ops-fixed-point tail)
Adds operations to tail until can't anymore. Returns new tail and
any unapplied operations.
aggregation-assertions!
(aggregation-assertions! buffers aggs options)
apply-equality-ops
(apply-equality-ops tail equality-pairs)
Accepts a TailStruct instance and a sequence of pairs of input
variables, and applies an equality filter for every pair.
apply-to-tail
(apply-to-tail this tail)
Accepts a tail and performs some modification on that tail,
returning a new tail.
attempt-join
(attempt-join tails)
Attempt to reduce the supplied set of tails by joining.
build-agg-tail
(build-agg-tail tail aggs grouping-fields options)
build-query
(build-query output-fields raw-predicates)
build-rule
(build-rule {:keys [fields predicates options], :as input})
default-selector
(default-selector op)
Default selector (either input or output) for this
operation. Dispatches based on type.
desugar-selectors
(desugar-selectors arg-m & sugar-full-pairs)
Accepts a map of cascalog input or output symbol (:< or :>, for
example) to var sequence, a <sugary input or output selector> and a
<full vector input or output selector> and either destructures the
non-sugary input or moves the sugary input into its proper
place. For example:
(desugar-selectors {:>> (["?a"])} :> :>>)
;=> {:>> ["?a"]}
(desugar-selectors {:> ["?a"] :<< [["?b"]]} :> :>> :< :<<)
;=> {:>> ["?a"], :<< ["?b"]}
existence-field
(existence-field node)
Returns true if this location directly descends from an
ExistenceNode, false otherwise. Short-circuits at any merge.
expand-outvars
(expand-outvars {:keys [op input output], :as pred})
expand-positional-selector
(expand-positional-selector arg-m)
Accepts a map of cascalog selector to var sequence and, if the map
contains an entry for Cascalog's positional selector, expands out
the proper number of logic vars and replaces each entry specified
within the positional map. This function returns the updated map.
find-join-fields
(find-join-fields l r)
grouping-output
(grouping-output aggs grouping-fields)
Returns the union of all grouping fields and all outputs for every
aggregation field. These are the only fields available after the
aggregation.
initial-tails
(initial-tails generators operations)
Builds up a sequence of tail structs from the supplied generators
and operations.
joinable?
(joinable? tail joinfields)
Returns true if the supplied tail can be joined with the supplied
join fields, false otherwise.
A join works if the join fields are all available in the given tail
AND the tail's either fully ground, or every non-join variable is
unground.
map->Application
(map->Application m__2313__auto__)
Factory function for class cascalog.logic.parse.Application, taking a map of keywords to field values.
map->ExistenceNode
(map->ExistenceNode m__2313__auto__)
Factory function for class cascalog.logic.parse.ExistenceNode, taking a map of keywords to field values.
map->FilterApplication
(map->FilterApplication m__2313__auto__)
Factory function for class cascalog.logic.parse.FilterApplication, taking a map of keywords to field values.
map->Grouping
(map->Grouping m__2313__auto__)
Factory function for class cascalog.logic.parse.Grouping, taking a map of keywords to field values.
map->Join
(map->Join m__2313__auto__)
Factory function for class cascalog.logic.parse.Join, taking a map of keywords to field values.
map->Merge
(map->Merge m__2313__auto__)
Factory function for class cascalog.logic.parse.Merge, taking a map of keywords to field values.
map->Projection
(map->Projection m__2313__auto__)
Factory function for class cascalog.logic.parse.Projection, taking a map of keywords to field values.
map->Rename
(map->Rename m__2313__auto__)
Factory function for class cascalog.logic.parse.Rename, taking a map of keywords to field values.
map->TailStruct
(map->TailStruct m__2313__auto__)
Factory function for class cascalog.logic.parse.TailStruct, taking a map of keywords to field values.
map->Unique
(map->Unique m__2313__auto__)
Factory function for class cascalog.logic.parse.Unique, taking a map of keywords to field values.
maximal-join
(maximal-join tail-seq)
Returns the between the two generators with the largest
intersection of joinable fields.
merge-tails
(merge-tails tails)
The first call begins with a bunch of generator tails, each with a
list of operations that could be applied. Based on the op-allowed
logic, these tails try to consume as many operations as possible
before giving up at a fixed point.
op-allowed?
(op-allowed? {:keys [ground? available-fields node]} op)
An operation can be applied to a tail if all of the following
conditions apply:
- It only consumes fields that are available in the supplied
TailStruct,
- It's a filter (or the branch is NOT a GeneratorSet)
- It only consumes ground variables (or the generator itself is
ground)
parse-subquery
(parse-subquery output-fields raw-predicates)
Parses predicates and output fields and returns a proper subquery.
parse-variables
(parse-variables vars default-selector)
parses variables of the form ['?a' '?b' :> '!!c'] and returns a map
of input variables, output variables, If there is no :>, defaults
to selector-default.
prefer-filter
(prefer-filter op)
prepare-operation
(prepare-operation op tail)
When an operation produces fields that are already present in the
tail, this is interpreted as an implicit filter against the existing
values. This function accepts an operation and a TailStruct and
returns a sequence of all pairs of output variable substitutions,
plus a new operation with output fields swapped as necessary
project
(project tail fields)
query-signature?
(query-signature? vars)
Accepts the normalized return vector of a Cascalog form and returns
true if the return vector is from a subquery, false otherwise. (A
predicate macro would trigger false, for example.)
rename
(rename tail fields)
select-join
(select-join tails)
Returns the join fields that will join the maximum number of fields
at a time. If the search fails, select-join throws.
This is unoptimal. It's better to rewrite this as a search problem
to find optimal joins.
split-outvar-constants
(split-outvar-constants output)
Accepts a sequence of output variables and returns a 2-vector:
[new-outputs, [seq-of-new-raw-predicates]]
By creating a new output predicate for every constant in the output
field.
tail-fields-intersection
(tail-fields-intersection & tails)
tail?
Returns true if the supplied item is a TailStruct, false
otherwise.
unground-assertions!
(unground-assertions! gens ops)
Performs various validations on the supplied set of parsed
predicates. If all validations pass, returns the sequence
unchanged.
unground-outvars
(unground-outvars predicates)
For the supplied sequence of RawPredicate instances, returns a seq
of all ungrounding vars in the output position.
validate-aggregation!
(validate-aggregation! tail aggs options)
Makes sure that all fields are available for the aggregation.
validate-generator-set!
(validate-generator-set! input output)
GeneratorSets can't be unground, ever.
validate-predicates!
(validate-predicates! preds opts)
validate-projection!
(validate-projection! remaining-ops needed available)