souffle  2.0.2-371-g6315b36
ExistenceCheck.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. 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 ExistenceCheck.h
12  *
13  * Defines a class for evaluating conditions in the Relational Algebra
14  * Machine.
15  *
16  ***********************************************************************/
17 
18 #pragma once
19 
21 #include "ram/Expression.h"
22 #include "ram/Relation.h"
24 #include <memory>
25 #include <utility>
26 #include <vector>
27 
28 namespace souffle::ram {
29 
30 /**
31  * @class ExistenceCheck
32  * @brief Existence check for a tuple(-pattern) in a relation
33  *
34  * Returns true if the tuple is in the relation
35  *
36  * The following condition is evaluated to true if the
37  * tuple element t0.1 is in the relation A:
38  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
39  * t0.1 IN A
40  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
41  */
42 class ExistenceCheck : public AbstractExistenceCheck {
43 public:
44  ExistenceCheck(std::string rel, VecOwn<Expression> vals) : AbstractExistenceCheck(rel, std::move(vals)) {}
45 
46  ExistenceCheck* clone() const override {
47  VecOwn<Expression> newValues;
48  for (auto& cur : values) {
49  newValues.emplace_back(cur->clone());
50  }
51  return new ExistenceCheck(relation, std::move(newValues));
52  }
53 };
54 
55 } // namespace souffle::ram
AbstractExistenceCheck.h
souffle::ram::ExistenceCheck::ExistenceCheck
ExistenceCheck(std::string rel, VecOwn< Expression > vals)
Definition: ExistenceCheck.h:51
souffle::ram::ExistenceCheck::clone
ExistenceCheck * clone() const override
Create a clone (i.e.
Definition: ExistenceCheck.h:53
MiscUtil.h
souffle::ram
Definition: AstToRamTranslator.h:54
Relation.h
souffle::ram::AbstractExistenceCheck::relation
const std::string relation
Relation.
Definition: AbstractExistenceCheck.h:95
std
Definition: Brie.h:3053
souffle::ram::AbstractExistenceCheck::values
VecOwn< Expression > values
Search tuple.
Definition: AbstractExistenceCheck.h:98
Expression.h
souffle::ram::AbstractExistenceCheck::AbstractExistenceCheck
AbstractExistenceCheck(std::string rel, VecOwn< Expression > vals)
Definition: AbstractExistenceCheck.h:49
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086