BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
Main Page
Related Pages
Classes
Files
File List
File Members
rel
rel_n_n.h
Go to the documentation of this file.
1
// ============================================================================
2
// Project: Deductive Database
3
// Filename: rel_n_n.h
4
// Purpose: Relation with two non-negative integer columns, index over 1st.
5
// Last Change: 04.08.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
22
//=============================================================================
23
// Include File Frame:
24
//=============================================================================
25
26
#ifndef REL_N_N_INCLUDED
27
#define REL_N_N_INCLUDED
28
29
//=============================================================================
30
// Used Types and Macros:
31
//=============================================================================
32
33
#ifndef VER_INCLUDED
34
#include "../base/ver.h"
35
#endif
36
37
#ifndef STR_INCLUDED
38
#include "../base/str.h"
39
#endif
40
41
#ifndef CHECK_INCLUDED
42
#include "../base/check.h"
43
#endif
44
45
#ifndef MPOOL_INCLUDED
46
#include "../mem/mpool.h"
47
#endif
48
49
#ifndef FLEXARR_INCLUDED
50
#include "../bds/flexarr.h"
51
#endif
52
53
#ifndef REL_INCLUDED
54
#include "../rel/rel.h"
55
#endif
56
57
58
//=============================================================================
59
// Private Constants:
60
//=============================================================================
61
62
//-----------------------------------------------------------------------------
63
// REL_N_N_MAGIC: Magic number (identifies objects of this class).
64
//-----------------------------------------------------------------------------
65
66
static
const
long
REL_N_N_MAGIC = 0x524E4E0AL;
// 'RNN\n'
67
68
//=============================================================================
69
// Class for Relation with two non-negative integer columns:
70
//=============================================================================
71
72
// Non-negative integers are used as ID for strings and for atoms.
73
// This version has an index on the first column.
74
// It is assumed that the first column is dense, so we can basically use
75
// an array as index. However, it is also assumed that a fixed-size array
76
// is not sufficient, so the relation can be quite big or of an unknown size.
77
78
class
rel_n_n_c
:
public
rel_c
{
79
public
:
80
81
//-----------------------------------------------------------------------------
82
// Constructor, Destructor:
83
//-----------------------------------------------------------------------------
84
85
// Constructor:
86
rel_n_n_c
(
str_t
rel_name);
87
88
// Destructor:
89
~
rel_n_n_c
();
90
91
//-----------------------------------------------------------------------------
92
// (Object) Methods:
93
//-----------------------------------------------------------------------------
94
95
// insert: Insert tuple into relation.
96
bool
insert(
int
c1,
int
c2);
97
98
//-----------------------------------------------------------------------------
99
// Debugging Support:
100
//-----------------------------------------------------------------------------
101
102
#if VER_DEBUG
103
public
:
104
// Integrity check:
105
str_t
check()
const
;
106
107
private
:
108
// Magic number (identifies objects of this class for debugging).
109
long
Magic;
// Must be "REL_N_N_MAGIC".
110
#endif
111
112
#if VER_DUMP
113
public
:
114
// Display data structure:
115
void
dump(
str_t
headline =
STR_NULL
)
const
;
116
#endif
117
118
//-----------------------------------------------------------------------------
119
// Copy-constructor and assignment operator are not supported for this class:
120
//-----------------------------------------------------------------------------
121
122
private
:
123
124
rel_n_n_c
(
const
rel_n_n_c
& obj);
// Not implemented
125
rel_n_n_c
& operator=(
const
rel_n_n_c
& obj);
// Not implemented
126
127
//-----------------------------------------------------------------------------
128
// This class works together with the corresponding cursor class:
129
//-----------------------------------------------------------------------------
130
131
friend
class
cur_n_n_c
;
132
133
//-----------------------------------------------------------------------------
134
// Private Object Members:
135
//-----------------------------------------------------------------------------
136
137
private
:
138
139
// Array indexed by first column, contains second column or list index.
140
flexarr_c<int>
IndexArr;
141
142
// List nodes to store value sets with >1 element for the 2nd column:
143
flexarr_c<int>
ValueArr;
144
145
//=============================================================================
146
// End of Class:
147
//=============================================================================
148
149
};
150
151
//-----------------------------------------------------------------------------
152
// Define pointer type:
153
//-----------------------------------------------------------------------------
154
155
typedef
rel_n_n_c
*
rel_n_n_t
;
156
157
//-----------------------------------------------------------------------------
158
// Define null pointer:
159
//-----------------------------------------------------------------------------
160
161
#define REL_N_N_NULL (static_cast<rel_n_n_t>(0))
162
163
//=============================================================================
164
// End of Include File:
165
//=============================================================================
166
167
#endif
168
flexarr_c< int >
cur_n_n_c
Definition:
cur_n_n.h:68
rel_c
Definition:
rel.h:72
str_t
const char * str_t
Definition:
str.h:41
STR_NULL
#define STR_NULL
Definition:
str.h:52
rel_n_n_c
Definition:
rel_n_n.h:78
Generated by
1.8.10