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
QueryGraphAnalyzer.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 QUERY_GRAPH_ANALYZER_HEADER
19 #define QUERY_GRAPH_ANALYZER_HEADER
20 
21 #include "Computation.h"
22 #include "Handle.h"
23 #include "InputTupleSetSpecifier.h"
24 #include "PDBVector.h"
25 #include <vector>
26 
27 namespace pdb {
28 
29 
30 // This class encapsulates the analyzer to user query graph
31 // This class is also called a TCAP compiler,
32 // and it translates a user query graph into a TCAP program.
33 
34 // A TCAP program has following format:
35 // $TargetTupleSetName($tupleNamesToKeep, $newTupleName) <=
36 // $TCAPOperatorName($SourceTupleSetName($tupleNamesToApply),
37 // $SourceTupleSetName($tupleNamesToKeep),
38 // $ComputationName,
39 // $LambdaName)
40 
41 // Currently supported TCAP operators include:
42 // Apply, Aggregate, Partition, Join, ScanSet, WriteSet, HashLeft, HashRight
43 // HashOne, Flatten, Filter and so on.
44 
45 // Note that the user query graph should not have loops
46 
48 
49 public:
50  // constructor
52 
53  // constructor
55 
56  // to convert user query to a tcap string
57  std::string parseTCAPString();
58 
59  // to traverse the sub-tree and put each traversed computation to a vector
60  void parseComputations(std::vector<Handle<Computation>> &computations,
61  Handle<Computation> sink);
62 
63  // to convert user query to a pdb::Vector of computations
64  // this method will invoke makeObject, but will not allocate allocation blocks
65  // you must ensure current allocation block has sufficient memory before
66  // invoking this method
67  void parseComputations(std::vector<Handle<Computation>> &computations);
68 
69  // to traverse from a graph sink recursively
70  void traverse(std::vector<std::string> &tcapStrings, Handle<Computation> sink,
71  std::vector<InputTupleSetSpecifier> inputTupleSets,
72  int &computationLabel, std::string &outputTupleSetName,
73  std::vector<std::string> &outputColumnNames,
74  std::string &addedOutputColumnName);
75 
76  // to clear traversal marks on the subtree rooted at sink
78 
79  // to clear all traversal marks
80  void clearGraphMarks();
81 
82 private:
83  // user query graph
84  std::vector<Handle<Computation>> queryGraph;
85 };
86 }
87 
88 #endif
std::vector< Handle< Computation > > queryGraph
QueryGraphAnalyzer(std::vector< Handle< Computation >> &queryGraph)
void parseComputations(std::vector< Handle< Computation >> &computations, Handle< Computation > sink)
void traverse(std::vector< std::string > &tcapStrings, Handle< Computation > sink, std::vector< InputTupleSetSpecifier > inputTupleSets, int &computationLabel, std::string &outputTupleSetName, std::vector< std::string > &outputColumnNames, std::string &addedOutputColumnName)