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.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HashOneExecutor.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 
19 #ifndef HASHONE_QUERY_EXEC_H
20 #define HASHONE_QUERY_EXEC_H
21 
22 #include "ComputeExecutor.h"
23 #include "TupleSetMachine.h"
24 #include "TupleSet.h"
25 #include <vector>
26 
27 
28 namespace pdb {
29 
30 // runs an appending 1 operation
32 
33 private:
34  // this is the output TupleSet that we return
36 
37  // the attribute to operate on
38  int whichAtt;
39 
40  // the output attribute
41  int outAtt;
42 
43  // to setup the output tuple set
45 
46 public:
47  // currently, we just ignore the extra parameter to the filter if we get it
48  HashOneExecutor(TupleSpec& inputSchema,
49  TupleSpec& attsToOperateOn,
50  TupleSpec& attsToIncludeInOutput,
52  : myMachine(inputSchema, attsToIncludeInOutput) {
53 
54  // this is the input attribute that we will process
55  output = std::make_shared<TupleSet>();
56  std::vector<int> matches = myMachine.match(attsToOperateOn);
57  whichAtt = matches[0];
58  outAtt = attsToIncludeInOutput.getAtts().size();
59  }
60 
61  HashOneExecutor(TupleSpec& inputSchema,
62  TupleSpec& attsToOperateOn,
63  TupleSpec& attsToIncludeInOutput)
64  : myMachine(inputSchema, attsToIncludeInOutput) {
65 
66  // this is the input attribute that we will process
67  output = std::make_shared<TupleSet>();
68  std::vector<int> matches = myMachine.match(attsToOperateOn);
69  whichAtt = matches[0];
70  outAtt = attsToIncludeInOutput.getAtts().size();
71  }
72 
73  TupleSetPtr process(TupleSetPtr input) override {
74 
75 
76  // set up the output tuple set
77  myMachine.setup(input, output);
78 
79  // create the output attribute, if needed
80  if (!output->hasColumn(outAtt)) {
81  std::vector<size_t>* outColumn = new std::vector<size_t>();
82  output->addColumn(outAtt, outColumn, true);
83  }
84 
85 
86  // get the output column
87  std::vector<size_t>& outColumn = output->getColumn<size_t>(outAtt);
88  // loop over the columns and set the output to be 1
89  int numRows = output->getNumRows(whichAtt);
90  outColumn.resize(numRows);
91  for (int i = 0; i < numRows; i++) {
92  outColumn[i] = 1;
93  }
94 
95 
96  return output;
97  }
98 
99 
100  std::string getType() override {
101  return "HASHONE";
102  }
103 };
104 }
105 
106 #endif
HashOneExecutor(TupleSpec &inputSchema, TupleSpec &attsToOperateOn, TupleSpec &attsToIncludeInOutput, ComputeInfoPtr)
std::vector< std::string > & getAtts()
Definition: TupleSpec.h:60
TupleSetSetupMachine myMachine
std::shared_ptr< ComputeInfo > ComputeInfoPtr
Definition: ComputeInfo.h:33
std::vector< int > match(TupleSpec &attsToMatch)
std::string getType() override
void setup(TupleSetPtr input, TupleSetPtr output)
std::shared_ptr< TupleSet > TupleSetPtr
Definition: TupleSet.h:64
TupleSetPtr process(TupleSetPtr input) override
HashOneExecutor(TupleSpec &inputSchema, TupleSpec &attsToOperateOn, TupleSpec &attsToIncludeInOutput)