souffle  2.0.2-371-g6315b36
Node.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2019, 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 Node.h
12  *
13  * Declares the Interpreter Node class. The interpreter node class
14  * is a compact executable representation of RAM nodes for interpretation.
15  * There are two main reasons for the class:
16  * - node types are exposed in form of enums so that fast switch-statements
17  * can be employed for interpretation (visitor patterns with their
18  * double-dispatch are too slow).
19  * - nodes are decorated with data so that frequent on-the-fly data-structure
20  * lookups are avoided.
21  * Every interpreter node is associated with a unique RAM node.
22  ***********************************************************************/
23 
24 #pragma once
25 
26 #include "interpreter/Util.h"
27 #include "ram/Relation.h"
28 #include "souffle/RamTypes.h"
31 #include <array>
32 #include <cassert>
33 #include <cstddef>
34 #include <memory>
35 #include <string>
36 #include <unordered_map>
37 #include <utility>
38 #include <vector>
39 
40 namespace souffle {
41 namespace ram {
42 class Node;
43 }
44 
45 namespace interpreter {
46 class ViewContext;
47 struct RelationWrapper;
48 
49 // clang-format off
50 
51 /* This macro defines all the interpreterNode token.
52  * For common operation, pass to Forward.
53  * For specialized operation, pass to FOR_EACH(Expand, tok)
54  */
55 #define FOR_EACH_INTERPRETER_TOKEN(Forward, Expand)\
56  Forward(Constant)\
57  Forward(TupleElement)\
58  Forward(AutoIncrement)\
59  Forward(IntrinsicOperator)\
60  Forward(UserDefinedOperator)\
61  Forward(NestedIntrinsicOperator)\
62  Forward(PackRecord)\
63  Forward(SubroutineArgument)\
64  Forward(True)\
65  Forward(False)\
66  Forward(Conjunction)\
67  Forward(Negation)\
68  FOR_EACH(Expand, EmptinessCheck)\
69  FOR_EACH(Expand, RelationSize)\
70  FOR_EACH(Expand, ExistenceCheck)\
71  FOR_EACH_PROVENANCE(Expand, ProvenanceExistenceCheck)\
72  Forward(Constraint)\
73  Forward(TupleOperation)\
74  FOR_EACH(Expand, Scan)\
75  FOR_EACH(Expand, ParallelScan)\
76  FOR_EACH(Expand, IndexScan)\
77  FOR_EACH(Expand, ParallelIndexScan)\
78  FOR_EACH(Expand, Choice)\
79  FOR_EACH(Expand, ParallelChoice)\
80  FOR_EACH(Expand, IndexChoice)\
81  FOR_EACH(Expand, ParallelIndexChoice)\
82  Forward(UnpackRecord)\
83  FOR_EACH(Expand, Aggregate)\
84  FOR_EACH(Expand, ParallelAggregate)\
85  FOR_EACH(Expand, IndexAggregate)\
86  FOR_EACH(Expand, ParallelIndexAggregate)\
87  Forward(Break)\
88  Forward(Filter)\
89  FOR_EACH(Expand, Project)\
90  Forward(SubroutineReturn)\
91  Forward(Sequence)\
92  Forward(Parallel)\
93  Forward(Loop)\
94  Forward(Exit)\
95  Forward(LogRelationTimer)\
96  Forward(LogTimer)\
97  Forward(DebugInfo)\
98  FOR_EACH(Expand, Clear)\
99  Forward(LogSize)\
100  Forward(IO)\
101  Forward(Query)\
102  Forward(Extend)\
103  Forward(Swap)\
104  Forward(Call)
105 
106 #define SINGLE_TOKEN(tok) I_##tok,
107 
108 #define EXPAND_TOKEN(structure, arity, tok)\
109  I_##tok##_##structure##_##arity,
110 
111 /*
112  * Declares all the tokens.
113  * For Forward token OP, creates I_OP
114  * For Extended token OP, generate I_OP_Structure_Arity for each data structure and supported arity.
115  */
116 enum NodeType {
118 };
119 
120 #undef SINGLE_TOKEN
121 #undef EXPAND_TOKEN
122 
123 #define __TO_STRING(a) #a
124 #define SINGLE_TOKEN_ENTRY(tok) {__TO_STRING(I_##tok), I_##tok},
125 #define EXPAND_TOKEN_ENTRY(Structure, arity, tok) \
126  {__TO_STRING(I_##tok##_##Structure##_##arity), I_##tok##_##Structure##_##arity},
127 
128 /**
129  * Construct interpreterNodeType by looking at the representation and the arity of the given rel.
130  *
131  * Add reflective from string to NodeType.
132  */
133 inline NodeType constructNodeType(std::string tokBase, const ram::Relation& rel) {
134  static bool isProvenance = Global::config().has("provenance");
135 
136  static const std::unordered_map<std::string, NodeType> map = {
138  };
139 
140  std::string arity = std::to_string(rel.getArity());
141  if (rel.getRepresentation() == RelationRepresentation::EQREL) {
142  return map.at("I_" + tokBase + "_Eqrel_" + arity);
143  } else if (isProvenance) {
144  return map.at("I_" + tokBase + "_Provenance_" + arity);
145  } else {
146  return map.at("I_" + tokBase + "_Btree_" + arity);
147  }
148 
149  fatal("Unrecognized node type: base:%s arity:%s.", tokBase, arity);
150 }
151 
152 #undef __TO_STRING
153 #undef EXPAND_TOKEN_ENTRY
154 #undef SINGLE_TOKEN_ENTRY
155 
156 // clang-format on
157 
158 /**
159  * @class Node
160  * @brief This is a shadow node for a ram::Node that is enriched for
161  * with local information so that the interpreter is executing
162  * quickly.
163  */
164 
165 class Node {
166 public:
167  using RelationHandle = Own<RelationWrapper>;
168 
169  Node(enum NodeType ty, const ram::Node* sdw, RelationHandle* relHandle = nullptr)
170  : type(ty), shadow(sdw), relHandle(relHandle) {}
171  virtual ~Node() = default;
172 
173  /** @brief get node type */
174  inline enum NodeType getType() const {
175  return type;
176  }
177 
178  /** @brief get shadow node, i.e., RAM node */
179  inline const ram::Node* getShadow() const {
180  return shadow;
181  }
182 
183  /** @brief get relation from handle */
184  RelationWrapper* getRelation() const {
185  assert(relHandle && "No relation cached\n");
186  return (*relHandle).get();
187  }
188 
189 protected:
190  enum NodeType type;
191  const ram::Node* shadow;
193 };
194 
195 /**
196  * @class CompoundNode
197  * @brief Compound node represents interpreter node with a list of children.
198  */
199 class CompoundNode : public Node {
200  using NodePtrVec = VecOwn<Node>;
201 
202 public:
203  CompoundNode(enum NodeType ty, const ram::Node* sdw, NodePtrVec children = {},
205  : Node(ty, sdw, relHandle), children(std::move(children)) {}
206 
207  /** @brief get children of node */
208  inline const Node* getChild(size_t i) const {
209  return children[i].get();
210  }
211 
212  /** @brief get list of all children */
213  const NodePtrVec& getChildren() const {
214  return children;
215  }
216 
217 protected:
219 };
220 
221 /**
222  * @class UnaryNode
223  * @brief Unary node represents interpreter node with a single child
224  */
225 class UnaryNode : public Node {
226 public:
227  UnaryNode(enum NodeType ty, const ram::Node* sdw, Own<Node> child, RelationHandle* relHandle = nullptr)
228  : Node(ty, sdw, relHandle), child(std::move(child)) {}
229 
230  inline const Node* getChild() const {
231  return child.get();
232  }
233 
234 protected:
236 };
237 
238 /**
239  * @class BinaryNode
240  * @brief Binary node represents interpreter node with two children.
241  */
242 class BinaryNode : public Node {
243 public:
244  BinaryNode(enum NodeType ty, const ram::Node* sdw, Own<Node> lhs, Own<Node> rhs,
245  RelationHandle* relHandle = nullptr)
246  : Node(ty, sdw, relHandle), lhs(std::move(lhs)), rhs(std::move(rhs)) {}
247 
248  /** @brief get left child of node */
249  inline const Node* getLhs() const {
250  return lhs.get();
251  }
252 
253  /** @brief get right child of node */
254  inline const Node* getRhs() const {
255  return rhs.get();
256  }
257 
258 protected:
259  Own<Node> lhs;
260  Own<Node> rhs;
261 };
262 
263 /**
264  * @class SuperInstruction
265  * @brief This class encodes information for a super-instruction, which is
266  * used to eliminate Number and TupleElement in index/project/existence operation.
267  */
268 class SuperInstruction {
269 public:
270  SuperInstruction(size_t i) {
271  first.resize(i);
272  second.resize(i);
273  }
274 
275  SuperInstruction(const SuperInstruction&) = delete;
276  SuperInstruction& operator=(const SuperInstruction&) = delete;
277  SuperInstruction(SuperInstruction&&) = default;
278 
279  /** @brief constant value in the lower bound/pattern */
280  std::vector<RamDomain> first;
281  /** @brief constant value in the upper bound */
282  std::vector<RamDomain> second;
283  /** @brief Encoded tupleElement expressions in the lower bound/pattern */
284  std::vector<std::array<size_t, 3>> tupleFirst;
285  /** @brief Encoded tupleElement expressions in the upper bound */
286  std::vector<std::array<size_t, 3>> tupleSecond;
287  /** @brief Generic expressions in the lower bound/pattern */
288  std::vector<std::pair<size_t, Own<Node>>> exprFirst;
289  /** @brief Generic expressions in the upper bound */
290  std::vector<std::pair<size_t, Own<Node>>> exprSecond;
291 };
292 
293 /**
294  * @class SuperOperation
295  * @brief node that utilizes the super instruction optimization should
296  * inherit from this class. E.g. ExistenceCheck, Project
297  */
298 class SuperOperation {
299 public:
301 
302  const SuperInstruction& getSuperInst() const {
303  return superInst;
304  }
305 
306 protected:
308 };
309 
310 /**
311  * @class AbstractParallel
312  * @brief node that utilizes parallel execution should inherit from this class.
313  * Enable node with its own view context for parallel execution.
314  */
316 public:
317  /** @brief get view context for operations */
318  inline ViewContext* getViewContext() const {
319  return viewContext.get();
320  }
321 
322  /** @brief set view context */
323  inline void setViewContext(const std::shared_ptr<ViewContext>& v) {
324  viewContext = v;
325  }
326 
327 protected:
328  std::shared_ptr<ViewContext> viewContext = nullptr;
329 };
330 
331 /**
332  * @class ViewOperation
333  * @brief operation that utilizes the index view from underlying relation should inherit from this
334  * class.
335  */
337 public:
338  ViewOperation(size_t id) : viewId(id) {}
339 
340  inline size_t getViewId() const {
341  return viewId;
342  }
343 
344 protected:
345  size_t viewId;
346 };
347 
348 /**
349  * @class BinRelOperation
350  * @brief operation that involves with two relations should inherit from this class.
351  * E.g. Swap, Extend
352  */
354 public:
355  BinRelOperation(size_t src, size_t target) : src(src), target(target) {}
356 
357  inline size_t getSourceId() const {
358  return src;
359  }
360 
361  inline size_t getTargetId() const {
362  return target;
363  }
364 
365 protected:
366  const size_t src;
367  const size_t target;
368 };
369 
370 /**
371  * @class NestedOperation
372  * @brief Encode a nested operation for the interpreter node. E.g. Loop, IndexScan
373  */
375 public:
376  NestedOperation(Own<Node> nested) : nested(std::move(nested)) {}
377 
378  inline const Node* getNestedOperation() const {
379  return nested.get();
380  };
381 
382 protected:
384 };
385 
386 /**
387  * @class ConditionalOperation
388  * @brief Encode a conditional operation for the interpreter node. E.g. Exit, Filter
389  */
390 class ConditionalOperation {
391 public:
393 
394  inline const Node* getCondition() const {
395  return cond.get();
396  };
397 
398 protected:
399  Own<Node> cond;
400 };
401 
402 /**
403  * @class Constant
404  */
405 class Constant : public Node {
406  using Node::Node;
407 };
408 
409 /**
410  * @class TupleElement
411  */
412 class TupleElement : public Node {
413 public:
414  TupleElement(enum NodeType ty, const ram::Node* sdw, size_t tupleId, size_t elementId)
415  : Node(ty, sdw), tupleId(tupleId), element(elementId) {}
416 
417  size_t getTupleId() const {
418  return tupleId;
419  }
420 
421  size_t getElement() const {
422  return element;
423  }
424 
425 private:
426  size_t tupleId;
427  size_t element;
428 };
429 
430 /**
431  * @class AutoIncrement
432  */
433 class AutoIncrement : public Node {
434  using Node::Node;
435 };
436 
437 /**
438  * @class IntrinsicOperator
439  */
442 };
443 
444 /**
445  * @class UserDefinedOperator
446  */
447 class UserDefinedOperator : public CompoundNode {
449 };
450 
451 /**
452  * @class NestedIntrinsicOperator
453  */
454 class NestedIntrinsicOperator : public CompoundNode {
456 };
457 
458 /**
459  * @class PackRecord
460  */
461 class PackRecord : public CompoundNode {
463 };
464 
465 /**
466  * @class SubroutineArgument
467  */
468 class SubroutineArgument : public Node {
469  using Node::Node;
470 };
471 
472 /**
473  * @class True
474  */
475 class True : public Node {
476  using Node::Node;
477 };
478 
479 /**
480  * @class False
481  */
482 class False : public Node {
483  using Node::Node;
484 };
485 
486 /**
487  * @class Conjunction
488  */
489 class Conjunction : public BinaryNode {
491 };
492 
493 /**
494  * @class Negation
495  */
496 class Negation : public UnaryNode {
497  using UnaryNode::UnaryNode;
498 };
499 
500 /**
501  * @class EmptinessCheck
502  */
503 class EmptinessCheck : public Node {
504  using Node::Node;
505 };
506 
507 /**
508  * @class RelationSize
509  */
510 class RelationSize : public Node {
511  using Node::Node;
512 };
513 
514 /**
515  * @class ExistenceCheck
516  */
517 class ExistenceCheck : public Node, public SuperOperation, public ViewOperation {
518 public:
519  ExistenceCheck(enum NodeType ty, const ram::Node* sdw, bool totalSearch, size_t viewId,
521  : Node(ty, sdw), SuperOperation(std::move(superInst)), ViewOperation(viewId),
523 
524  bool isTotalSearch() const {
525  return totalSearch;
526  }
527 
528  bool isTemp() const {
529  return tempRelation;
530  }
531 
532  const std::string& getRelationName() const {
533  return relationName;
534  }
535 
536 private:
537  const bool totalSearch;
538  const bool tempRelation;
539  const std::string relationName;
540 };
541 
542 /**
543  * @class ProvenanceExistenceCheck
544  */
546 public:
547  ProvenanceExistenceCheck(enum NodeType ty, const ram::Node* sdw, Own<Node> child, size_t viewId,
549  : UnaryNode(ty, sdw, std::move(child)), SuperOperation(std::move(superInst)),
551 };
552 
553 /**
554  * @class Constraint
555  */
556 class Constraint : public BinaryNode {
558 };
559 
560 /**
561  * @class TupleOperation
562  */
563 class TupleOperation : public UnaryNode {
564  using UnaryNode::UnaryNode;
565 };
566 
567 /**
568  * @class Scan
569  */
570 class Scan : public Node, public NestedOperation {
571 public:
573  : Node(ty, sdw, relHandle), NestedOperation(std::move(nested)) {}
574 };
575 
576 /**
577  * @class ParallelScan
578  */
579 class ParallelScan : public Scan, public AbstractParallel {
580  using Scan::Scan;
581 };
582 
583 /**
584  * @class IndexScan
585  */
586 class IndexScan : public Scan, public SuperOperation, public ViewOperation {
587 public:
590  : Scan(ty, sdw, relHandle, std::move(nested)), SuperOperation(std::move(superInst)),
592 };
593 
594 /**
595  * @class ParallelIndexScan
596  */
597 class ParallelIndexScan : public IndexScan, public AbstractParallel {
598 public:
600 };
601 
602 /**
603  * @class Choice
604  */
605 class Choice : public Node, public ConditionalOperation, public NestedOperation {
606 public:
609  : Node(ty, sdw, relHandle), ConditionalOperation(std::move(cond)),
610  NestedOperation(std::move(nested)) {}
611 };
612 
613 /**
614  * @class ParallelChoice
615  */
616 class ParallelChoice : public Choice, public AbstractParallel {
617  using Choice::Choice;
618 };
619 
620 /**
621  * @class IndexChoice
622  */
623 class IndexChoice : public Choice, public SuperOperation, public ViewOperation {
624 public:
627  : Choice(ty, sdw, relHandle, std::move(cond), std::move(nested)),
629 };
630 
631 /**
632  * @class ParallelIndexChoice
633  */
634 class ParallelIndexChoice : public IndexChoice, public AbstractParallel {
636 };
637 
638 /**
639  * @class UnpackRecord
640  */
641 class UnpackRecord : public Node, public NestedOperation {
642 public:
644  : Node(ty, sdw), NestedOperation(std::move(nested)), expr(std::move(expr)) {}
645 
646  inline const Node* getExpr() const {
647  return expr.get();
648  }
649 
650 protected:
651  Own<Node> expr;
652 };
653 
654 /**
655  * @class Aggregate
656  */
657 class Aggregate : public Node, public ConditionalOperation, public NestedOperation {
658 public:
661  : Node(ty, sdw, relHandle), ConditionalOperation(std::move(filter)),
662  NestedOperation(std::move(nested)), expr(std::move(expr)) {}
663 
664  inline const Node* getExpr() const {
665  return expr.get();
666  }
667 
668 protected:
669  Own<Node> expr;
670 };
671 
672 /**
673  * @class ParallelAggregate
674  */
675 class ParallelAggregate : public Aggregate, public AbstractParallel {
676  using Aggregate::Aggregate;
677 };
678 
679 /**
680  * @class IndexAggregate
681  */
682 class IndexAggregate : public Aggregate, public SuperOperation, public ViewOperation {
683 public:
686  : Aggregate(ty, sdw, relHandle, std::move(expr), std::move(filter), std::move(nested)),
688 };
689 
690 /**
691  * @class ParallelIndexAggregate
692  */
695 };
696 
697 /**
698  * @class Break
699  */
700 class Break : public Node, public ConditionalOperation, public NestedOperation {
701 public:
702  Break(enum NodeType ty, const ram::Node* sdw, Own<Node> cond, Own<Node> nested)
703  : Node(ty, sdw, nullptr), ConditionalOperation(std::move(cond)),
704  NestedOperation(std::move(nested)) {}
705 };
706 
707 /**
708  * @class Filter
709  */
710 class Filter : public Node, public ConditionalOperation, public NestedOperation {
711 public:
712  Filter(enum NodeType ty, const ram::Node* sdw, Own<Node> cond, Own<Node> nested)
713  : Node(ty, sdw, nullptr), ConditionalOperation(std::move(cond)),
714  NestedOperation(std::move(nested)) {}
715 };
716 
717 /**
718  * @class Project
719  */
720 class Project : public Node, public SuperOperation {
721 public:
723  : Node(ty, sdw, relHandle), SuperOperation(std::move(superInst)) {}
724 };
725 
726 /**
727  * @class SubroutineReturn
728  */
729 class SubroutineReturn : public CompoundNode {
731 };
732 
733 /**
734  * @class Sequence
735  */
736 class Sequence : public CompoundNode {
738 };
739 
740 /**
741  * @class Parallel
742  */
743 class Parallel : public CompoundNode {
745 };
746 
747 /**
748  * @class Loop
749  */
750 class Loop : public UnaryNode {
751  using UnaryNode::UnaryNode;
752 };
753 
754 /**
755  * @class Exit
756  */
757 class Exit : public UnaryNode {
758  using UnaryNode::UnaryNode;
759 };
760 
761 /**
762  * @class LogRelationTimer
763  */
764 class LogRelationTimer : public UnaryNode {
765  using UnaryNode::UnaryNode;
766 };
767 
768 /**
769  * @class LogTimer
770  */
771 class LogTimer : public UnaryNode {
772  using UnaryNode::UnaryNode;
773 };
774 
775 /**
776  * @class DebugInfo
777  */
778 class DebugInfo : public UnaryNode {
779  using UnaryNode::UnaryNode;
780 };
781 
782 /**
783  * @class Clear
784  */
785 class Clear : public Node {
786  using Node::Node;
787 };
788 
789 /**
790  * @class Call
791  */
792 class Call : public Node {
793 public:
794  Call(enum NodeType ty, const ram::Node* sdw, size_t subroutineId)
795  : Node(ty, sdw), subroutineId(subroutineId) {}
796 
797  size_t getSubroutineId() const {
798  return subroutineId;
799  }
800 
801 private:
802  const size_t subroutineId;
803 };
804 
805 /**
806  * @class LogSize
807  */
808 class LogSize : public Node {
809  using Node::Node;
810 };
811 
812 /**
813  * @class IO
814  */
815 class IO : public Node {
816  using Node::Node;
817 };
818 
819 /**
820  * @class Query
821  */
822 class Query : public UnaryNode, public AbstractParallel {
823  using UnaryNode::UnaryNode;
824 };
825 
826 /**
827  * @class Extend
828  */
829 class Extend : public Node, public BinRelOperation {
830 public:
831  Extend(enum NodeType ty, const ram::Node* sdw, size_t src, size_t target)
832  : Node(ty, sdw), BinRelOperation(src, target) {}
833 };
834 
835 /**
836  * @class Swap
837  */
838 class Swap : public Node, public BinRelOperation {
839 public:
840  Swap(enum NodeType ty, const ram::Node* sdw, size_t src, size_t target)
841  : Node(ty, sdw), BinRelOperation(src, target) {}
842 };
843 
844 } // namespace interpreter
845 } // namespace souffle
souffle::interpreter::Break
Definition: Node.h:713
souffle::interpreter::Scan
Definition: Node.h:583
souffle::interpreter::CompoundNode::getChildren
const NodePtrVec & getChildren() const
get list of all children
Definition: Node.h:226
souffle::interpreter::Call::Call
Call(enum NodeType ty, const ram::Node *sdw, size_t subroutineId)
Definition: Node.h:807
souffle::interpreter::Negation
Definition: Node.h:509
souffle::interpreter::SuperOperation::SuperOperation
SuperOperation(SuperInstruction superInst)
Definition: Node.h:313
souffle::interpreter::IndexChoice
Definition: Node.h:636
souffle::interpreter::SuperInstruction::second
std::vector< RamDomain > second
constant value in the upper bound
Definition: Node.h:295
souffle::interpreter::LogSize
Definition: Node.h:821
souffle::interpreter::UnpackRecord
Definition: Node.h:654
souffle::interpreter::RelationSize
Definition: Node.h:523
souffle::interpreter::IndexScan
Definition: Node.h:599
souffle::interpreter::UnaryNode::child
Own< Node > child
Definition: Node.h:248
souffle::interpreter::ExistenceCheck::getRelationName
const std::string & getRelationName() const
Definition: Node.h:545
souffle::interpreter::ConditionalOperation::cond
Own< Node > cond
Definition: Node.h:409
souffle::interpreter::AbstractParallel
node that utilizes parallel execution should inherit from this class. Enable node with its own view c...
Definition: Node.h:328
souffle::interpreter::IndexAggregate
Definition: Node.h:695
souffle::interpreter::LogTimer
Definition: Node.h:784
souffle::RelationRepresentation::EQREL
@ EQREL
souffle::interpreter::NestedOperation
Encode a nested operation for the interpreter node. E.g. Loop, IndexScan.
Definition: Node.h:387
souffle::interpreter::ViewOperation::getViewId
size_t getViewId() const
Definition: Node.h:353
souffle::interpreter::SuperInstruction::SuperInstruction
SuperInstruction(size_t i)
Definition: Node.h:283
souffle::interpreter::Node
This is a shadow node for a ram::Node that is enriched for with local information so that the interpr...
Definition: Node.h:178
souffle::interpreter::TupleElement
Definition: Node.h:425
souffle::interpreter::Node::getType
enum NodeType getType() const
get node type
Definition: Node.h:187
souffle::interpreter::ParallelIndexScan
Definition: Node.h:610
souffle::interpreter::Node::~Node
virtual ~Node()=default
souffle::interpreter::Loop
Definition: Node.h:763
souffle::interpreter::NestedOperation::getNestedOperation
const Node * getNestedOperation() const
Definition: Node.h:391
souffle::interpreter::SubroutineArgument
Definition: Node.h:481
souffle::interpreter::SubroutineReturn
Definition: Node.h:742
souffle::interpreter::Aggregate::getExpr
const Node * getExpr() const
Definition: Node.h:677
souffle::interpreter::TupleElement::tupleId
size_t tupleId
Definition: Node.h:439
souffle::interpreter::ParallelScan
Definition: Node.h:592
souffle::Own
std::unique_ptr< A > Own
Definition: ContainerUtil.h:42
souffle::interpreter::ConditionalOperation::getCondition
const Node * getCondition() const
Definition: Node.h:407
souffle::interpreter::Choice
Definition: Node.h:618
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
MiscUtil.h
souffle::interpreter::Constraint
Definition: Node.h:569
souffle::interpreter::BinaryNode::lhs
Own< Node > lhs
Definition: Node.h:272
souffle::interpreter::IO
Definition: Node.h:828
souffle::interpreter::BinaryNode::getRhs
const Node * getRhs() const
get right child of node
Definition: Node.h:267
souffle::interpreter::Aggregate::Aggregate
Aggregate(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, Own< Node > expr, Own< Node > filter, Own< Node > nested)
Definition: Node.h:672
souffle::interpreter::Extend::Extend
Extend(enum NodeType ty, const ram::Node *sdw, size_t src, size_t target)
Definition: Node.h:844
souffle::interpreter::NestedOperation::nested
Own< Node > nested
Definition: Node.h:393
souffle::interpreter::Extend
Definition: Node.h:842
souffle::interpreter::Filter::Filter
Filter(enum NodeType ty, const ram::Node *sdw, Own< Node > cond, Own< Node > nested)
Definition: Node.h:725
souffle::interpreter::TupleElement::element
size_t element
Definition: Node.h:440
souffle::interpreter::ExistenceCheck::relationName
const std::string relationName
Definition: Node.h:552
souffle::interpreter::TupleElement::getTupleId
size_t getTupleId() const
Definition: Node.h:430
souffle::interpreter::ViewContext
This class contains information for views (Hints) creation for ram::Query and ram::Parallel operation...
Definition: ViewContext.h:39
souffle::interpreter::UnpackRecord::expr
Own< Node > expr
Definition: Node.h:664
souffle::interpreter::NestedIntrinsicOperator
Definition: Node.h:467
souffle::interpreter::SuperInstruction::first
std::vector< RamDomain > first
constant value in the lower bound/pattern
Definition: Node.h:293
souffle::interpreter::False
Definition: Node.h:495
souffle::interpreter::UnpackRecord::getExpr
const Node * getExpr() const
Definition: Node.h:659
souffle::interpreter::IntrinsicOperator
Definition: Node.h:453
souffle::interpreter::ConditionalOperation
Encode a conditional operation for the interpreter node. E.g. Exit, Filter.
Definition: Node.h:403
souffle::interpreter::SuperOperation
node that utilizes the super instruction optimization should inherit from this class....
Definition: Node.h:311
souffle::interpreter::SuperInstruction::tupleFirst
std::vector< std::array< size_t, 3 > > tupleFirst
Encoded tupleElement expressions in the lower bound/pattern.
Definition: Node.h:297
souffle::interpreter::ViewOperation::ViewOperation
ViewOperation(size_t id)
Definition: Node.h:351
souffle::interpreter::CompoundNode::CompoundNode
CompoundNode(enum NodeType ty, const ram::Node *sdw, NodePtrVec children={}, RelationHandle *relHandle=nullptr)
Definition: Node.h:216
souffle::interpreter::Node::relHandle
RelationHandle *const relHandle
Definition: Node.h:205
souffle::interpreter::Filter
Definition: Node.h:723
souffle::interpreter::UserDefinedOperator
Definition: Node.h:460
souffle::interpreter::NodeType
NodeType
Definition: Node.h:129
souffle::interpreter::Node::shadow
const ram::Node * shadow
Definition: Node.h:204
souffle::ram::Node
Node is a superclass for all RAM IR classes.
Definition: Node.h:42
souffle::interpreter::Node::Node
Node(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle=nullptr)
Definition: Node.h:182
souffle::interpreter::Node::type
enum NodeType type
Definition: Node.h:203
souffle::interpreter::ParallelIndexChoice
Definition: Node.h:647
souffle::interpreter::ParallelIndexAggregate
Definition: Node.h:706
souffle::interpreter::AbstractParallel::getViewContext
ViewContext * getViewContext() const
get view context for operations
Definition: Node.h:331
souffle::interpreter::TupleElement::getElement
size_t getElement() const
Definition: Node.h:434
i
size_t i
Definition: json11.h:663
souffle::filter
std::vector< A > filter(std::vector< A > xs, F &&f)
Filter a vector to include certain elements.
Definition: FunctionalUtil.h:155
ContainerUtil.h
souffle::interpreter::SuperInstruction::exprSecond
std::vector< std::pair< size_t, Own< Node > > > exprSecond
Generic expressions in the upper bound.
Definition: Node.h:303
souffle::interpreter::RelationHandle
Own< RelationWrapper > RelationHandle
Definition: Generator.cpp:28
souffle::interpreter::IndexAggregate::IndexAggregate
IndexAggregate(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, Own< Node > expr, Own< Node > filter, Own< Node > nested, size_t viewId, SuperInstruction superInst)
Definition: Node.h:697
souffle::interpreter::Call::subroutineId
const size_t subroutineId
Definition: Node.h:815
souffle::ram::Relation
An abstract class for performing indexed operations.
Definition: Relation.h:40
souffle::interpreter::TupleElement::TupleElement
TupleElement(enum NodeType ty, const ram::Node *sdw, size_t tupleId, size_t elementId)
Definition: Node.h:427
souffle::interpreter::NestedOperation::NestedOperation
NestedOperation(Own< Node > nested)
Definition: Node.h:389
Relation.h
souffle::interpreter::ProvenanceExistenceCheck
Definition: Node.h:558
souffle::interpreter::CompoundNode::children
NodePtrVec children
Definition: Node.h:231
souffle::interpreter::IndexScan::IndexScan
IndexScan(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, Own< Node > nested, size_t viewId, SuperInstruction superInst)
Definition: Node.h:601
souffle::interpreter::ExistenceCheck::ExistenceCheck
ExistenceCheck(enum NodeType ty, const ram::Node *sdw, bool totalSearch, size_t viewId, SuperInstruction superInst, bool tempRelation, std::string relationName)
Definition: Node.h:532
souffle::interpreter::Project
Definition: Node.h:733
souffle::interpreter::SuperInstruction::tupleSecond
std::vector< std::array< size_t, 3 > > tupleSecond
Encoded tupleElement expressions in the upper bound.
Definition: Node.h:299
souffle::interpreter::SuperInstruction::operator=
SuperInstruction & operator=(const SuperInstruction &)=delete
souffle::interpreter::UnaryNode
Unary node represents interpreter node with a single child.
Definition: Node.h:238
souffle::interpreter::LogRelationTimer
Definition: Node.h:777
souffle::interpreter::BinRelOperation::src
const size_t src
Definition: Node.h:379
souffle::interpreter::AbstractParallel::setViewContext
void setViewContext(const std::shared_ptr< ViewContext > &v)
set view context
Definition: Node.h:336
souffle::interpreter::ViewOperation::viewId
size_t viewId
Definition: Node.h:358
souffle::interpreter::IndexChoice::IndexChoice
IndexChoice(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, Own< Node > cond, Own< Node > nested, size_t viewId, SuperInstruction superInst)
Definition: Node.h:638
souffle::interpreter::UnpackRecord::UnpackRecord
UnpackRecord(enum NodeType ty, const ram::Node *sdw, Own< Node > expr, Own< Node > nested)
Definition: Node.h:656
SINGLE_TOKEN
#define SINGLE_TOKEN(tok)
Definition: Node.h:119
souffle::interpreter::Node::getShadow
const ram::Node * getShadow() const
get shadow node, i.e., RAM node
Definition: Node.h:192
souffle::interpreter::Query
Definition: Node.h:835
souffle::interpreter::SuperInstruction::exprFirst
std::vector< std::pair< size_t, Own< Node > > > exprFirst
Generic expressions in the lower bound/pattern.
Definition: Node.h:301
souffle::interpreter::BinaryNode::rhs
Own< Node > rhs
Definition: Node.h:273
souffle::interpreter::ExistenceCheck::totalSearch
const bool totalSearch
Definition: Node.h:550
souffle::interpreter::BinRelOperation::getSourceId
size_t getSourceId() const
Definition: Node.h:370
souffle::interpreter::ExistenceCheck::isTemp
bool isTemp() const
Definition: Node.h:541
souffle::interpreter::constructNodeType
NodeType constructNodeType(std::string tokBase, const ram::Relation &rel)
Construct interpreterNodeType by looking at the representation and the arity of the given rel.
Definition: Node.h:146
souffle::interpreter::Parallel
Definition: Node.h:756
souffle::interpreter::SuperInstruction
This class encodes information for a super-instruction, which is used to eliminate Number and TupleEl...
Definition: Node.h:281
souffle::interpreter::CompoundNode::NodePtrVec
VecOwn< Node > NodePtrVec
Definition: Node.h:213
souffle::Global::config
static MainConfig & config()
Definition: Global.h:141
FOR_EACH_INTERPRETER_TOKEN
#define FOR_EACH_INTERPRETER_TOKEN(Forward, Expand)
Definition: Node.h:68
souffle::interpreter::PackRecord
Definition: Node.h:474
souffle::interpreter::Project::Project
Project(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, SuperInstruction superInst)
Definition: Node.h:735
souffle::interpreter::True
Definition: Node.h:488
souffle::interpreter::Break::Break
Break(enum NodeType ty, const ram::Node *sdw, Own< Node > cond, Own< Node > nested)
Definition: Node.h:715
souffle::interpreter::BinRelOperation::getTargetId
size_t getTargetId() const
Definition: Node.h:374
souffle::interpreter::ExistenceCheck::tempRelation
const bool tempRelation
Definition: Node.h:551
souffle::interpreter::DebugInfo
Definition: Node.h:791
std
Definition: Brie.h:3053
souffle::interpreter::ParallelAggregate
Definition: Node.h:688
souffle::interpreter::Aggregate
Definition: Node.h:670
souffle::interpreter::AbstractParallel::viewContext
std::shared_ptr< ViewContext > viewContext
Definition: Node.h:341
souffle::interpreter::BinRelOperation::target
const size_t target
Definition: Node.h:380
souffle::interpreter::Node::RelationHandle
Own< RelationWrapper > RelationHandle
Definition: Node.h:180
RamTypes.h
SINGLE_TOKEN_ENTRY
#define SINGLE_TOKEN_ENTRY(tok)
Definition: Node.h:137
souffle::interpreter::EmptinessCheck
Definition: Node.h:516
EXPAND_TOKEN_ENTRY
#define EXPAND_TOKEN_ENTRY(Structure, arity, tok)
Definition: Node.h:138
souffle::fatal
void fatal(const char *format, const Args &... args)
Definition: MiscUtil.h:198
souffle::interpreter::UnaryNode::UnaryNode
UnaryNode(enum NodeType ty, const ram::Node *sdw, Own< Node > child, RelationHandle *relHandle=nullptr)
Definition: Node.h:240
souffle::interpreter::ExistenceCheck
Definition: Node.h:530
souffle::interpreter::Exit
Definition: Node.h:770
souffle::interpreter::CompoundNode
Compound node represents interpreter node with a list of children.
Definition: Node.h:212
souffle::interpreter::Aggregate::expr
Own< Node > expr
Definition: Node.h:682
souffle::interpreter::Clear
Definition: Node.h:798
souffle::interpreter::Call
Definition: Node.h:805
souffle
Definition: AggregateOp.h:25
souffle::interpreter::ViewOperation
operation that utilizes the index view from underlying relation should inherit from this class.
Definition: Node.h:349
souffle::interpreter::SuperOperation::getSuperInst
const SuperInstruction & getSuperInst() const
Definition: Node.h:315
souffle::interpreter::RelationWrapper
Wrapper for InterpreterRelation.
Definition: Relation.h:48
souffle::interpreter::BinaryNode::getLhs
const Node * getLhs() const
get left child of node
Definition: Node.h:262
souffle::interpreter::CompoundNode::getChild
const Node * getChild(size_t i) const
get children of node
Definition: Node.h:221
Util.h
souffle::interpreter::TupleOperation
Definition: Node.h:576
souffle::interpreter::AutoIncrement
Definition: Node.h:446
souffle::interpreter::Call::getSubroutineId
size_t getSubroutineId() const
Definition: Node.h:810
souffle::interpreter::BinRelOperation
operation that involves with two relations should inherit from this class. E.g. Swap,...
Definition: Node.h:366
souffle::interpreter::ConditionalOperation::ConditionalOperation
ConditionalOperation(Own< Node > cond)
Definition: Node.h:405
souffle::interpreter::BinaryNode::BinaryNode
BinaryNode(enum NodeType ty, const ram::Node *sdw, Own< Node > lhs, Own< Node > rhs, RelationHandle *relHandle=nullptr)
Definition: Node.h:257
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
souffle::interpreter::Choice::Choice
Choice(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, Own< Node > cond, Own< Node > nested)
Definition: Node.h:620
EXPAND_TOKEN
#define EXPAND_TOKEN(structure, arity, tok)
Definition: Node.h:121
souffle::interpreter::NodePtrVec
std::vector< NodePtr > NodePtrVec
Definition: Generator.cpp:27
souffle::interpreter::Node::getRelation
RelationWrapper * getRelation() const
get relation from handle
Definition: Node.h:197
souffle::interpreter::UnaryNode::getChild
const Node * getChild() const
Definition: Node.h:243
souffle::interpreter::ExistenceCheck::isTotalSearch
bool isTotalSearch() const
Definition: Node.h:537
souffle::VecOwn
std::vector< Own< A > > VecOwn
Definition: ContainerUtil.h:45
souffle::interpreter::Swap::Swap
Swap(enum NodeType ty, const ram::Node *sdw, size_t src, size_t target)
Definition: Node.h:853
souffle::interpreter::Conjunction
Definition: Node.h:502
souffle::interpreter::Constant
Definition: Node.h:418
souffle::interpreter::ProvenanceExistenceCheck::ProvenanceExistenceCheck
ProvenanceExistenceCheck(enum NodeType ty, const ram::Node *sdw, Own< Node > child, size_t viewId, SuperInstruction superInst)
Definition: Node.h:560
souffle::interpreter::Scan::Scan
Scan(enum NodeType ty, const ram::Node *sdw, RelationHandle *relHandle, Own< Node > nested)
Definition: Node.h:585
souffle::interpreter::SuperOperation::superInst
const SuperInstruction superInst
Definition: Node.h:320
souffle::interpreter::Sequence
Definition: Node.h:749
souffle::interpreter::Swap
Definition: Node.h:851
souffle::interpreter::BinaryNode
Binary node represents interpreter node with two children.
Definition: Node.h:255
souffle::interpreter::BinRelOperation::BinRelOperation
BinRelOperation(size_t src, size_t target)
Definition: Node.h:368