souffle  2.0.2-371-g6315b36
RelationTag.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 RelationTag.h
12  *
13  * Identifies the available relation tags, including qualifiers and
14  * representations.
15  ***********************************************************************/
16 
17 #pragma once
18 
20 #include <ostream>
21 
22 namespace souffle {
23 
24 /** Space of user-chosen tags that a relation can have */
25 enum class RelationTag {
26  INPUT, // relation read from csv
27  OUTPUT, // relation written to csv
28  PRINTSIZE, // number of tuples written to stdout
29  OVERRIDABLE, // rules defined in component can be overwritten by sub-component
30  INLINE, // inlined
31  MAGIC, // enable magic-set on this relation
32  SUPPRESSED, // warnings suppressed
33  BRIE, // use brie data-structure
34  BTREE, // use btree data-structure
35  EQREL, // use union data-structure
36 };
37 
38 /** Space of qualifiers that a relation can have */
39 enum class RelationQualifier {
40  INPUT, // relation read from csv
41  OUTPUT, // relation written to csv
42  PRINTSIZE, // number of tuples written to stdout
43  OVERRIDABLE, // rules defined in component can be overwritten by sub-component
44  INLINE, // inlined
45  MAGIC, // enable magic-set on this relation
46  SUPPRESSED, // warnings suppressed
47 };
48 
49 /** Space of internal representations that a relation can have */
50 enum class RelationRepresentation {
51  DEFAULT, // use default data-structure
52  BRIE, // use brie data-structure
53  BTREE, // use btree data-structure
54  EQREL, // use union data-structure
55  INFO, // info relation for provenance
56 };
57 
58 /**
59  * Check if a given relation tag sets a relation representation.
60  */
61 inline bool isRelationRepresentationTag(const RelationTag& tag) {
62  switch (tag) {
63  case RelationTag::BRIE:
64  case RelationTag::BTREE:
65  case RelationTag::EQREL: return true;
66  default: return false;
67  }
68 }
69 
70 /**
71  * Check if a given relation tag is a relation qualifier.
72  */
73 inline bool isRelationQualifierTag(const RelationTag& tag) {
74  switch (tag) {
75  case RelationTag::INPUT:
80  case RelationTag::MAGIC:
81  case RelationTag::SUPPRESSED: return true;
82  default: return false;
83  }
84 }
85 
86 /**
87  * Get the corresponding RelationQualifier for a valid RelationTag.
88  */
90  switch (tag) {
98  default: fatal("invalid relation tag");
99  }
100 }
101 
102 /**
103  * Get the corresponding RelationRepresentation for a valid RelationTag.
104  */
106  switch (tag) {
110  default: fatal("invalid relation tag");
111  }
112 
114 }
115 
116 inline std::ostream& operator<<(std::ostream& os, RelationTag qualifier) {
117  switch (qualifier) {
118  case RelationTag::INPUT: return os << "input";
119  case RelationTag::OUTPUT: return os << "output";
120  case RelationTag::PRINTSIZE: return os << "printsize";
121  case RelationTag::OVERRIDABLE: return os << "overridable";
122  case RelationTag::INLINE: return os << "inline";
123  case RelationTag::MAGIC: return os << "magic";
124  case RelationTag::SUPPRESSED: return os << "suppressed";
125  case RelationTag::BRIE: return os << "brie";
126  case RelationTag::BTREE: return os << "btree";
127  case RelationTag::EQREL: return os << "eqrel";
128  }
129 
131 }
132 
133 inline std::ostream& operator<<(std::ostream& os, RelationQualifier qualifier) {
134  switch (qualifier) {
135  case RelationQualifier::INPUT: return os << "input";
136  case RelationQualifier::OUTPUT: return os << "output";
137  case RelationQualifier::PRINTSIZE: return os << "printsize";
138  case RelationQualifier::OVERRIDABLE: return os << "overridable";
139  case RelationQualifier::INLINE: return os << "inline";
140  case RelationQualifier::MAGIC: return os << "magic";
141  case RelationQualifier::SUPPRESSED: return os << "suppressed";
142  }
143 
145 }
146 
147 inline std::ostream& operator<<(std::ostream& os, RelationRepresentation representation) {
148  switch (representation) {
149  case RelationRepresentation::BTREE: return os << "btree";
150  case RelationRepresentation::BRIE: return os << "brie";
151  case RelationRepresentation::EQREL: return os << "eqrel";
152  case RelationRepresentation::INFO: return os << "info";
154  }
155 
157 }
158 
159 } // namespace souffle
souffle::RelationRepresentation::BRIE
@ BRIE
UNREACHABLE_BAD_CASE_ANALYSIS
#define UNREACHABLE_BAD_CASE_ANALYSIS
Definition: MiscUtil.h:206
souffle::RelationTag::EQREL
@ EQREL
souffle::RelationQualifier::SUPPRESSED
@ SUPPRESSED
souffle::RelationRepresentation::EQREL
@ EQREL
souffle::RelationQualifier::OVERRIDABLE
@ OVERRIDABLE
souffle::RelationTag::PRINTSIZE
@ PRINTSIZE
MiscUtil.h
souffle::getRelationRepresentationFromTag
RelationRepresentation getRelationRepresentationFromTag(const RelationTag &tag)
Get the corresponding RelationRepresentation for a valid RelationTag.
Definition: RelationTag.h:111
souffle::RelationQualifier::PRINTSIZE
@ PRINTSIZE
souffle::RelationTag::OUTPUT
@ OUTPUT
souffle::RelationQualifier::MAGIC
@ MAGIC
souffle::RelationTag::MAGIC
@ MAGIC
souffle::getRelationQualifierFromTag
RelationQualifier getRelationQualifierFromTag(const RelationTag &tag)
Get the corresponding RelationQualifier for a valid RelationTag.
Definition: RelationTag.h:95
souffle::RelationTag
RelationTag
Space of user-chosen tags that a relation can have.
Definition: RelationTag.h:31
souffle::operator<<
std::ostream & operator<<(std::ostream &os, AggregateOp op)
Definition: AggregateOp.h:51
souffle::RelationQualifier::INPUT
@ INPUT
souffle::RelationRepresentation::DEFAULT
@ DEFAULT
souffle::RelationQualifier::INLINE
@ INLINE
souffle::RelationTag::INLINE
@ INLINE
souffle::fatal
void fatal(const char *format, const Args &... args)
Definition: MiscUtil.h:198
souffle::RelationRepresentation::INFO
@ INFO
souffle::isRelationQualifierTag
bool isRelationQualifierTag(const RelationTag &tag)
Check if a given relation tag is a relation qualifier.
Definition: RelationTag.h:79
souffle
Definition: AggregateOp.h:25
souffle::RelationTag::INPUT
@ INPUT
souffle::RelationRepresentation::BTREE
@ BTREE
souffle::RelationTag::SUPPRESSED
@ SUPPRESSED
souffle::RelationTag::OVERRIDABLE
@ OVERRIDABLE
souffle::RelationRepresentation
RelationRepresentation
Space of internal representations that a relation can have.
Definition: RelationTag.h:56
souffle::RelationQualifier
RelationQualifier
Space of qualifiers that a relation can have.
Definition: RelationTag.h:45
souffle::isRelationRepresentationTag
bool isRelationRepresentationTag(const RelationTag &tag)
Check if a given relation tag sets a relation representation.
Definition: RelationTag.h:67
souffle::RelationQualifier::OUTPUT
@ OUTPUT
souffle::RelationTag::BRIE
@ BRIE
souffle::RelationTag::BTREE
@ BTREE