Esempio n. 1
0
void printResultMessage(const SuccessResult &result, std::ostream &os) {
  os << "OK, passed " + std::to_string(result.numSuccess) + " tests";
  if (!result.distribution.empty()) {
    os << std::endl;
    printDistribution(result, os);
  }
}
Esempio n. 2
0
/*
 * returns a random join tree. JoinConditions and selections will be reconstructed later
 */
string quickPick::executeQuickPick(int n){
	string bestJoinTree="";
	string joinTree;
	srand(time(NULL));
	double bestCost=std::numeric_limits<double>::infinity();
	vector<double> costLog;

	for(int t=0; t<n; t++){

	init();

	//store intermediate join trees here
	string joinTrees[res.relations.size()];
	for(unsigned int i=0; i<res.relations.size(); i++){
		joinTrees[i] = res.relations.at(i).binding;
	}

	int index;
	int indexLeftRelation;
	int indexRightRelation;
	while(!unionFind->only_one_set()){
		index=pickNextEdge();

		indexLeftRelation = getRelationIndex(res.joinConditions.at(index).first);
		indexRightRelation = getRelationIndex(res.joinConditions.at(index).second);
		int l = unionFind->find(indexLeftRelation);
		int r = unionFind->find(indexRightRelation);
		if(l != r){
			//The relations which are connected by the picked edge are in distinct sets, thus union the two sets
			unionFind->do_union(indexLeftRelation, indexRightRelation);
			joinTrees[unionFind->find(indexLeftRelation)] = (((string("(")+=joinTrees[l])+=string(" "))+=joinTrees[r])+=string(")");
		}
	}

	joinTree=joinTrees[unionFind->find(0)];
	double cost = getCost(joinTree);

	//store the cost into this vector for distribution analysis
	costLog.push_back(cost);
	if(cost < bestCost){
		//keep best join tree and cost
		bestJoinTree = joinTree;
		bestCost = cost;
	}

	}

	printDistribution(costLog);
	cout << "The best join tree is " << bestJoinTree << endl;
	cout << "Cost of this join tree: " << (int)bestCost <<"\n"<< endl;

	delete(unionFind);

	return bestJoinTree;
}