souffle  2.0.2-371-g6315b36
RelationSize.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2020, 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 RelationSize.h
12  *
13  * Defines a class for returning the size of a relation.
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ram/Expression.h"
20 #include "ram/Node.h"
21 #include "ram/Relation.h"
22 #include "ram/utility/NodeMapper.h"
25 #include <cassert>
26 #include <memory>
27 #include <sstream>
28 #include <string>
29 #include <utility>
30 #include <vector>
31 
32 namespace souffle::ram {
33 
34 /**
35  * @class RelationSize
36  * @brief Returns the numbers of tuples in a relation
37  *
38  * For example:
39  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
40  * size(B)
41  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
42  */
43 class RelationSize : public Expression {
44 public:
45  RelationSize(std::string rel) : relation(std::move(rel)) {}
46 
47  /** @brief Get relation */
48  const std::string getRelation() const {
49  return relation;
50  }
51 
52  RelationSize* clone() const override {
53  return new RelationSize(relation);
54  }
55 
56 protected:
57  void print(std::ostream& os) const override {
58  os << "size(" << relation << ")";
59  }
60 
61  bool equal(const Node& node) const override {
62  const auto& other = static_cast<const RelationSize&>(node);
63  return relation == other.relation;
64  }
65 
66  /** Relation */
67  std::string relation;
68 };
69 
70 } // namespace souffle::ram
MiscUtil.h
souffle::ram::RelationSize::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: RelationSize.h:67
souffle::ram::RelationSize::clone
RelationSize * clone() const override
Create a clone (i.e.
Definition: RelationSize.h:58
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::RelationSize::RelationSize
RelationSize(std::string rel)
Definition: RelationSize.h:51
souffle::ram::Node
Node is a superclass for all RAM IR classes.
Definition: Node.h:42
souffle::ram::RelationSize::print
void print(std::ostream &os) const override
Print RAM node.
Definition: RelationSize.h:63
NodeMapper.h
ContainerUtil.h
Relation.h
souffle::ram::RelationSize::relation
std::string relation
Relation.
Definition: RelationSize.h:73
Node.h
std
Definition: Brie.h:3053
souffle::ram::RelationSize::getRelation
const std::string getRelation() const
Get relation.
Definition: RelationSize.h:54
Expression.h
souffle::ram::RelationSize
Returns the numbers of tuples in a relation.
Definition: RelationSize.h:49
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086