本文整理汇总了C++中Plan::fromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Plan::fromFile方法的具体用法?C++ Plan::fromFile怎么用?C++ Plan::fromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan::fromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_plan
int main_plan(int argc, char* argv[]) {
if (argc != 2)
return -1;
Plan p;
p.fromFile(argv[1]);
p.print(std::cout);
return 0;
}
示例2: main
int main(int argc, char** argv) {
// if (argc != 2) {
// cerr << "usage: " << argv[0] << " <planFile>" << endl;
// return -1;
// }
// parse schema
cout << "-- parse schema from " << fileCreate << endl;
Parser parser(fileCreate);
unique_ptr<Schema> schema;
try {
schema = parser.parse();
cout << schema->toString() << endl;
} catch (ParserError& e) {
cerr << e.what() << endl;
return -1;
}
// setting everything up
cout << endl << "-- init Buffer- and SegmentManager" << endl;
BufferManager bm("/tmp/db", 10ul * 1024ul * 1024ul); // bogus arguments
SegmentManager sm(bm);
SegmentID spId = sm.createSegment(Segment::SegmentType::Schema, 200);
SchemaSegment& scs = static_cast<SchemaSegment&>(sm.getSegment(spId));
// read schema
scs.readSchemaFromFile(fileCreate, &sm);
// insert tuples
cout << endl << "-- insert 5 tuples in each relation" << endl;
SPSegment& students = static_cast<SPSegment&>(sm.getSegment(scs.getRelationSegmentID("student")));
struct {int id; char name[64];} sstudent;
for(int i=1; i<=5; i++){
sstudent.id = i;
// sstudent.name = "Student "+string(i);
stringstream ss;
ss << "Student " << i;
strcpy(sstudent.name, ss.str().c_str());
Record r(sizeof(sstudent), (char*) ((void*) (&sstudent)));
students.insert(r); // TID id =
}
SPSegment& lectures = static_cast<SPSegment&>(sm.getSegment(
scs.getRelationSegmentID("lecture")));
struct {
int id;
char name[64];
} slecture;
for (int i = 1; i <= 5; i++) {
slecture.id = i;
stringstream ss;
ss << "Lecture " << i;
strcpy(slecture.name, ss.str().c_str());
Record r(sizeof(slecture), (char*) ((void*) (&slecture)));
lectures.insert(r);
}
SPSegment& exams = static_cast<SPSegment&>(sm.getSegment(
scs.getRelationSegmentID("exam")));
struct {
int l_id;
int s_id;
int grade;
} sexam;
for (int i = 1; i <= 5; i++) {
sexam.l_id = i;
sexam.s_id = i; // 5-i
sexam.grade = i + 3;
Record r(sizeof(sexam), (char*) ((void*) (&sexam)));
exams.insert(r);
}
// parse query plan
cout << endl << "-- parse query plan from " << filePlan << endl;
Plan p;
p.fromFile(argv[1]);
p.print(cout);
// const plan::Operator* root = &p.getRoot();
// walk down tree and execute the corresponding physical operators
cout << endl << "-- generate tree of physical operators" << endl;
operators::Operator* op = walkTree(p.getRoot(), scs, sm);
// print results
cout << endl << "-- print results" << endl;
operators::Print print(op, cout);
print.open();
while(print.next()){}
print.close();
return 0;
}