-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClause.cpp
More file actions
74 lines (62 loc) · 1.47 KB
/
Clause.cpp
File metadata and controls
74 lines (62 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "Clause.h"
WhereClause::WhereClause(BooleanExpression * expression) :
m_expression(expression)
{
for (int i = 0; i < m_expression->variables().size(); i++)
{
/* set location of the data */
m_expression->variables()[i]->data(&m_tuple);
}
}
WhereClause::~WhereClause()
{
delete m_expression;
}
bool WhereClause::evaluate(const Tuple & t)
{
m_tuple.schema(t.schema());
m_tuple.m_data = t.m_data;
return m_expression->evaluate();
}
JoinClause::JoinClause(BooleanExpression & exp, SelectionList items[],
std::vector<IVariableOperand *> variables[])
: m_expression(exp)
{
for(int i = 0; i < 2; i++)
{
Schema * schema = new Schema();
m_tuple[i].m_data = NULL;
m_tuple[i].schema(schema);
m_items[i] = items[i];
for(int j = 0; j < items[i].size(); j++)
{
schema->add(items[i].at(j));
}
for (int j = 0; j < variables[i].size(); j++)
{
/* set location of the data */
variables[i].at(j)->data(&m_tuple[i]);
}
}
}
JoinClause::~JoinClause()
{
for(int i = 0; i < 2; i++)
{
delete m_tuple[i].schema();
}
}
const Schema * JoinClause::schema(int branch) const
{
return m_tuple[branch].schema();
}
bool JoinClause::evaluate(const Tuple & t0, const Tuple & t1)
{
m_tuple[LEFT].m_data = t0.m_data;
m_tuple[RIGHT].m_data = t1.m_data;
return m_expression.evaluate();
}
const SelectionList & JoinClause::filter(int branch) const
{
return m_items[branch];
}