BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
bench_j1axy_1.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: bench_j1axy_1.h
4 // Purpose: Bottom-Up Evaluation for Join1, a(X,Y), Ver. 1: no goto, dupCh
5 // Last Change: 17.09.2017
6 // Language: C++
7 // EMail: brass@informatik.uni-halle.de
8 // WWW: http://www.informatik.uni-halle.de/~brass/
9 // Address: Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
10 // Copyright: (c) 2015-2017 by Stefan Brass
11 // License: See file "LICENSE" for copying conditions.
12 // Note: There is no warranty at all - this code may contain bugs.
13 // ============================================================================
14 
15 
23 //=============================================================================
24 // Include File Frame:
25 //=============================================================================
26 
27 #ifndef BENCH_J1AXY_1_INCLUDED
28 #define BENCH_J1AXY_1_INCLUDED
29 
30 
31 //=============================================================================
32 // This Benchmark is optional:
33 //=============================================================================
34 
35 #ifndef VER_INCLUDED
36 #include "../base/ver.h"
37 #endif
38 
39 #if VER_BENCH_J1AXY_1
40 
41 
42 //=============================================================================
43 // Used Types and Macros:
44 //=============================================================================
45 
46 
47 #ifndef STR_INCLUDED
48 #include "../base/str.h"
49 #endif
50 
51 #ifndef CHECK_INCLUDED
52 #include "../base/check.h"
53 #endif
54 
55 #ifndef LIST_2_INCLUDED
56 #include "../rel/list_2.h"
57 #endif
58 
59 #ifndef SET_2_INCLUDED
60 #include "../rel/set_2.h"
61 #endif
62 
63 #ifndef REL_N_N_INCLUDED
64 #include "../rel/rel_n_n.h"
65 #endif
66 
67 #ifndef BENCH_INCLUDED
68 #include "bench.h"
69 #endif
70 
71 
72 //=============================================================================
73 // Private Constants:
74 //=============================================================================
75 
76 //-----------------------------------------------------------------------------
77 // BENCH_J1AXY_1_MAGIC: Magic number (identifies objects of this class).
78 //-----------------------------------------------------------------------------
79 
80 static const long BENCH_J1AXY_1_MAGIC = 0x4A31410AL; // 'J1A\n'
81 
82 
83 //=============================================================================
84 // Bottom-Up Evaluation (Join 1 Benchmark: a(X,Y), Ver. E: no goto, w/dupChk):
85 //=============================================================================
86 
87 class bench_j1axy_1_c : public bench_c {
88  public:
89 
90 
91 //-----------------------------------------------------------------------------
92 // Constructor, Destructor:
93 //-----------------------------------------------------------------------------
94 
95  public:
96 
97  // Constructor:
99 
100  // Destructor:
101  ~bench_j1axy_1_c();
102 
103 //-----------------------------------------------------------------------------
104 // (Object) Methods:
105 //-----------------------------------------------------------------------------
106 
107  // load: Load data file with EDB facts.
108  bool load(str_t filename);
109 
110  // Do bottom-up evaluation:
111  long eval();
112 
113  // name: Name of this benchmark.
114  str_t name() const {
115  return
116  "Join 1, a(X,Y), Ver. 5: Rel. Attrs, no goto, full dupcheck";
117  }
118 
119  // file: List of data files.
120  str_t file(int i) const;
121 
122  // result: List of correct results of eval method.
123  long result(int i) const;
124 
125 //-----------------------------------------------------------------------------
126 // Copy-constructor and assignment operator are not supported for this class:
127 //-----------------------------------------------------------------------------
128 
129  private:
130 
131  // These methods are not implemented:
132  bench_j1axy_1_c(const bench_j1axy_1_c& obj);
133  bench_j1axy_1_c& operator=(const bench_j1axy_1_c& obj);
134 
135 
136 //-----------------------------------------------------------------------------
137 // Debugging Support:
138 //-----------------------------------------------------------------------------
139 
140 #if VER_DEBUG
141  // Integrity check:
142  public:
143  str_t check() const;
144 
145  // Magic number (identifies objects of this class for debugging).
146  private:
147  long Magic; // Must be "BENCH_J1AXY_1_MAGIC".
148 #endif
149 
150 
151 #if VER_DUMP
152  public:
153  // Display data structure:
154  void dump(str_t headline = STR_NULL) const;
155 #endif
156 
157 //-----------------------------------------------------------------------------
158 // Private Object Members:
159 //-----------------------------------------------------------------------------
160 
161  private:
162 
163 //-----------------------------------------------------------------------------
164 // Data storage for EDB relations:
165 //-----------------------------------------------------------------------------
166 
167  rel_n_n_c c2_bf;
168  list_2_c c3_ff;
169  rel_n_n_c c4_bf;
170  list_2_c d1_ff;
171  rel_n_n_c d2_bf;
172 
173 
174 //-----------------------------------------------------------------------------
175 // Relation for storing derived b1 tuples (for rule with two IDB lit):
176 //-----------------------------------------------------------------------------
177 
178  rel_n_n_c b1_fb;
179  // Note that columns 1 and 2 are exchanged,
180  // because c1 is always input to the mapping, and c2 output.
181 
182 //-----------------------------------------------------------------------------
183 // Sets for duplicate checks:
184 //-----------------------------------------------------------------------------
185 
186  set_2_c b1_bb;
187  set_2_c b2_bb;
188  set_2_c c1_bb;
189  set_2_c a_bb;
190 
191 //=============================================================================
192 // End of Class:
193 //=============================================================================
194 
195 };
196 
197 
198 //=============================================================================
199 // End of Conditional Compilation of this Test (VER_BENCH_J1AXY_1):
200 //=============================================================================
201 
202 #endif
203 
204 
205 //=============================================================================
206 // End of Include File:
207 //=============================================================================
208 
209 #endif
210 
Abstract Superclass of Standard Benchmarks with load() and eval()
Abstract superclass for Standard Benchmarks with load() and eval() Methods.
Definition: bench.h:67
Definition: list_2.h:58
Definition: bench_j1axy_1.h:87
const char * str_t
Definition: str.h:41
#define STR_NULL
Definition: str.h:52
Definition: rel_n_n.h:78
bool load(str_t filename)
Definition: bench_j1axy_1.cpp:100
Definition: set_2.h:58