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


C++ Disk::getDiskIOs方法代码示例

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


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

示例1: selectFromTable

void selectFromTable(bool dis, string attributes, string tabs, string whereCondition, string orderBy) {
	
	int disk0 = disk.getDiskIOs();
	vector<string> tableNames = split(tabs, ',');
	vector<string> attributeNames = split(attributes, ',');
	string tableName;
	if(validate(tableNames)) return;
	if(tableNames.size()==1) {
		Relation *relation = schemaManager.getRelation(tableNames[0]);
		string pName = projection(attributeNames, tableNames[0], whereCondition);
		string d;
		relation = schemaManager.getRelation(pName);
		if(dis) {
			d = distinct(pName);
			relation = schemaManager.getRelation(d);	
		}
		cout<<*relation<<endl;
		if(!(attributeNames.size()==1 && attributeNames[0]=="*" && whereCondition.empty()))
		schemaManager.deleteRelation(pName);
		if(dis)
		schemaManager.deleteRelation(d);
	}
	else {
		vector<string>::iterator it;
		vector<string> projections;
		if(tableNames.size()==2) {
			string ptemp = crossJoin(attributeNames, tableNames[0], tableNames[1], whereCondition, false);
			string d;
			Relation *relation = schemaManager.getRelation(ptemp);
			if(dis) {
				d = distinct(ptemp);
				relation = schemaManager.getRelation(d);
			} 
			cout<<*relation<<endl;
			schemaManager.deleteRelation(ptemp);
			if(dis)
			schemaManager.deleteRelation(d);
		}
		else {
			bool flag =true;
			vector<string> blah;
			string str = crossJoin(blah, tableNames[0],tableNames[1], whereCondition, false);
			for(int i=2;i<tableNames.size();i++) {
				str = crossJoin(blah, str, tableNames[i], whereCondition, true);
			}
			Relation *relation = schemaManager.getRelation(str);
			cout<<*relation<<endl;
			schemaManager.deleteRelation(str);
		}
	}
	cout<<"No. of disk IO's used for this opertaion are "<<disk.getDiskIOs()-disk0<<endl;
}
开发者ID:ravitx,项目名称:608,代码行数:52,代码来源:core.cpp

示例2: insertIntoTable

void insertIntoTable(string tableName, vector<string> fieldNames, vector<string> fieldValues) {

        if(!schemaManager.relationExists(tableName)) { 
		cout<<"Illegal Tablename"<<endl;
		return;
	}	
	Relation *relation = schemaManager.getRelation(tableName);
	Tuple tuple = relation->createTuple();
	Schema schema = relation->getSchema();
 	vector<string>::iterator it,it1;	
	for(it = fieldNames.begin(),it1 = fieldValues.begin();it!=fieldNames.end();it++, it1++) {
		string str=*it,str1=*it1;
		str = removeSpaces(str);
		int type = schema.getFieldType(str);
		if(!type) {
			str1 = removeSpaces(str1);
			if(isNumber(str1)) {
				tuple.setField(str,stoi(str1));
			}
			else {
				cout<<"Data type is not supported\n";
				return;
			}
		} 
		else {
			regex exp("\\ *\"(.*)\"");
			cmatch match;
			if(regex_match(str1.c_str(),match,exp)) {
				str1 = match[1];
				if(str1.length()>20) {
					cout<<"Data type is not supported\n";
					return;
				}
				else tuple.setField(str,str1);
			}
			else {
				cout<<"Data type is not supported\n";
				return;
			}
		}
	}
	insertTuple(tableName, tuple);
	cout<<disk.getDiskIOs()<<endl;
}
开发者ID:ravitx,项目名称:608,代码行数:44,代码来源:core.cpp

示例3: main

int main(int argc, char ** argv){
	// Initialize the memory, disk and the schema manager
	MainMemory mem;
	Disk disk;
	//cout << "The memory contains " << mem.getMemorySize() << " blocks" << endl;
	SchemaManager schema_manager(&mem,&disk);
	disk.resetDiskIOs();
	disk.resetDiskTimer();
	resetFreeBlocks();
	clock_t start_time;
	start_time=clock();

	//=======================Read Input=========================
	ifstream input;
	bool interactive_mode = false;
	assert(argv && argc >= 1);

	cout<<endl;
	cout<<"                   ";
	cout<<"============================================="<<endl<<endl;
	cout<<"                   ";
	cout<<"Welcome to TinySQL Database Management System"<<endl<<endl;
	cout<<"                   ";
	cout<<"Develped by Jimmy Jin & Tony Wang, 12/6/2016"<<endl<<endl;
	cout<<"                   ";
	cout<<"============================================="<<endl<<endl;


	if (argc == 1){
		cout<<endl<<"Entering Interactive Mode: Type query and ENTER to execute; Type EXIT to exit the program."<<endl<<endl;
		interactive_mode = true;
	}
	else if (argc == 2){
		string filename = argv[1];
		input.open(filename.c_str());
		if (!input.is_open()){
			cout<<"Cannot Open file: "<<filename<<endl;
			return 0;
		}
	}
	else{
		cout<<"To use TinySQL to read input file, type:   ";
		cout<<"./Tiny <filename>"<<endl; 
		cout<<"To use TinySQL in Interactive Mode, type:  ";
		cout<<"./Tiny"<<endl;
		return 0;
	}
	unsigned long int ios = 0;
	double time = 0;
	string line;
	vector<string> words;

	// for each command line
	while(1){
		if (interactive_mode){
			cout<<">>";
			char console_input[1000];
			cin.getline(console_input, sizeof(console_input));
			line = string(console_input);
			if (line == "EXIT") break;
			cout<<endl;
		}
		else{
			if (!getline(input, line)) break;
			cout<<line<<endl;	
		}
		if(line[0] == '#')	continue;
		if(line.size() == 0)	continue;
		// extract each word into vector words
		words = splitBy(line," ");

		// prepare memory
		resetFreeBlocks();

		if (words[0] == "CREATE"){
			Create(words, schema_manager, mem);
		}
		else if (words[0] == "DROP"){
			string relation_name = words[2];
			schema_manager.deleteRelation(relation_name);
		}
		else if (words[0] == "INSERT"){
			Insert(words, line, schema_manager, mem);
			//	cout<< *(schema_manager.getRelation(relation_name))<<endl;
		}
		else if (words[0] == "DELETE"){
			Delete(words, schema_manager, mem);
		}
		else if (words[0] == "SELECT"){
			Select(words, schema_manager, mem);
		}
		else{
			cout<<"Not a valid Tiny-SQL command!"<<endl<<endl;
			continue;
			//abort();
		}
		words.clear();
		cout << "Elapse time = " << disk.getDiskTimer() - time<< " ms" << endl;
		cout << "Disk I/Os = " << disk.getDiskIOs() - ios<< endl<<endl;
		time = disk.getDiskTimer();
//.........这里部分代码省略.........
开发者ID:tonywang1990,项目名称:TinySQL-implementation,代码行数:101,代码来源:Tiny.cpp


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