A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
MultiInputsBase.h
Go to the documentation of this file.
1
/*****************************************************************************
2
* *
3
* Copyright 2018 Rice University *
4
* *
5
* Licensed under the Apache License, Version 2.0 (the "License"); *
6
* you may not use this file except in compliance with the License. *
7
* You may obtain a copy of the License at *
8
* *
9
* http://www.apache.org/licenses/LICENSE-2.0 *
10
* *
11
* Unless required by applicable law or agreed to in writing, software *
12
* distributed under the License is distributed on an "AS IS" BASIS, *
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14
* See the License for the specific language governing permissions and *
15
* limitations under the License. *
16
* *
17
*****************************************************************************/
18
#ifndef MULTI_INPUTS_BASE
19
#define MULTI_INPUTS_BASE
20
21
22
namespace
pdb {
23
24
25
// this class represents all inputs for a multi-input computation like Join
26
// this is used in query graph analysis
27
class
MultiInputsBase
{
28
29
private
:
30
// tuple set names for each input
31
std::vector<std::string>
tupleSetNamesForInputs
;
32
33
// input columns for each input
34
std::vector<std::vector<std::string>>
inputColumnsForInputs
;
35
36
// input column to apply for each input
37
std::vector<std::vector<std::string>>
inputColumnsToApplyForInputs
;
38
39
// lambda names to extract for each input and each predicate
40
std::vector<std::map<std::string, std::vector<std::string>>>
lambdaNamesForInputs
;
41
42
43
// input names for this join operation
44
std::vector<std::string>
inputNames
;
45
46
// input names show up in join predicates
47
std::vector<std::string>
inputNamesInPredicates
;
48
49
// input names show up in join projection
50
std::vector<std::string>
inputNamesInProjection
;
51
52
53
int
numPredicates
;
54
55
56
int
numInputs
;
57
58
public
:
59
void
setNumInputs
(
int
numInputs
) {
60
this->numInputs =
numInputs
;
61
}
62
63
int
getNumInputs
() {
64
return
this->
numInputs
;
65
}
66
67
void
setNumPredicates
(
int
numPredicates
) {
68
this->numPredicates =
numPredicates
;
69
}
70
71
int
getNumPredicates
() {
72
return
this->
numPredicates
;
73
}
74
75
// returns the latest tuple set name that contains the i-th input
76
std::string
getTupleSetNameForIthInput
(
int
i) {
77
if
(i >= this->
getNumInputs
()) {
78
return
""
;
79
}
80
return
tupleSetNamesForInputs
[i];
81
}
82
83
// set the latest tuple set name that contains the i-th input
84
void
setTupleSetNameForIthInput
(
int
i, std::string name) {
85
int
numInputs
= this->
getNumInputs
();
86
if
(
tupleSetNamesForInputs
.size() !=
numInputs
) {
87
tupleSetNamesForInputs
.resize(numInputs);
88
}
89
if
(i < numInputs) {
90
tupleSetNamesForInputs
[i] = name;
91
}
92
}
93
94
// get latest input columns for the tupleset for the i-th input
95
std::vector<std::string>
getInputColumnsForIthInput
(
int
i) {
96
if
(i >= this->
getNumInputs
()) {
97
std::vector<std::string> ret;
98
return
ret;
99
}
100
return
inputColumnsForInputs
[i];
101
}
102
103
// set latest input columns for the tupleset for the i-th input
104
void
setInputColumnsForIthInput
(
int
i, std::vector<std::string>& columns) {
105
int
numInputs
= this->
getNumInputs
();
106
if
(
inputColumnsForInputs
.size() !=
numInputs
) {
107
inputColumnsForInputs
.resize(numInputs);
108
}
109
if
(i < numInputs) {
110
inputColumnsForInputs
[i] = columns;
111
}
112
}
113
114
// get latest input column to apply for the tupleset for the i-th input
115
std::vector<std::string>
getInputColumnsToApplyForIthInput
(
int
i) {
116
if
(i >= this->
getNumInputs
()) {
117
std::vector<std::string> ret;
118
return
ret;
119
}
120
return
inputColumnsToApplyForInputs
[i];
121
}
122
123
124
// set latest input column to apply for the tupleset for the i-th input
125
void
setInputColumnsToApplyForIthInput
(
int
i, std::vector<std::string>& columnsToApply) {
126
int
numInputs
= this->
getNumInputs
();
127
if
(
inputColumnsToApplyForInputs
.size() !=
numInputs
) {
128
inputColumnsToApplyForInputs
.resize(numInputs);
129
}
130
if
(i < numInputs) {
131
inputColumnsToApplyForInputs
[i] = columnsToApply;
132
}
133
}
134
135
// set latest input column to apply for the tupleset for the i-th input
136
void
setInputColumnsToApplyForIthInput
(
int
i, std::string columnToApply) {
137
int
numInputs
= this->
getNumInputs
();
138
if
(
inputColumnsToApplyForInputs
.size() !=
numInputs
) {
139
inputColumnsToApplyForInputs
.resize(numInputs);
140
}
141
if
(i < numInputs) {
142
inputColumnsToApplyForInputs
[i].clear();
143
inputColumnsToApplyForInputs
[i].push_back(columnToApply);
144
}
145
}
146
147
// get lambdas to extract for the i-th input, and j-th predicate
148
std::vector<std::string>
getLambdasForIthInputAndPredicate
(
int
i, std::string predicateLambda) {
149
if
(i >= this->
getNumInputs
()) {
150
std::vector<std::string> ret;
151
return
ret;
152
}
153
return
lambdaNamesForInputs
[i][predicateLambda];
154
}
155
156
// set lambdas for the i-th input, and j-th predicate
157
void
setLambdasForIthInputAndPredicate
(
int
i,
158
std::string predicateLambda,
159
std::string lambdaName) {
160
int
numInputs
= this->
getNumInputs
();
161
if
(
lambdaNamesForInputs
.size() !=
numInputs
) {
162
lambdaNamesForInputs
.resize(numInputs);
163
}
164
if
(i < numInputs) {
165
lambdaNamesForInputs
[i][predicateLambda].push_back(lambdaName);
166
}
167
}
168
169
// get the name for the i-th input
170
std::string
getNameForIthInput
(
int
i) {
171
if
(i >= this->
getNumInputs
()) {
172
return
""
;
173
}
174
return
inputNames
[i];
175
}
176
177
178
// set the name for the i-th input
179
void
setNameForIthInput
(
int
i, std::string name) {
180
int
numInputs
= this->
getNumInputs
();
181
if
(
inputNames
.size() !=
numInputs
) {
182
inputNames
.resize(numInputs);
183
}
184
if
(i < numInputs) {
185
inputNames
[i] = name;
186
}
187
}
188
189
// get the input names in predicates
190
std::vector<std::string>
getInputsInPredicates
() {
191
return
this->
inputNamesInPredicates
;
192
}
193
194
195
// add name to names in predicates
196
void
addInputNameToPredicates
(std::string name) {
197
198
auto
iter = std::find(
inputNamesInPredicates
.begin(),
inputNamesInPredicates
.end(), name);
199
if
(iter ==
inputNamesInPredicates
.end()) {
200
inputNamesInPredicates
.push_back(name);
201
}
202
}
203
204
// get the input names in projection
205
std::vector<std::string>
getInputsInProjection
() {
206
return
inputNamesInProjection
;
207
}
208
209
210
// set the name for the i-th input
211
void
addInputNameToProjection
(std::string name) {
212
213
auto
iter = std::find(
inputNamesInProjection
.begin(),
inputNamesInProjection
.end(), name);
214
if
(iter ==
inputNamesInProjection
.end()) {
215
inputNamesInProjection
.push_back(name);
216
}
217
}
218
219
220
// get a vector of inputs that are not in join predicates
221
std::vector<std::string>
getNamesNotInPredicates
() {
222
std::vector<std::string> ret;
223
for
(
int
i = 0; i <
inputNames
.size(); i++) {
224
auto
iter = std::find(
225
inputNamesInPredicates
.begin(),
inputNamesInPredicates
.end(),
inputNames
[i]);
226
if
(iter ==
inputNamesInPredicates
.end()) {
227
ret.push_back(
inputNames
[i]);
228
}
229
}
230
return
ret;
231
}
232
233
// get a vector of inputs that are not in projection
234
std::vector<std::string>
getNamesNotInProjection
() {
235
std::vector<std::string> ret;
236
for
(
int
i = 0; i <
inputNames
.size(); i++) {
237
auto
iter = std::find(
238
inputNamesInProjection
.begin(),
inputNamesInProjection
.end(),
inputNames
[i]);
239
if
(iter ==
inputNamesInProjection
.end()) {
240
ret.push_back(
inputNames
[i]);
241
}
242
}
243
return
ret;
244
}
245
246
// check whether an input name is in projection
247
bool
isInputInProjection
(std::string name) {
248
auto
iter = std::find(
inputNamesInProjection
.begin(),
inputNamesInProjection
.end(), name);
249
if
(iter !=
inputNamesInProjection
.end()) {
250
return
true
;
251
}
else
{
252
return
false
;
253
}
254
}
255
};
256
}
257
258
#endif
pdb::MultiInputsBase::getNumInputs
int getNumInputs()
Definition:
MultiInputsBase.h:63
pdb::MultiInputsBase::setNumInputs
void setNumInputs(int numInputs)
Definition:
MultiInputsBase.h:59
pdb::MultiInputsBase::setInputColumnsForIthInput
void setInputColumnsForIthInput(int i, std::vector< std::string > &columns)
Definition:
MultiInputsBase.h:104
pdb::MultiInputsBase::getLambdasForIthInputAndPredicate
std::vector< std::string > getLambdasForIthInputAndPredicate(int i, std::string predicateLambda)
Definition:
MultiInputsBase.h:148
pdb::MultiInputsBase::tupleSetNamesForInputs
std::vector< std::string > tupleSetNamesForInputs
Definition:
MultiInputsBase.h:31
pdb::MultiInputsBase::setNumPredicates
void setNumPredicates(int numPredicates)
Definition:
MultiInputsBase.h:67
pdb::MultiInputsBase::getTupleSetNameForIthInput
std::string getTupleSetNameForIthInput(int i)
Definition:
MultiInputsBase.h:76
pdb::MultiInputsBase::numInputs
int numInputs
Definition:
MultiInputsBase.h:56
pdb::MultiInputsBase::setInputColumnsToApplyForIthInput
void setInputColumnsToApplyForIthInput(int i, std::vector< std::string > &columnsToApply)
Definition:
MultiInputsBase.h:125
pdb::MultiInputsBase::setTupleSetNameForIthInput
void setTupleSetNameForIthInput(int i, std::string name)
Definition:
MultiInputsBase.h:84
pdb::MultiInputsBase::addInputNameToProjection
void addInputNameToProjection(std::string name)
Definition:
MultiInputsBase.h:211
pdb::MultiInputsBase::getNumPredicates
int getNumPredicates()
Definition:
MultiInputsBase.h:71
pdb::MultiInputsBase::getInputColumnsForIthInput
std::vector< std::string > getInputColumnsForIthInput(int i)
Definition:
MultiInputsBase.h:95
pdb::MultiInputsBase::inputNamesInPredicates
std::vector< std::string > inputNamesInPredicates
Definition:
MultiInputsBase.h:47
pdb::MultiInputsBase::inputColumnsToApplyForInputs
std::vector< std::vector< std::string > > inputColumnsToApplyForInputs
Definition:
MultiInputsBase.h:37
pdb::MultiInputsBase::numPredicates
int numPredicates
Definition:
MultiInputsBase.h:53
pdb::MultiInputsBase::inputNamesInProjection
std::vector< std::string > inputNamesInProjection
Definition:
MultiInputsBase.h:50
pdb::MultiInputsBase::setInputColumnsToApplyForIthInput
void setInputColumnsToApplyForIthInput(int i, std::string columnToApply)
Definition:
MultiInputsBase.h:136
pdb::MultiInputsBase::inputColumnsForInputs
std::vector< std::vector< std::string > > inputColumnsForInputs
Definition:
MultiInputsBase.h:34
pdb::MultiInputsBase::getInputsInPredicates
std::vector< std::string > getInputsInPredicates()
Definition:
MultiInputsBase.h:190
pdb::MultiInputsBase::getNamesNotInPredicates
std::vector< std::string > getNamesNotInPredicates()
Definition:
MultiInputsBase.h:221
pdb::MultiInputsBase::addInputNameToPredicates
void addInputNameToPredicates(std::string name)
Definition:
MultiInputsBase.h:196
pdb::MultiInputsBase::lambdaNamesForInputs
std::vector< std::map< std::string, std::vector< std::string > > > lambdaNamesForInputs
Definition:
MultiInputsBase.h:40
pdb::MultiInputsBase::isInputInProjection
bool isInputInProjection(std::string name)
Definition:
MultiInputsBase.h:247
pdb::MultiInputsBase::setNameForIthInput
void setNameForIthInput(int i, std::string name)
Definition:
MultiInputsBase.h:179
pdb::MultiInputsBase::inputNames
std::vector< std::string > inputNames
Definition:
MultiInputsBase.h:44
pdb::MultiInputsBase::setLambdasForIthInputAndPredicate
void setLambdasForIthInputAndPredicate(int i, std::string predicateLambda, std::string lambdaName)
Definition:
MultiInputsBase.h:157
pdb::MultiInputsBase::getInputColumnsToApplyForIthInput
std::vector< std::string > getInputColumnsToApplyForIthInput(int i)
Definition:
MultiInputsBase.h:115
pdb::MultiInputsBase::getNameForIthInput
std::string getNameForIthInput(int i)
Definition:
MultiInputsBase.h:170
pdb::MultiInputsBase::getNamesNotInProjection
std::vector< std::string > getNamesNotInProjection()
Definition:
MultiInputsBase.h:234
pdb::MultiInputsBase
Definition:
MultiInputsBase.h:27
pdb::MultiInputsBase::getInputsInProjection
std::vector< std::string > getInputsInProjection()
Definition:
MultiInputsBase.h:205
plinycompute
pdb
src
queryExecution
headers
MultiInputsBase.h
Generated on Mon Jun 18 2018 18:10:36 by
1.8.6