当前位置: 首页>>代码示例>>C++>>正文


C++ Plan::getRoot方法代码示例

本文整理汇总了C++中Plan::getRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ Plan::getRoot方法的具体用法?C++ Plan::getRoot怎么用?C++ Plan::getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plan的用法示例。


在下文中一共展示了Plan::getRoot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:vogler,项目名称:dbimpl,代码行数:94,代码来源:operatorTest.cpp


注:本文中的Plan::getRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。