souffle  2.0.2-371-g6315b36
ParallelChoice.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file ParallelChoice.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/AbstractParallel.h"
18 #include "ram/Choice.h"
19 #include "ram/Condition.h"
20 #include "ram/Node.h"
21 #include "ram/Operation.h"
22 #include "ram/Relation.h"
23 #include "ram/RelationOperation.h"
26 #include <cstddef>
27 #include <iosfwd>
28 #include <memory>
29 #include <ostream>
30 #include <string>
31 #include <utility>
32 
33 namespace souffle::ram {
34 
35 /**
36  * @class ParallelChoice
37  * @brief Find a tuple in a relation such that a given condition holds in parallel.
38  *
39  * For example:
40  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
41  * QUERY
42  * ...
43  * PARALLEL CHOICE t1 IN A WHERE (t1.x, t1.y) NOT IN A
44  * ...
45  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
46  */
47 class ParallelChoice : public Choice, public AbstractParallel {
48 public:
49  ParallelChoice(std::string rel, size_t ident, Own<Condition> cond, Own<Operation> nested,
50  std::string profileText = "")
51  : Choice(rel, ident, std::move(cond), std::move(nested), profileText) {}
52 
53  ParallelChoice* clone() const override {
56  }
57 
58 protected:
59  void print(std::ostream& os, int tabpos) const override {
60  os << times(" ", tabpos);
61  os << "PARALLEL CHOICE t" << getTupleId();
62  os << " IN " << relation;
63  os << " WHERE " << getCondition();
64  os << std::endl;
65  RelationOperation::print(os, tabpos + 1);
66  }
67 };
68 
69 } // namespace souffle::ram
souffle::ram::ParallelChoice::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: ParallelChoice.h:63
souffle::ram::NestedOperation::profileText
const std::string profileText
Text used by the profiler.
Definition: NestedOperation.h:93
souffle::ram::NestedOperation::getOperation
Operation & getOperation() const
Get nested operation.
Definition: NestedOperation.h:62
MiscUtil.h
RelationOperation.h
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::RelationOperation::relation
const std::string relation
Search relation.
Definition: RelationOperation.h:60
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
souffle::ram::NestedOperation::getProfileText
const std::string & getProfileText() const
Get profile text.
Definition: NestedOperation.h:67
Choice.h
Relation.h
Condition.h
souffle::ram::ParallelChoice::clone
ParallelChoice * clone() const override
Create a clone (i.e.
Definition: ParallelChoice.h:57
souffle::ram::TupleOperation::getTupleId
int getTupleId() const
Get identifier.
Definition: TupleOperation.h:43
souffle::ram::Choice
Find a tuple in a relation such that a given condition holds.
Definition: Choice.h:59
souffle::ram::ParallelChoice::ParallelChoice
ParallelChoice(std::string rel, size_t ident, Own< Condition > cond, Own< Operation > nested, std::string profileText="")
Definition: ParallelChoice.h:53
AbstractParallel.h
Node.h
std
Definition: Brie.h:3053
Operation.h
StreamUtil.h
souffle::ram::AbstractChoice::condition
Own< Condition > condition
Condition for which a tuple in the relation may hold.
Definition: AbstractChoice.h:65
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
souffle::ram::AbstractChoice::getCondition
const Condition & getCondition() const
Getter for the condition.
Definition: AbstractChoice.h:45
souffle::ram::NestedOperation::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: NestedOperation.h:80
souffle::ram::ParallelChoice
Find a tuple in a relation such that a given condition holds in parallel.
Definition: ParallelChoice.h:51