Fixed merge issues. Everything compiles and runs again.
This commit is contained in:
parent
b0aaaf902f
commit
3436a00452
6 changed files with 37 additions and 128 deletions
58
DBEngine.cpp
58
DBEngine.cpp
|
@ -44,14 +44,7 @@ void DBEngine::save(){
|
||||||
vector<Relation> DBEngine::getRelations(){
|
vector<Relation> DBEngine::getRelations(){
|
||||||
return tables;
|
return tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
>>>>>>> master
|
|
||||||
Relation& DBEngine::getTableFromName(string n){
|
Relation& DBEngine::getTableFromName(string n){
|
||||||
for(int i = 0; i < tables.size(); i++){
|
for(int i = 0; i < tables.size(); i++){
|
||||||
if (tables[i].getTableName() == n){
|
if (tables[i].getTableName() == n){
|
||||||
|
@ -64,7 +57,7 @@ Relation DBEngine::selection(string attName, string s, Relation r){
|
||||||
equality(attName, s, r);
|
equality(attName, s, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
Relation DBEngine::selection(string attName, string s, Relation r){
|
Relation DBEngine::selection(string attName, string s, Relation r){
|
||||||
equality(attName, s, r);
|
equality(attName, s, r);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +66,7 @@ Relation DBEngine::selection(string attName, string s, Relation r){
|
||||||
Relation DBEngine::selection(string attName, string s, Relation r){
|
Relation DBEngine::selection(string attName, string s, Relation r){
|
||||||
equality(attName, s, r);
|
equality(attName, s, r);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//assumes that all attribute titles are unique
|
//assumes that all attribute titles are unique
|
||||||
Relation DBEngine::projection(vector<string> input, Relation r){
|
Relation DBEngine::projection(vector<string> input, Relation r){
|
||||||
|
@ -89,9 +83,7 @@ Relation DBEngine::projection(vector<string> input, Relation r){
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation temp(new_name, v);
|
Relation temp(new_name, v);
|
||||||
return temp;
|
return temp;
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation DBEngine::product(string new_name, Relation r1, Relation r2){
|
Relation DBEngine::product(string new_name, Relation r1, Relation r2){
|
||||||
|
@ -113,11 +105,7 @@ Relation DBEngine::product(string new_name, Relation r1, Relation r2){
|
||||||
vector<string> tuple2;
|
vector<string> tuple2;
|
||||||
vector<string> result_tuple;
|
vector<string> result_tuple;
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//test error matching
|
//test error matching
|
||||||
|
@ -138,12 +126,10 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
/*
|
||||||
<<<<<<< HEAD
|
Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||||
|
|
||||||
|
|
||||||
/*Relation DBEngine::setUnion(Relation r1, Relation r2){
|
|
||||||
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
||||||
cout << "Failure to union: the relations are not union-compatible";
|
cout << "Failure to union: the relations are not union-compatible";
|
||||||
return;
|
return;
|
||||||
|
@ -151,9 +137,7 @@ void DBEngine::rename(Relation& r, vector<string> oldnames, vector<string> newna
|
||||||
|
|
||||||
else {
|
else {
|
||||||
vector<Attribute> r1_atts = r1.getAttributes();
|
vector<Attribute> r1_atts = r1.getAttributes();
|
||||||
=======
|
*/
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
Relation DBEngine::setUnion(Relation r1, Relation r2){
|
Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||||
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
if (r1.getAttributeNames() != r2.getAttributeNames()){
|
||||||
cout << "Failure to union: the relations are not union-compatible.\nreturning the first relation.\n";
|
cout << "Failure to union: the relations are not union-compatible.\nreturning the first relation.\n";
|
||||||
|
@ -187,13 +171,9 @@ Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
vector<Attribute> r1_atts = r1.getAttributes();
|
||||||
/*vector<Attribute> r1_atts = r1.getAttributes();
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
vector<Attribute> r2_atts = r2.getAttributes();
|
vector<Attribute> r2_atts = r2.getAttributes();
|
||||||
vector<Attribute> new_atts = r1_atts;
|
vector<Attribute> new_atts = r1_atts;
|
||||||
|
|
||||||
|
@ -213,19 +193,7 @@ Relation DBEngine::setUnion(Relation r1, Relation r2){
|
||||||
}
|
}
|
||||||
|
|
||||||
//currently all returned relations are called TEMP
|
//currently all returned relations are called TEMP
|
||||||
Relation new_r("TEMP", new_atts);
|
Relation new_r("TEMP", new_atts);
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
return new_r;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
=======
|
|
||||||
return new_r;*/
|
return new_r;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
return new_r;*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
14
DBEngine.h
14
DBEngine.h
|
@ -22,18 +22,10 @@ public:
|
||||||
Relation selection(string attName, string s, Relation r);
|
Relation selection(string attName, string s, Relation r);
|
||||||
Relation projection(vector<string> input, Relation r);
|
Relation projection(vector<string> input, Relation r);
|
||||||
Relation product(string s1, Relation r1, Relation r2);
|
Relation product(string s1, Relation r1, Relation r2);
|
||||||
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
void rename(Relation& r, vector<string> oldnames, vector<string> newnames);
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void save();
|
void save();
|
||||||
void storeCommands(string s);
|
void storeCommands(string s);
|
||||||
//Relation setUnion(Relation r1, Relation r2);
|
Relation setUnion(Relation r1, Relation r2);
|
||||||
=======
|
|
||||||
Relation setUnion(Relation r1, Relation r2);
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
Relation setUnion(Relation r1, Relation r2);
|
|
||||||
>>>>>>> master
|
|
||||||
//void setDiff();
|
//void setDiff();
|
||||||
//void crossProduct();
|
//void crossProduct();
|
||||||
};
|
};
|
||||||
|
|
52
Parserv3.h
52
Parserv3.h
|
@ -7,13 +7,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
class PRelation
|
class PRelation
|
||||||
{
|
{
|
||||||
string name;
|
string name;
|
||||||
|
@ -269,18 +262,6 @@ class PComparison
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PComparison()
|
PComparison()
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
{
|
|
||||||
op.setPOp("~");
|
|
||||||
operand1.setPOperand("~");
|
|
||||||
operand2.setPOperand("~");
|
|
||||||
}
|
|
||||||
|
|
||||||
PComparison(string str1, string str2, string str3)
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
{
|
{
|
||||||
op.setPOp("~");
|
op.setPOp("~");
|
||||||
operand1.setPOperand("~");
|
operand1.setPOperand("~");
|
||||||
|
@ -295,19 +276,6 @@ class PComparison
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPComparison(string str1, string str2, string str3)
|
void setPComparison(string str1, string str2, string str3)
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
{
|
|
||||||
operand1.setPOperand(str1);
|
|
||||||
op.setPOp(str2);
|
|
||||||
operand2.setPOperand(str3);
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void setPComparison(string str1, string str2, string str3)
|
|
||||||
{
|
{
|
||||||
operand1.setPOperand(str1);
|
operand1.setPOperand(str1);
|
||||||
op.setPOp(str2);
|
op.setPOp(str2);
|
||||||
|
@ -316,14 +284,6 @@ class PComparison
|
||||||
|
|
||||||
string getPComparison()
|
string getPComparison()
|
||||||
{
|
{
|
||||||
=======
|
|
||||||
string getPComparison()
|
|
||||||
{
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
string getPComparison()
|
|
||||||
{
|
|
||||||
>>>>>>> master
|
|
||||||
return operand1.getPOperand() + " " + op.getPOp() + " " + operand2.getPOperand();
|
return operand1.getPOperand() + " " + op.getPOp() + " " + operand2.getPOperand();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -431,10 +391,8 @@ class PExpression
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
vector<string> tokenize(string ss)
|
vector<string> tokenize(string ss)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -835,7 +793,7 @@ void par_line(vector<string> input) //calls par_command() or par_query() dependi
|
||||||
• Match the first item in the token list and determine weather this is a command or a query.
|
• Match the first item in the token list and determine weather this is a command or a query.
|
||||||
• Call functions par_command() or par_query();
|
• Call functions par_command() or par_query();
|
||||||
• After either par_command() or par_query() returns, make sure the line ends properly with “;” token
|
• After either par_command() or par_query() returns, make sure the line ends properly with “;” token
|
||||||
*/
|
|
||||||
string tempChar = input.back();
|
string tempChar = input.back();
|
||||||
|
|
||||||
if (tempChar != ";")
|
if (tempChar != ";")
|
||||||
|
@ -921,8 +879,6 @@ void parse(string input, DBEngine &engine)
|
||||||
vector<string> listOfTokens = tokenize(input);
|
vector<string> listOfTokens = tokenize(input);
|
||||||
par_line(listOfTokens);
|
par_line(listOfTokens);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
=======
|
void parse(string s, DBEngine &e);
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
|
@ -486,6 +486,13 @@ void par_line(vector<string> input) //calls par_command() or par_query() dependi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parse(string input, DBEngine &engine)
|
||||||
|
{
|
||||||
|
engine.storeCommands(input);
|
||||||
|
vector<string> listOfTokens = tokenize(input);
|
||||||
|
par_line(listOfTokens);
|
||||||
|
}
|
||||||
|
/*
|
||||||
int main () {
|
int main () {
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,3 +510,4 @@ int main () {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
33
test.cpp
33
test.cpp
|
@ -1,14 +1,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
<<<<<<< HEAD
|
#include "Parserv3.h"
|
||||||
<<<<<<< HEAD
|
//#include "Condition.h"
|
||||||
#include "Parserv3.h"
|
|
||||||
=======
|
|
||||||
#include "Condition.h"
|
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
#include "Condition.h"
|
|
||||||
>>>>>>> master
|
|
||||||
#include "DBEngine.h"
|
#include "DBEngine.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -35,9 +28,7 @@ int main() {
|
||||||
v.push_back(att1);
|
v.push_back(att1);
|
||||||
v.push_back(att2);
|
v.push_back(att2);
|
||||||
v.push_back(att3);
|
v.push_back(att3);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Relation r("Food", v);
|
Relation r("Food", v);
|
||||||
//r.renameAttribute("Breakfast", "BFST");
|
//r.renameAttribute("Breakfast", "BFST");
|
||||||
//r.display();
|
//r.display();
|
||||||
|
@ -101,13 +92,10 @@ int main () {
|
||||||
parse(ss3, engine);
|
parse(ss3, engine);
|
||||||
|
|
||||||
engine.save();
|
engine.save();
|
||||||
|
/*
|
||||||
|
|
||||||
=======
|
//engine.createTable("Food", v);
|
||||||
engine.createTable("Food", v);
|
//engine.createTable("Food", v);
|
||||||
=======
|
|
||||||
engine.createTable("Food", v);
|
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
Attribute att4("Breakfast", "VARCHAR(20)", true);
|
Attribute att4("Breakfast", "VARCHAR(20)", true);
|
||||||
Attribute att5("Lunch", "VARCHAR(20)", false);
|
Attribute att5("Lunch", "VARCHAR(20)", false);
|
||||||
|
@ -131,8 +119,5 @@ int main () {
|
||||||
engine.createTable("MoarFood", v2);
|
engine.createTable("MoarFood", v2);
|
||||||
|
|
||||||
engine.setUnion(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
|
engine.setUnion(engine.getTableFromName("Food"), engine.getTableFromName("MoarFood")).display();
|
||||||
<<<<<<< HEAD
|
*/
|
||||||
>>>>>>> master
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue