souffle  2.0.2-371-g6315b36
ViewContext.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 ViewContext.h
12  *
13  * Declares the ViewContext class.
14  * Each Query operation has an ViewContext assoicated with it.
15  * The view context contains information about views creation during execution.
16  ***********************************************************************/
17 
18 #pragma once
19 
20 #include "interpreter/Node.h"
21 #include <array>
22 #include <memory>
23 #include <vector>
24 
25 namespace souffle::interpreter {
26 
27 /**
28  * @class ViewContext
29  * @brief This class contains information for views (Hints) creation for ram::Query and ram::Parallel
30  * operation.
31  */
32 class ViewContext {
33 public:
34  /** @brief Add outer-most filter operation which requires a view. */
35  void addViewOperationForFilter(Own<Node> node) {
36  outerFilterViewOps.push_back(std::move(node));
37  }
38 
39  /** @brief Add outer-most filter operation which does not require a view. */
41  outerFilterViewFreeOps.push_back(std::move(node));
42  }
43 
44  /** @brief Add nested operation which require a View (Hints). */
46  nestedViewOps.push_back(std::move(op));
47  }
48 
49  /** @brief Return outer-most filter operations. */
51  return outerFilterViewOps;
52  }
53 
54  /** @brief Return views for outer-most filter operations. */
57  }
58 
59  /** @brief Return nested operations */
61  return nestedViewOps;
62  }
63 
64  /** @brief Return Views information for outer filter operation */
65  std::vector<std::array<size_t, 3>>& getViewInfoForFilter() {
66  return viewInfoForFilter;
67  }
68 
69  /** @brief Return Views information for nested operation */
70  std::vector<std::array<size_t, 3>>& getViewInfoForNested() {
71  return viewInfoForNested;
72  }
73 
74  /** @brief Add View creation information into the list for outer filter. */
75  void addViewInfoForFilter(size_t relId, size_t indexPos, size_t viewPos) {
76  viewInfoForFilter.push_back({relId, indexPos, viewPos});
77  }
78 
79  /** @brief Add View creation information into the list for nested oprations. */
80  void addViewInfoForNested(size_t relId, size_t indexPos, size_t viewPos) {
81  viewInfoForNested.push_back({relId, indexPos, viewPos});
82  }
83 
84  /** If this context has information for parallel operation. */
85  bool isParallel = false;
86 
87 private:
88  /** Vector of filter operation, views required */
90  /** Vector of filter operations, no views required. */
92  /** Vector of nested operations */
94  /** Vector of View information in filter operations */
95  std::vector<std::array<size_t, 3>> viewInfoForFilter;
96  /** Vector of View information in nested operations */
97  std::vector<std::array<size_t, 3>> viewInfoForNested;
98 };
99 
100 } // namespace souffle::interpreter
Node.h
souffle::interpreter::ViewContext::outerFilterViewOps
VecOwn< Node > outerFilterViewOps
Vector of filter operation, views required.
Definition: ViewContext.h:96
souffle::Own
std::unique_ptr< A > Own
Definition: ContainerUtil.h:42
souffle::interpreter::ViewContext::viewInfoForFilter
std::vector< std::array< size_t, 3 > > viewInfoForFilter
Vector of View information in filter operations.
Definition: ViewContext.h:102
souffle::interpreter::ViewContext::getOuterFilterViewFreeOps
const VecOwn< Node > & getOuterFilterViewFreeOps()
Return views for outer-most filter operations.
Definition: ViewContext.h:62
souffle::interpreter
Definition: BrieIndex.cpp:22
souffle::interpreter::ViewContext::addViewInfoForFilter
void addViewInfoForFilter(size_t relId, size_t indexPos, size_t viewPos)
Add View creation information into the list for outer filter.
Definition: ViewContext.h:82
souffle::interpreter::ViewContext::addViewOperationForFilter
void addViewOperationForFilter(Own< Node > node)
Add outer-most filter operation which requires a view.
Definition: ViewContext.h:42
souffle::interpreter::ViewContext::nestedViewOps
VecOwn< Node > nestedViewOps
Vector of nested operations.
Definition: ViewContext.h:100
souffle::interpreter::ViewContext::addViewInfoForNested
void addViewInfoForNested(size_t relId, size_t indexPos, size_t viewPos)
Add View creation information into the list for nested oprations.
Definition: ViewContext.h:87
souffle::interpreter::ViewContext::getViewInfoForNested
std::vector< std::array< size_t, 3 > > & getViewInfoForNested()
Return Views information for nested operation.
Definition: ViewContext.h:77
souffle::interpreter::ViewContext::isParallel
bool isParallel
If this context has information for parallel operation.
Definition: ViewContext.h:92
souffle::interpreter::ViewContext::outerFilterViewFreeOps
VecOwn< Node > outerFilterViewFreeOps
Vector of filter operations, no views required.
Definition: ViewContext.h:98
souffle::interpreter::ViewContext::addViewFreeOperationForFilter
void addViewFreeOperationForFilter(Own< Node > node)
Add outer-most filter operation which does not require a view.
Definition: ViewContext.h:47
souffle::interpreter::ViewContext::addViewOperationForNested
void addViewOperationForNested(Own< Node > op)
Add nested operation which require a View (Hints).
Definition: ViewContext.h:52
souffle::interpreter::ViewContext::getViewInfoForFilter
std::vector< std::array< size_t, 3 > > & getViewInfoForFilter()
Return Views information for outer filter operation.
Definition: ViewContext.h:72
souffle::interpreter::ViewContext::getViewsInNestedOperation
VecOwn< Node > & getViewsInNestedOperation()
Return nested operations.
Definition: ViewContext.h:67
souffle::interpreter::ViewContext::getOuterFilterViewOps
const VecOwn< Node > & getOuterFilterViewOps()
Return outer-most filter operations.
Definition: ViewContext.h:57
souffle::interpreter::ViewContext::viewInfoForNested
std::vector< std::array< size_t, 3 > > viewInfoForNested
Vector of View information in nested operations.
Definition: ViewContext.h:104
souffle::VecOwn
std::vector< Own< A > > VecOwn
Definition: ContainerUtil.h:45