BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
bench_j1axy_6.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: bench_j1axy_6.h
4 // Purpose: Benchmark Join1, a(X,Y), Ver. 6: abstract machine, bitmap 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) 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_6_INCLUDED
28 #define BENCH_J1AXY_6_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_6
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 CUR_2_INCLUDED
60 #include "../rel/cur_2.h"
61 #endif
62 
63 #ifndef SET_TT_INCLUDED
64 #include "../rel/set_tt.h"
65 #endif
66 
67 #ifndef REL_N_N_INCLUDED
68 #include "../rel/rel_n_n.h"
69 #endif
70 
71 #ifndef CUR_N_N_INCLUDED
72 #include "../rel/cur_n_n.h"
73 #endif
74 
75 #ifndef BAM_INCLUDED
76 #include "../emu/bam.h"
77 #endif
78 
79 #ifndef BENCH_INCLUDED
80 #include "bench.h"
81 #endif
82 
83 
84 //=============================================================================
85 // Private Constants:
86 //=============================================================================
87 
88 //-----------------------------------------------------------------------------
89 // BENCH_J1AXY_6_MAGIC: Magic number (identifies objects of this class).
90 //-----------------------------------------------------------------------------
91 
92 static const long BENCH_J1AXY_6_MAGIC = 0x4A31410AL; // 'J1A\n'
93 
94 
95 //=============================================================================
96 // Benchmark Join1, a(X,Y), Ver. 6: abstract machine, bitmap dupcheck
97 //=============================================================================
98 
99 class bench_j1axy_6_c : public bench_c {
100  public:
101 
102 
103 //-----------------------------------------------------------------------------
104 // Constructor, Destructor:
105 //-----------------------------------------------------------------------------
106 
107  public:
108 
109  // Constructor:
110  bench_j1axy_6_c();
111 
112  // Destructor:
113  ~bench_j1axy_6_c();
114 
115 //-----------------------------------------------------------------------------
116 // (Object) Methods:
117 //-----------------------------------------------------------------------------
118 
119  // load: Load data file with EDB facts.
120  bool load(str_t filename);
121 
122  // eval: Do bottom-up evaluation.
123  long eval();
124 
125  // name: Name of this benchmark.
126  str_t name() const {
127  return "Join 1, a(X,Y), Ver. 6: Abstract Machine, Bitmap";
128  }
129 
130  // file: List of data files.
131  str_t file(int i) const;
132 
133  // result: List of correct results of the eval method.
134  long result(int i) const;
135 
136  // Open cursor (note: load() must be called before this method).
137  void open();
138 
139  // fetch: Get next tuple, returns false if there is no further tuple.
140  inline bool fetch() {
141  return result_cursor.fetch();
142  }
143 
144 
145  // c1: Return value for column 1 of current row in cursor.
146  inline int c1() {
147  return result_cursor.c1();
148  }
149 
150  // c2: Return value for column 2 of current row in cursor.
151  inline int c2() {
152  return result_cursor.c2();
153  }
154 
155  // error: Did an error occur?
156  inline bool error() {
157  // EDB relations:
158  if(c2_bf.mem_err())
159  return true;
160  if(c3_ff.mem_err())
161  return true;
162  if(c4_bf.mem_err())
163  return true;
164  if(d1_ff.mem_err())
165  return true;
166  if(d2_bf.mem_err())
167  return true;
168 
169  // Derived b1 tuples (for rule with two IDB lit):
170  if(b1_fb.mem_err())
171  return true;
172 
173  // Sets for duplicate checks:
174  if(b1_bb.mem_err())
175  return true;
176  if(b2_bb.mem_err())
177  return true;
178  if(c1_bb.mem_err())
179  return true;
180  if(a_bb.mem_err())
181  return true;
182 
183  // Error with backtrack stacks:
184  return Error;
185  }
186 
187  // close: Close cursor.
188  inline void close() {
189  result_cursor.close();
190  }
191 
192 //-----------------------------------------------------------------------------
193 // Copy-constructor and assignment operator are not supported for this class:
194 //-----------------------------------------------------------------------------
195 
196  private:
197 
198  // These methods are not implemented:
199  bench_j1axy_6_c(const bench_j1axy_6_c& obj);
200  bench_j1axy_6_c& operator=(const bench_j1axy_6_c& obj);
201 
202 
203 //-----------------------------------------------------------------------------
204 // Debugging Support:
205 //-----------------------------------------------------------------------------
206 
207 #if VER_DEBUG
208  // Integrity check:
209  public:
210  str_t check() const;
211 
212  // Magic number (identifies objects of this class for debugging).
213  private:
214  long Magic; // Must be "BENCH_J1AXY_6_MAGIC".
215 #endif
216 
217 
218 #if VER_DUMP
219  public:
220  // Display data structure:
221  void dump(str_t headline = STR_NULL) const;
222 #endif
223 
224 //-----------------------------------------------------------------------------
225 // Auxiliary Methods:
226 //-----------------------------------------------------------------------------
227 
228  private:
229 
230  bool bam_prog();
231 
232 //-----------------------------------------------------------------------------
233 // Private Object Members:
234 //-----------------------------------------------------------------------------
235 
236  private:
237 
238 //-----------------------------------------------------------------------------
239 // Abstract machine:
240 //-----------------------------------------------------------------------------
241 
242  bam_c bam;
243 
244 //-----------------------------------------------------------------------------
245 // Data storage for EDB relations:
246 //-----------------------------------------------------------------------------
247 
248  rel_n_n_c c2_bf;
249  list_2_c c3_ff;
250  rel_n_n_c c4_bf;
251  list_2_c d1_ff;
252  rel_n_n_c d2_bf;
253 
254 //-----------------------------------------------------------------------------
255 // Relation for storing derived b1 tuples (for rule with two IDB lit):
256 //-----------------------------------------------------------------------------
257 
258  rel_n_n_c b1_fb;
259  // Note that columns 1 and 2 are exchanged,
260  // because c1 is always input to the mapping, and c2 output.
261 
262 //-----------------------------------------------------------------------------
263 // Sets for duplicate checks:
264 //-----------------------------------------------------------------------------
265 
266  set_tt_c b1_bb;
267  set_tt_c b2_bb;
268  set_tt_c c1_bb;
269  set_tt_c a_bb;
270 
271 //-----------------------------------------------------------------------------
272 // Result list and cursor:
273 //-----------------------------------------------------------------------------
274 
275  list_2_c result_list;
276  cur_2_c result_cursor;
277 
278 //-----------------------------------------------------------------------------
279 // Did an error occur?
280 //-----------------------------------------------------------------------------
281 
282  bool Error;
283 
284 
285 //=============================================================================
286 // End of Class:
287 //=============================================================================
288 
289 };
290 
291 
292 //=============================================================================
293 // End of Conditional Compilation of this Test (VER_BENCH_J1AXY_6):
294 //=============================================================================
295 
296 #endif
297 
298 
299 //=============================================================================
300 // End of Include File:
301 //=============================================================================
302 
303 #endif
304 
Abstract Superclass of Standard Benchmarks with load() and eval()
Abstract superclass for Standard Benchmarks with load() and eval() Methods.
Definition: bench.h:67
bool load(str_t filename)
Definition: bench_j1axy_6.cpp:150
Definition: bench_j1axy_6.h:99
Definition: list_2.h:58
const char * str_t
Definition: str.h:41
Definition: bam.h:182
Definition: set_tt.h:121
#define STR_NULL
Definition: str.h:52
Definition: rel_n_n.h:78
Definition: cur_2.h:62