Example #1
0
// [[Rcpp::export]]
NumericMatrix CPP_dsm_score_dense(NumericMatrix f, NumericVector f1, NumericVector f2, double N, int am_code, int sparse, int transform_code) {
  if (am_code < 0 || am_code >= am_table_entries)
    stop("internal error -- invalid AM code");
  am_func AM = am_table[am_code]; /* selected association measure */

  int nr = f.nrow(), nc = f.ncol();
  if (am_code != 0 && (nr != f1.size() || nc != f2.size()))
    stop("internal error -- marginal vectors f1 and f2 not conformable with matrix f");

  NumericMatrix scores(nr, nc);

  NumericMatrix::iterator _f = f.begin();
  NumericVector::iterator _f1 = f1.begin();
  NumericVector::iterator _f2 = f2.begin();
  NumericMatrix::iterator _scores = scores.begin();

  int i = 0;
  for (int col = 0; col < nc; col++) {
    for (int row = 0; row < nr; row++) {
      /* frequeny measure (am_code == 0) is a special case, since marginals may not be available (in "reweight" mode) */
      double score = (am_code == 0) ? _f[i] : AM(_f[i], _f1[row], _f2[col], N, sparse);
      _scores[i] = (transform_code) ? transform(score, transform_code) : score;
      i++;
    }
  }

  return scores;
}
Example #2
0
// [[Rcpp::export]]
NumericVector CPP_dsm_score_sparse(int nr, int nc, IntegerVector p, IntegerVector row_of, NumericVector f, NumericVector f1, NumericVector f2, double N, int am_code, int sparse, int transform_code) {
  if (am_code < 0 || am_code >= am_table_entries)
    stop("internal error -- invalid AM code");
  am_func AM = am_table[am_code]; /* selected association measure */

  // -- don't check whether sparse=TRUE, so power users can compute non-sparse AMs for nonzero entries of the sparse matrix
  //  if (!sparse) stop("only sparse association scores can be used with sparse matrix representation");
  
  int n_items = f.size();
  NumericVector scores(n_items);
  if (am_code != 0 && (nr != f1.size() || nc != f2.size()))
    stop("internal error -- marginal vectors f1 and f2 not conformable with matrix f");

  IntegerVector::iterator _p = p.begin();
  IntegerVector::iterator _row_of = row_of.begin();
  NumericVector::iterator _f = f.begin();
  NumericVector::iterator _f1 = f1.begin();
  NumericVector::iterator _f2 = f2.begin();
  NumericVector::iterator _scores = scores.begin();
  
  for (int col = 0; col < nc; col++) {
    for (int i = _p[col]; i < _p[col+1]; i++) {
      /* frequeny measure (*am_code == 0) is a special case, since marginals may not be available ("reweight" mode) */
      double score = (am_code == 0) ? _f[i] : AM(_f[i], _f1[_row_of[i]], _f2[col], N, sparse);
      _scores[i] = (transform_code) ? transform(score, transform_code) : score;
    }
  }

  return scores;
}
Example #3
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db1(env->getEnv(), DB1);
	BDBOpe db2(env->getEnv(), DB2);
	Operator *o1, *o2, *o3, *o4;
	
	db1.open();
	db2.open();
	TABLE_REC tableRec1, tableRec2;
	
	tableRec1.tableID = DB1_tableID;
	tableRec1.attriNum = DB1_attriNum;
	tableRec2.tableID = DB2_tableID;
	tableRec2.attriNum = DB2_attriNum;
	
	ATTRIBUTE_REC attriRec1[tableRec1.attriNum];
	ATTRIBUTE_REC attriRec2[tableRec2.attriNum];
	AttributeManager AM(env->getEnv());
	
	AM.getForTableID(tableRec1, attriRec1);
	AM.getForTableID(tableRec2, attriRec2);
	
/* JOin target */
	OPERATION_NODE pn[2];
	pn[0].tableID = 15;
	pn[0].attributeID = 1;
	pn[0].option = 0;
	pn[1].tableID = 16;
	pn[1].attributeID = 1;
	pn[1].option = 0;

	
	JOIN_OPERATION_NODE jpn[1];
	jpn[0].rightNode = pn[0];
	jpn[0].leftNode = pn[1];
/* ============ */	

	o1 = new Scan_U2(&db1, attriRec1, DB1_attriNum, 1000000, 10);
	((Scan_U2 *)o1)->storeData();
	o2 = new Scan_U2(&db2, attriRec2, DB2_attriNum, 1000000, 10);
	((Scan_U2 *)o2)->storeData();
	
	o3 = new MargeJoin(o1, o2 , jpn, 1);
	o4 = new OutPut(TIME_OUT);

	o4->setPreOperator(o3);
	o4->init(env->getEnv());
	o4->exec();
}
Example #4
0
struct VkMapping {
#if SDL_VERSION_ATLEAST(1, 3, 0)
	SDL_Keycode vk_from;
#else
	uint16 vk_from;
#endif
	byte vk_count;
	byte map_to;
};

#define AS(x, z) {x, 0, z}
#define AM(x, y, z, w) {x, (byte)(y - x), z}

static const VkMapping _vk_mapping[] = {
	/* Pageup stuff + up/down */
	AM(SDLK_PAGEUP, SDLK_PAGEDOWN, WKC_PAGEUP, WKC_PAGEDOWN),
	AS(SDLK_UP,     WKC_UP),
	AS(SDLK_DOWN,   WKC_DOWN),
	AS(SDLK_LEFT,   WKC_LEFT),
	AS(SDLK_RIGHT,  WKC_RIGHT),

	AS(SDLK_HOME,   WKC_HOME),
	AS(SDLK_END,    WKC_END),

	AS(SDLK_INSERT, WKC_INSERT),
	AS(SDLK_DELETE, WKC_DELETE),

	/* Map letters & digits */
	AM(SDLK_a, SDLK_z, 'A', 'Z'),
	AM(SDLK_0, SDLK_9, '0', '9'),
Example #5
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db_r(env->getEnv(), "REGION20.row");
	BDBOpe db_n(env->getEnv(), "NATION20.row");
	BDBOpe db_c(env->getEnv(), "CUSTOMER20.row");
	BDBOpe db_o(env->getEnv(), "ORDERS20.row");
	BDBOpe db_l(env->getEnv(), "LINEITEM20.row");
	BDBOpe db_s(env->getEnv(), "SUPPLIER20.row");

	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23;
	
	db_r.open();
	db_n.open();
	db_c.open();
	db_o.open();
	db_l.open();
	db_s.open();


	TABLE_REC tableRec_r;
	TABLE_REC tableRec_n;
	TABLE_REC tableRec_c;
	TABLE_REC tableRec_o;
	TABLE_REC tableRec_l;
	TABLE_REC tableRec_s;

	
/* set table info */
	tableRec_r.tableID = 9;
	tableRec_r.attriNum = 3;
	
	tableRec_n.tableID = 10;
	tableRec_n.attriNum = 4;
	
	tableRec_c.tableID = 14;
	tableRec_c.attriNum = 8;

	tableRec_o.tableID = 15;
	tableRec_o.attriNum = 9;
	
	tableRec_l.tableID = 16;
	tableRec_l.attriNum = 16;
	
	tableRec_s.tableID = 11;
	tableRec_s.attriNum = 7;

/* aet attriRec */
	ATTRIBUTE_REC attriRec_r[tableRec_r.attriNum];
	ATTRIBUTE_REC attriRec_n[tableRec_n.attriNum];
	ATTRIBUTE_REC attriRec_c[tableRec_c.attriNum];
	ATTRIBUTE_REC attriRec_o[tableRec_o.attriNum];
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];
	ATTRIBUTE_REC attriRec_s[tableRec_s.attriNum];

	AttributeManager AM(env->getEnv());

	AM.getForTableID(tableRec_r, attriRec_r);
	AM.getForTableID(tableRec_n, attriRec_n);
	AM.getForTableID(tableRec_c, attriRec_c);
	AM.getForTableID(tableRec_o, attriRec_o);
	AM.getForTableID(tableRec_l, attriRec_l);
	AM.getForTableID(tableRec_s, attriRec_s);

/* selection1 */
	FixStrPosVal pv1(1,25);
	string str1("ASIA");
	pv1.setStr(str1);

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 9;
	cn1.attriID = 2;
	AxprNode an1 = AxprNode(EQ, &cn1, &vn1);
	

/* selection2 */

	DatePosVal pv2(1,(unsigned char *)"1994-01-01");
	DatePosVal pv3(1,(unsigned char *)"1995-01-01");
	

	ValueNode vn2 = ValueNode(&pv2);
	ValueNode vn3 = ValueNode(&pv3);
	ColumnRefNode cn2;
	cn2.tableID = 15;
	cn2.attriID = 5;
	AxprNode an2 = AxprNode(GE, &cn2, &vn2);
	AxprNode an3 = AxprNode(LT, &cn2, &vn3);
	AxprNode an4 = AxprNode(AND, &an2, &an3);
	
	
/* GROUP */
	IntPosVal pv5(1, 1);
	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4[2];
	cn4[0].tableID = 16;
	cn4[0].attriID = 6;
	cn4[1].tableID = 16;
	cn4[1].attriID = 7;
	ArithmeticNode arith1(SUB, &vn5, &cn4[1]);
	ArithmeticNode arith2(MUL, &cn4[0], &arith1);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith2, 2);
	
	
	OPERATION_NODE group[1];
	group[0].tableID = 10;
	group[0].attributeID = 2;




/* Join1 */

	OPERATION_NODE pn1[2];
	pn1[0].tableID = 9;
	pn1[0].attributeID = 1;
	pn1[1].tableID = 10;
	pn1[1].attributeID = 3;
	

	JOIN_OPERATION_NODE jpn1[1];
	jpn1[0].rightNode = pn1[0];
	jpn1[0].leftNode = pn1[1];
	
	
/* Join2 */
	OPERATION_NODE pn2[2];
	pn2[0].tableID = 10;
	pn2[0].attributeID = 1;
	pn2[1].tableID = 11;
	pn2[1].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn2[1];
	jpn2[0].rightNode = pn2[0];
	jpn2[0].leftNode = pn2[1];

/* Join3 */
	OPERATION_NODE pn3[2];
	pn3[0].tableID = 11;
	pn3[0].attributeID = 1;
	pn3[1].tableID = 16;
	pn3[1].attributeID = 3;

	
	JOIN_OPERATION_NODE jpn3[1];
	jpn3[0].rightNode = pn3[0];
	jpn3[0].leftNode = pn3[1];
	
/* Join4 */
	OPERATION_NODE pn4[2];
	pn4[0].tableID = 15;
	pn4[0].attributeID = 1;
	pn4[1].tableID = 16;
	pn4[1].attributeID = 1;

	
	JOIN_OPERATION_NODE jpn4[1];
	jpn4[0].rightNode = pn4[0];
	jpn4[0].leftNode = pn4[1];

/* Join5 */
	OPERATION_NODE pn5[4];
	pn5[0].tableID = 14;
	pn5[0].attributeID = 1;
	pn5[1].tableID = 14;
	pn5[1].attributeID = 4;
	pn5[2].tableID = 15;
	pn5[2].attributeID = 2;
	pn5[3].tableID = 11;
	pn5[3].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn5[2];
	jpn5[0].rightNode = pn5[0];
	jpn5[0].leftNode = pn5[2];
	jpn5[1].rightNode = pn5[1];
	jpn5[1].leftNode = pn5[3];


/* Projection1 */

	OPERATION_NODE pro1[1];
	pro1[0].tableID = 9;
	pro1[0].attributeID = 1;

/* Projection2 */

	OPERATION_NODE pro2[2];
	pro2[0].tableID = 10;
	pro2[0].attributeID = 1;
	pro2[1].tableID = 10;
	pro2[1].attributeID = 2;

/* Projection3 */

	OPERATION_NODE pro3[3];
	pro3[0].tableID = 11;
	pro3[0].attributeID = 1;
	pro3[1].tableID = 11;
	pro3[1].attributeID = 4;
	pro3[2].tableID = 10;
	pro3[2].attributeID = 2;
	
/* Projection4 */

	OPERATION_NODE pro4[5];
	pro4[0].tableID = 16;
	pro4[0].attributeID = 1;
	pro4[1].tableID = 16;
	pro4[1].attributeID = 6;
	pro4[2].tableID = 16;
	pro4[2].attributeID = 7;
	pro4[3].tableID = 11;
	pro4[3].attributeID = 4;
	pro4[4].tableID = 10;
	pro4[4].attributeID = 2;

/* Projection5 */
	
	OPERATION_NODE pro5[2];
	pro5[0].tableID = 15;
	pro5[0].attributeID = 1;
	pro5[1].tableID = 15;
	pro5[1].attributeID = 2;

/* Projection6 */
	
	OPERATION_NODE pro6[2];
	pro6[0].tableID = 14;
	pro6[0].attributeID = 1;
	pro6[1].tableID = 14;
	pro6[1].attributeID = 4;

/* Projection7 */
	
	OPERATION_NODE pro7[3];
	pro7[0].tableID = 10;
	pro7[0].attributeID = 2;
	pro7[1].tableID = 16;
	pro7[1].attributeID = 6;
	pro7[2].tableID = 16;
	pro7[2].attributeID = 7;


/* Sort 1 */
	OPERATION_NODE so1[1];
	so1[0].tableID = 0;
	so1[0].attributeID = 0;
	so1[0].position = 1;
	so1[0].option = 1;


	o1 = new Scan(&db_r, attriRec_r, 3);
//	cout << "OK new o1" << endl;
	o2 = new Selection((Node *)&an1 ,(unsigned int)1);
//	cout << "OK new o2" << endl;
	o2->setPreOperator(o1);
	//r_regionkey
	o3 = new Projection(pro1, 1);
	o3->setPreOperator(o2);
//	cout << "OK new o3" << endl;
	
	o4 = new Scan(&db_n, attriRec_n, 4);
//	cout << "OK new o4" << endl;
	o5 = new OneSideHashJoin(o3, o4 , jpn1, 1);
//	cout << "OK new o5" << endl;
	//n_natonkey, n_name
	o6 = new Projection(pro2, 2);
	o6->setPreOperator(o5);
//	cout << "OK new o6" << endl;
	
	
	o7 = new Scan(&db_s, attriRec_s, 7);
//	cout << "OK new o7" << endl;
	o8 = new OneSideHashJoin(o6, o7 , jpn2, 1);
//	cout << "OK new o8" << endl;
	//s_suppkey, s_nationkey, n_name
	o9 = new Projection(pro3, 3);
	o9->setPreOperator(o8);
//	cout << "OK new o9" << endl;


	o10 = new Scan(&db_l, attriRec_l, 16);
//	cout << "OK new o10" << endl;
	
	o11 = new OneSideHashJoin(o9, o10 , jpn3, 1);
//	cout << "OK new o11" << endl;
	//l_orderkey, l_extendedprice, l_discount, s_nationkey, n_name
	o12 = new Projection(pro4, 5);
	o12->setPreOperator(o11);
//	cout << "OK new o12" << endl;

	o13 = new Scan(&db_o, attriRec_o, 9);
//	cout << "OK new o13" << endl;
	
	o14 = new Selection((Node *)&an4 ,(unsigned int)2);
//	cout << "OK new o14" << endl;
	o14->setPreOperator(o13);
	//o_orderkey, o_custkey
	o15 = new Projection(pro5, 2);
	o15->setPreOperator(o14);
//	cout << "OK new o15" << endl;
	
	o16 = new OneSideHashJoin(o15, o12 , jpn4, 1);
//	cout << "OK new o16" << endl;

	o17 = new Scan(&db_c, attriRec_c, 8);
//	cout << "OK new o17" << endl;
	//c_custkey, c_nationkey 
	o18 = new Projection(pro6, 2);
	o18->setPreOperator(o17);
//	cout << "OK new o18" << endl;
	
	o19 = new OneSideHashJoin(o18, o16 , jpn5, 2);
//	cout << "OK new o19" << endl;
	//n_name, l_extendedprice, l_discount
	o20 = new Projection(pro7, 3);
	o20->setPreOperator(o19);
//	cout << "OK new o20" << endl;

	o21 = new GroupBy(group, 1, aggre, 1);
	o21->setPreOperator(o20);
//	cout << "OK new o21" << endl;

	o22 = new Sort(so1, 1);
	o22->setPreOperator(o21);
//	cout << "OK new o22" << endl;


	o23 = new OutPut(STD_OUT);
//	cout << "OK new o23" << endl;

	o23->setPreOperator(o22);
	o23->init(env->getEnv());
	cout << "TEST START Q5 NSM20" << endl;
	
	cout << setprecision(2);
	cout << setiosflags(ios::fixed); 
	o23->exec();
}
Example #6
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db_r_1(env->getEnv(), "1.1.DSM");
	BDBOpe db_r_2(env->getEnv(), "1.2.DSM");
	BDBOpe db_n_1(env->getEnv(), "2.1.DSM");
	BDBOpe db_n_2(env->getEnv(), "2.2.DSM");
	BDBOpe db_n_3(env->getEnv(), "2.3.DSM");
	BDBOpe db_s_1(env->getEnv(), "3.1.DSM");
	BDBOpe db_s_4(env->getEnv(), "3.4.DSM");
	BDBOpe db_c_1(env->getEnv(), "6.1.DSM");
	BDBOpe db_c_4(env->getEnv(), "6.4.DSM");
	BDBOpe db_o_1(env->getEnv(), "7.1.DSM");
	BDBOpe db_o_2(env->getEnv(), "7.2.DSM");
	BDBOpe db_o_5(env->getEnv(), "7.5.DSM");
	BDBOpe db_l_1(env->getEnv(), "8.1.DSM");
	BDBOpe db_l_3(env->getEnv(), "8.3.DSM");
	BDBOpe db_l_6(env->getEnv(), "8.6.DSM");
	BDBOpe db_l_7(env->getEnv(), "8.7.DSM");
	
	db_r_1.open();
	db_r_2.open();
	db_n_1.open();
	db_n_2.open();
	db_n_3.open();
	db_s_1.open();
	db_s_4.open();
	db_c_1.open();
	db_c_4.open();
	db_o_1.open();
	db_o_2.open();
	db_o_5.open();
	db_l_1.open();
	db_l_3.open();
	db_l_6.open();
	db_l_7.open();


	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23, *o24, *o25, *o26, *o27, *o28, *o29, *o30;
	Operator *o31, *o32, *o33, *o34, *o35, *o36, *o37, *o38, *o39;



	TABLE_REC tableRec_r;
	TABLE_REC tableRec_n;
	TABLE_REC tableRec_c;
	TABLE_REC tableRec_o;
	TABLE_REC tableRec_l;
	TABLE_REC tableRec_s;

	
/* set table info */
	tableRec_r.tableID = 1;
	tableRec_r.attriNum = 3;
	
	tableRec_n.tableID = 2;
	tableRec_n.attriNum = 4;
	
	tableRec_s.tableID = 3;
	tableRec_s.attriNum = 7;
	
	tableRec_c.tableID = 6;
	tableRec_c.attriNum = 8;

	tableRec_o.tableID = 7;
	tableRec_o.attriNum = 9;
	
	tableRec_l.tableID = 8;
	tableRec_l.attriNum = 16;
	


/* aet attriRec */
	ATTRIBUTE_REC attriRec_r[tableRec_r.attriNum];
	ATTRIBUTE_REC attriRec_n[tableRec_n.attriNum];
	ATTRIBUTE_REC attriRec_s[tableRec_s.attriNum];
	ATTRIBUTE_REC attriRec_c[tableRec_c.attriNum];
	ATTRIBUTE_REC attriRec_o[tableRec_o.attriNum];
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];
	

	AttributeManager AM(env->getEnv());
	

	AM.getForTableID(tableRec_r, attriRec_r);
	AM.getForTableID(tableRec_n, attriRec_n);
	AM.getForTableID(tableRec_c, attriRec_c);
	AM.getForTableID(tableRec_o, attriRec_o);
	AM.getForTableID(tableRec_l, attriRec_l);
	AM.getForTableID(tableRec_s, attriRec_s);

/* selection1 */
	FixStrPosVal pv1(1,25);
	string str1("ASIA");
	pv1.setStr(str1);

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 1;
	cn1.attriID = 2;
	AxprNode an1 = AxprNode(EQ, &cn1, &vn1);
	

/* selection2 */

	DatePosVal pv2(1,(unsigned char *)"1994-01-01");
	DatePosVal pv3(1,(unsigned char *)"1995-01-01");
	

	ValueNode vn2 = ValueNode(&pv2);
	ValueNode vn3 = ValueNode(&pv3);
	ColumnRefNode cn2;
	cn2.tableID = 7;
	cn2.attriID = 5;
	AxprNode an2 = AxprNode(GE, &cn2, &vn2);
	AxprNode an3 = AxprNode(LT, &cn2, &vn3);
	AxprNode an4 = AxprNode(AND, &an2, &an3);
	
	
/* GROUP */
	IntPosVal pv5(1, 1);
	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4[2];
	cn4[0].tableID = 8;
	cn4[0].attriID = 6;
	cn4[1].tableID = 8;
	cn4[1].attriID = 7;
	ArithmeticNode arith1(SUB, &vn5, &cn4[1]);
	ArithmeticNode arith2(MUL, &cn4[0], &arith1);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith2, 2);
	
	
	OPERATION_NODE group[1];
	group[0].tableID = 2;
	group[0].attributeID = 2;
	
/* Sort 1 */
	OPERATION_NODE so1[1];
	so1[0].tableID = 0;
	so1[0].attributeID = 0;
	so1[0].position = 1;
	so1[0].option = 1;

/* Projection1 */

	OPERATION_NODE pro1[2];
	pro1[0].tableID = 2;
	pro1[0].attributeID = 1;
	pro1[1].tableID = 2;
	pro1[1].attributeID = 2;
	
/* Projection2 */

	OPERATION_NODE pro2[3];
	pro2[0].tableID = 3;
	pro2[0].attributeID = 1;
	pro2[1].tableID = 3;
	pro2[1].attributeID = 4;
	pro2[2].tableID = 2;
	pro2[2].attributeID = 2;
	
/* Projection3 */

	OPERATION_NODE pro3[3];
	pro3[0].tableID = 2;
	pro3[0].attributeID = 2;
	pro3[1].tableID = 8;
	pro3[1].attributeID = 6;
	pro3[2].tableID = 8;
	pro3[2].attributeID = 7;
	
	
	OPERATION_NODE op1;
	op1.tableID = 2;
	op1.attributeID = 3;
	
	OPERATION_NODE op2;
	op2.tableID = 3;
	op2.attributeID = 4;
	
	OPERATION_NODE op3;
	op3.tableID = 8;
	op3.attributeID = 3;
	
	OPERATION_NODE op4;
	op4.tableID = 7;
	op4.attributeID = 2;
	
	OPERATION_NODE op5;
	op5.tableID = 6;
	op5.attributeID = 4;
	
	
/* Join1 */
	OPERATION_NODE pn1[4];
	pn1[0].tableID = 6;
	pn1[0].attributeID = 1;
	pn1[1].tableID = 6;
	pn1[1].attributeID = 4;
	pn1[2].tableID = 7;
	pn1[2].attributeID = 2;
	pn1[3].tableID = 3;
	pn1[3].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn1[2];
	jpn1[0].rightNode = pn1[0];
	jpn1[0].leftNode = pn1[2];
	jpn1[1].rightNode = pn1[1];
	jpn1[1].leftNode = pn1[3];
	
/* exec */
	
	o1 = new ScanDSM(&db_r_2, &attriRec_r[1], 1);
//	cout << "OK new o1" << endl;
	
	o2 = new SelectBitOut((Node *)&an1 ,(unsigned int)1);
//	cout << "OK new o2" << endl;
	o2->setPreOperator(o1);
	
	o3 = new ScanDSM(&db_r_1, &attriRec_r[0], 1);
//	cout << "OK new o3" << endl;
	
	o4 = new BitFilter(o3, o2);
//	cout << "OK new o4" << endl;

	o5 = new ScanDSM(&db_n_3, &attriRec_n[2], 1);
//	cout << "OK new o5" << endl;
	
	o6 = new JoinIndex_OneHash(o4, o5); 
//	cout << "OK new o6" << endl;

	
	o7 = new ScanDSM(&db_n_1, &attriRec_n[0], 1);
//	cout << "OK new o7" << endl;
	
	o8 = new ScanFromJI(o7, o6, &op1);
//	cout << "OK new o8" << endl;
	
	o9 = new ScanDSM(&db_n_2, &attriRec_n[1], 1);
//	cout << "OK new o9" << endl;
	
	//n_name, n_natonkey, r_regionkey, n_nationkey
	o10 = new ScanFromJI(o9, o8, &op1);
//	cout << "OK new o10" << endl;
	
	//n_name, n_natonkey
	o11 = new Projection(pro1, 2);
	o11->setPreOperator(o10);
//	cout << "OK new o11" << endl;
	
	o12 = new ScanDSM(&db_s_4, &attriRec_s[3], 1);
//	cout << "OK new o12" << endl;
	
	o13 = new JoinIndex_OneHash(o11, o12); 
//	cout << "OK new o13" << endl;
	
	o14 = new ScanDSM(&db_s_1, &attriRec_s[0], 1);
//	cout << "OK new o14" << endl;
	
	o15 = new ScanFromJI(o14, o13, &op2);
//	cout << "OK new o15" << endl;
	
	//s_suppkey s_nationkey n_name
	o16 = new Projection(pro2, 3);
	o16->setPreOperator(o15);
//	cout << "OK new o16" << endl;
	
	o17 = new ScanDSM(&db_l_3, &attriRec_l[2], 1);
//	cout << "OK new o17" << endl;
	
	o18 = new JoinIndex_OneHash(o16, o17); 
//	cout << "OK new o18" << endl;
	
	o19 = new ScanDSM(&db_l_6, &attriRec_l[5], 1);
//	cout << "OK new o19" << endl;
	
	o20 = new ScanFromJI(o19, o18, &op3);
//	cout << "OK new o20" << endl;
	
	o21 = new ScanDSM(&db_l_7, &attriRec_l[6], 1);
//	cout << "OK new o21" << endl;
	
	o22 = new ScanFromJI(o21, o20, &op3);
//	cout << "OK new o22" << endl;
	
	o23 = new ScanDSM(&db_l_1, &attriRec_l[0], 1);
//	cout << "OK new o23" << endl;
	
	//l_orderkey, l_extendedprice, l_discount, s_suppkey, s_nationkey, n_name, l_suppkey
	o24 = new ScanFromJI(o23, o22, &op3);
//	cout << "OK new o24" << endl;
	
	
	
	o25 = new ScanDSM(&db_o_5, &attriRec_o[4], 1);
//	cout << "OK new o25" << endl;
	
	o26 = new SelectBitOut((Node *)&an4 ,(unsigned int)2);
//	cout << "OK new o26" << endl;
	o26->setPreOperator(o25);
	
	o27 = new ScanDSM(&db_o_2, &attriRec_o[1], 1);
//	cout << "OK new o27" << endl;
	
	o28 = new BitFilter(o27, o26);
//	cout << "OK new o28" << endl;
	
	o29 = new ScanDSM(&db_o_1, &attriRec_o[0], 1);
//	cout << "OK new o29" << endl;
	
	//o_order, o_custkey
	o30 = new ScanFromJI(o29, o28, &op4);
//	cout << "OK new o30" << endl;
	
	//o_custkey, o_orderkey, l_orderkey, l_extendedprice, l_discount, s_suppkey, s_nationkey, n_name, l_suppkey
	o31 = new JoinIndex_OneHash(o30, o24); 
//	cout << "OK new o31" << endl;

	o32 = new ScanDSM(&db_c_4, &attriRec_c[3], 1);
//	cout << "OK new o32" << endl;
	
	o33 = new ScanDSM(&db_c_1, &attriRec_c[0], 1);
//	cout << "OK new o33" << endl;
	
	o34 = new ScanFromJI(o33, o32, &op5);
//	cout << "OK new o34" << endl;
	
	o35 = new OneSideHashJoin(o34, o31 , jpn1, 2);
//	cout << "OK new o31" << endl;
	
	
	o36 = new Projection(pro3, 3);
	o36->setPreOperator(o35);
//	cout << "OK new o36" << endl;
	
	o37 = new GroupBy(group, 1, aggre, 1);
	o37->setPreOperator(o36);
//	cout << "OK new o37" << endl;

	o38 = new Sort(so1, 1);
	o38->setPreOperator(o37);
//	cout << "OK new o38" << endl;
	
	o39 = new OutPut(STD_OUT);
//	cout << "OK new o39" << endl;

	o39->setPreOperator(o38);
	o39->init(env->getEnv());
	cout << "TEST START" << endl;
	
	cout << setprecision(4);
	cout << setiosflags(ios::fixed); 
	o39->exec();
}
Example #7
0
	disable_hardware_cursor();
	return true;
}

struct VkMapping {
	uint16 vk_from;
	byte vk_count;
	byte map_to;
};

#define AS(x, z) {x, 0, z}
#define AM(x, y, z, w) {x, y - x, z}

static const VkMapping _vk_mapping[] = {
	/* Pageup stuff + up/down */
	AM(KEY_PGUP, KEY_PGDN, WKC_PAGEUP, WKC_PAGEDOWN),
	AS(KEY_UP,     WKC_UP),
	AS(KEY_DOWN,   WKC_DOWN),
	AS(KEY_LEFT,   WKC_LEFT),
	AS(KEY_RIGHT,  WKC_RIGHT),

	AS(KEY_HOME,   WKC_HOME),
	AS(KEY_END,    WKC_END),

	AS(KEY_INSERT, WKC_INSERT),
	AS(KEY_DEL,    WKC_DELETE),

	/* Map letters & digits */
	AM(KEY_A, KEY_Z, 'A', 'Z'),
	AM(KEY_0, KEY_9, '0', '9'),
Example #8
0
	MyShowCursor(false, true);
	return true;
}

struct VkMapping {
	byte vk_from;
	byte vk_count;
	byte map_to;
};

#define AS(x, z) {x, 0, z}
#define AM(x, y, z, w) {x, y - x, z}

static const VkMapping _vk_mapping[] = {
	/* Pageup stuff + up/down */
	AM(VK_PRIOR, VK_DOWN, WKC_PAGEUP, WKC_DOWN),
	/* Map letters & digits */
	AM('A', 'Z', 'A', 'Z'),
	AM('0', '9', '0', '9'),

	AS(VK_ESCAPE,   WKC_ESC),
	AS(VK_PAUSE,    WKC_PAUSE),
	AS(VK_BACK,     WKC_BACKSPACE),
	AM(VK_INSERT,   VK_DELETE, WKC_INSERT, WKC_DELETE),

	AS(VK_SPACE,    WKC_SPACE),
	AS(VK_RETURN,   WKC_RETURN),
	AS(VK_TAB,      WKC_TAB),

	/* Function keys */
	AM(VK_F1, VK_F12, WKC_F1, WKC_F12),
Example #9
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db_r_1(env->getEnv(), "1.1.DSM");
	BDBOpe db_r_2(env->getEnv(), "1.2.DSM");
	BDBOpe db_n_1(env->getEnv(), "2.1.DSM");
	BDBOpe db_n2_1(env->getEnv(), "2.1.DSM");
	BDBOpe db_n2_2(env->getEnv(), "2.2.DSM");
	BDBOpe db_n_3(env->getEnv(), "2.3.DSM");
	BDBOpe db_s_1(env->getEnv(), "3.1.DSM");
	BDBOpe db_s_4(env->getEnv(), "3.4.DSM");
	BDBOpe db_p_1(env->getEnv(), "4.1.DSM");
	BDBOpe db_p_5(env->getEnv(), "4.5.DSM");
	BDBOpe db_c_1(env->getEnv(), "6.1.DSM");
	BDBOpe db_c_4(env->getEnv(), "6.4.DSM");
	BDBOpe db_o_1(env->getEnv(), "7.1.DSM");
	BDBOpe db_o_2(env->getEnv(), "7.2.DSM");
	BDBOpe db_o_5(env->getEnv(), "7.5.DSM");
	BDBOpe db_l_1(env->getEnv(), "8.1.DSM");
	BDBOpe db_l_2(env->getEnv(), "8.2.DSM");
	BDBOpe db_l_3(env->getEnv(), "8.3.DSM");
	BDBOpe db_l_6(env->getEnv(), "8.6.DSM");
	BDBOpe db_l_7(env->getEnv(), "8.7.DSM");

	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23, *o24, *o25, *o26, *o27, *o28, *o29, *o30;
	Operator *o31, *o32, *o33, *o34, *o35, *o36, *o37, *o38, *o39, *o40;
	Operator *o41, *o42, *o43, *o44, *o45, *o46, *o47, *o48, *o49, *o50, *o51;
	db_r_1.open();
	db_r_2.open();
	db_n_1.open();
	db_n2_1.open();
	db_n2_2.open();
	db_n_3.open();
	db_s_1.open();
	db_s_4.open();
	db_p_1.open();
	db_p_5.open();
	db_c_1.open();
	db_c_4.open();
	db_o_1.open();
	db_o_2.open();
	db_o_5.open();
	
	db_l_1.open();
	db_l_2.open();
	db_l_3.open();
	db_l_6.open();
	db_l_7.open();
	
	TABLE_REC tableRec_r;
	TABLE_REC tableRec_n;
	TABLE_REC tableRec_s;
	TABLE_REC tableRec_p;
	TABLE_REC tableRec_c;
	TABLE_REC tableRec_o;
	TABLE_REC tableRec_l;

	tableRec_r.tableID = 1;
	tableRec_r.attriNum = 3;

	tableRec_n.tableID = 2;
	tableRec_n.attriNum = 4;
	
	tableRec_s.tableID = 3;
	tableRec_s.attriNum = 7;
	
	tableRec_p.tableID = 4;
	tableRec_p.attriNum = 9;
	
	tableRec_c.tableID = 6;
	tableRec_c.attriNum = 8;
	
	tableRec_o.tableID = 7;
	tableRec_o.attriNum = 9;
	
	tableRec_l.tableID = 8;
	tableRec_l.attriNum = 16;
	
	
	ATTRIBUTE_REC attriRec_r[tableRec_r.attriNum];
	ATTRIBUTE_REC attriRec_n[tableRec_n.attriNum];
	ATTRIBUTE_REC attriRec_s[tableRec_s.attriNum];
	ATTRIBUTE_REC attriRec_p[tableRec_p.attriNum];
	ATTRIBUTE_REC attriRec_c[tableRec_c.attriNum];
	ATTRIBUTE_REC attriRec_o[tableRec_o.attriNum];
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];

	AttributeManager AM(env->getEnv());
	
	AM.getForTableID(tableRec_r, attriRec_r);
/*	for(int i=0 ; i < (int)tableRec_r.attriNum ; i++){
		cout << attriRec_r[i].attributeName << endl;
	}
*/
	AM.getForTableID(tableRec_n, attriRec_n);
/*	for(int i=0 ; i < (int)tableRec_n.attriNum ; i++){
		cout << attriRec_n[i].attributeName << endl;
	}
*/
	AM.getForTableID(tableRec_s, attriRec_s);
/*	for(int i=0 ; i < (int)tableRec_s.attriNum ; i++){
		cout << attriRec_s[i].attributeName << endl;
	}
*/
	AM.getForTableID(tableRec_p, attriRec_p);
/*	for(int i=0 ; i < (int)tableRec_p.attriNum ; i++){
		cout << attriRec_p[i].attributeName << endl;
	}
*/
	AM.getForTableID(tableRec_c, attriRec_c);
/*	for(int i=0 ; i < (int)tableRec_c.attriNum ; i++){
		cout << attriRec_c[i].attributeName << endl;
	}
*/
	AM.getForTableID(tableRec_o, attriRec_o);
/*	for(int i=0 ; i < (int)tableRec_o.attriNum ; i++){
		cout << attriRec_o[i].attributeName << endl;
	}
*/
	AM.getForTableID(tableRec_l, attriRec_l);
/*	for(int i=0 ; i < (int)tableRec_l.attriNum ; i++){
		cout << attriRec_l[i].attributeName << endl;
	}
*/

/* selection1 */
	FixStrPosVal pv1(1,25);
	string str1("AMERICA");
	pv1.setStr(str1);

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 1;
	cn1.attriID = 2;
	AxprNode an1 = AxprNode(EQ, &cn1, &vn1);
	

/* selection2 */

	DatePosVal pv2(1,(unsigned char *)"1995-01-01");
	DatePosVal pv3(1,(unsigned char *)"1996-12-31");
	

	ValueNode vn2 = ValueNode(&pv2);
	ValueNode vn3 = ValueNode(&pv3);
	ColumnRefNode cn2;
	cn2.tableID = 7;
	cn2.attriID = 5;
	AxprNode an2 = AxprNode(GE, &cn2, &vn2);
	AxprNode an3 = AxprNode(LE, &cn2, &vn3);
	AxprNode an4 = AxprNode(AND, &an2, &an3);

/* selection3 */
	VarStrPosVal pv4(1,25);
	string str2("ECONOMY ANODIZED STEEL");
	pv4.set((unsigned char*)str2.c_str());

	ValueNode vn4 = ValueNode(&pv4);
	ColumnRefNode cn3;
	cn3.tableID = 4;
	cn3.attriID = 5;
	AxprNode an5 = AxprNode(EQ, &cn3, &vn4);
	

	
/*Join1*/
	OPERATION_NODE jop1, jop2;
	jop1.tableID = 6;
	jop1.attributeID = 4;
	jop2.tableID = 6;
	jop2.attributeID = 1;
	
	JOIN_OPERATION_NODE jon1;
	jon1.rightNode = jop1;
	jon1.leftNode = jop2;

/*Join2*/
	OPERATION_NODE jop3, jop4;
	jop3.tableID = 7;
	jop3.attributeID = 2;
	jop4.tableID = 7;
	jop4.attributeID = 5;
	
	JOIN_OPERATION_NODE jon2;
	jon2.rightNode = jop3;
	jon2.leftNode = jop4;

/*Join3*/
	OPERATION_NODE jop5, jop6;
	jop5.tableID = 7;
	jop5.attributeID = 5;
	jop6.tableID = 7;
	jop6.attributeID = 1;
	
	JOIN_OPERATION_NODE jon3;
	jon3.rightNode = jop5;
	jon3.leftNode = jop6;

/*Join4*/
	OPERATION_NODE jop7, jop8;
	jop7.tableID = 7;
	jop7.attributeID = 1;
	jop8.tableID = 8;
	jop8.attributeID = 1;
	
	JOIN_OPERATION_NODE jon4;
	jon4.rightNode = jop7;
	jon4.leftNode = jop8;
	
/*Join5*/
	OPERATION_NODE jop9, jop10;
	jop9.tableID = 4;
	jop9.attributeID = 1;
	jop10.tableID = 8;
	jop10.attributeID = 2;
	
	JOIN_OPERATION_NODE jon5;
	jon5.rightNode = jop9;
	jon5.leftNode = jop10;

/*Join6*/
	OPERATION_NODE jop11, jop12;
	jop11.tableID = 6;
	jop11.attributeID = 1;
	jop12.tableID = 7;
	jop12.attributeID = 2;
	
	JOIN_OPERATION_NODE jon6;
	jon6.rightNode = jop11;
	jon6.leftNode = jop12;
	
/*Join7*/
	OPERATION_NODE jop13, jop14;
	jop13.tableID = 3;
	jop13.attributeID = 1;
	jop14.tableID = 8;
	jop14.attributeID = 3;
	
	JOIN_OPERATION_NODE jon7;
	jon7.rightNode = jop13;
	jon7.leftNode = jop14;
	
/*Join8*/
	OPERATION_NODE jop15, jop16;
	jop15.tableID = 2;
	jop15.attributeID = 1;
	jop16.tableID = 3;
	jop16.attributeID = 4;
	
	JOIN_OPERATION_NODE jon8;
	jon8.rightNode = jop15;
	jon8.leftNode = jop16;
	
/* Projection1 */

	OPERATION_NODE pro1[1];
	pro1[0].tableID = 6;
	pro1[0].attributeID = 1;
	
	
/* Projection2 */

	OPERATION_NODE pro2[2];
	pro2[0].tableID = 7;
	pro2[0].attributeID = 1;
	pro2[1].tableID = 7;
	pro2[1].attributeID = 5;
	
/* Projection3 */

	OPERATION_NODE pro3[1];
	pro3[0].tableID = 8;
	pro3[0].attributeID = 2;
	
/* Projection4 */

	OPERATION_NODE pro4[2];
	pro4[0].tableID = 8;
	pro4[0].attributeID = 3;
	pro4[1].tableID = 2;
	pro4[1].attributeID = 2;

/* Projection5 */

	OPERATION_NODE pro5[4];
	pro5[0].tableID = 7;
	pro5[0].attributeID = 5;
	pro5[1].tableID = 2;
	pro5[1].attributeID = 2;
	pro5[2].tableID = 8;
	pro5[2].attributeID = 6;
	pro5[3].tableID = 8;
	pro5[3].attributeID = 7;

/* Extract */
	OPERATION_NODE ex[1];
	ex[0].tableID = 7;
	ex[0].attributeID = 5;

/* GROUP */
	IntPosVal pv5(1, 1);
	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4[2];
	cn4[0].tableID = 8;
	cn4[0].attriID = 6;
	cn4[1].tableID = 8;
	cn4[1].attriID = 7;
	ArithmeticNode arith1(SUB, &vn5, &cn4[1]);
	ArithmeticNode arith2(MUL, &cn4[0], &arith1);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith2, 2);
	
	
	OPERATION_NODE group[1];
	group[0].tableID = 7;
	group[0].attributeID = 5;

/* Sort 1 */
	OPERATION_NODE so1[1];
	so1[0].tableID = 7;
	so1[0].attributeID = 5;
	so1[0].option = 0;
	
	


	OPERATION_NODE op1;
	op1.tableID = 2;
	op1.attributeID = 3;
	
	OPERATION_NODE op2;
	op2.tableID = 6;
	op2.attributeID = 4;
	
	OPERATION_NODE op3;
	op3.tableID = 7;
	op3.attributeID = 5;
	
	OPERATION_NODE op4;
	op4.tableID = 8;
	op4.attributeID = 1;
	
	OPERATION_NODE op5;
	op5.tableID = 3;
	op5.attributeID = 4;
	
	OPERATION_NODE op6;
	op6.tableID = 2;
	op6.attributeID = 2;
	
	OPERATION_NODE op7;
	op7.tableID = 8;
	op7.attributeID = 2;


	o1 = new ScanDSM(&db_r_2, &attriRec_r[1], 1);
	
	o2 = new SelectBitOut((Node *)&an1 ,(unsigned int)1);
	o2->setPreOperator(o1);
	
	o3 = new ScanDSM(&db_r_1, &attriRec_r[0], 1); 
	
	o4 = new BitFilter(o3, o2);
	
	o5 = new ScanDSM(&db_n_3, &attriRec_n[2], 1);
	
	o6 = new JoinIndex_OneHash(o4, o5); 
	
	o7 = new ScanDSM(&db_n_1, &attriRec_n[0], 1);
	
	o8 = new ScanFromJI(o7, o6, &op1);

	o9 = new ScanDSM(&db_c_4, &attriRec_c[3], 1);

	o10 = new JoinIndex_OneHash(o8, o9); 
	
	o11 = new ScanDSM(&db_c_1, &attriRec_c[0], 1);
	
	o12 = new ScanFromJI(o11, o10, &op2);
	
	o13 = new Projection(pro1, 1);
	o13->setPreOperator(o12);
	
/*	
	
	o14 = new ScanDSM(&db_o_2, &attriRec_o[1], 1);
//	cout << "OK new o14" << endl;
	
	o15 = new JoinIndex_OneHash(o13, o14); 
//	cout << "OK new o15" << endl;
	
*/
	o14 = new ScanDSM(&db_o_5, &attriRec_o[4], 1);

	o15 = new Selection((Node *)&an4 ,(unsigned int)2);
	o15->setPreOperator(o14);
	
	o16 = new ScanDSM(&db_o_2, &attriRec_o[1], 1);
	
	o17 = new ScanFromJI(o16, o15, &op3);
	
	o18 = new ScanDSM(&db_o_1, &attriRec_o[0], 1);
	
	o19 = new ScanFromJI(o18, o17, &op3);
	
	
	
	o20 = new ScanDSM(&db_p_5, &attriRec_p[4], 1);

	o21 = new SelectBitOut((Node *)&an5 ,1);
	o21->setPreOperator(o20);
	
	o22 = new ScanDSM(&db_p_1, &attriRec_p[0], 1);

	o23 = new BitFilter(o22, o21);
	
	o24 = new ScanDSM(&db_l_2, &attriRec_l[1], 1);
	
	o25 = new JoinIndex_OneHash(o23, o24, &jon5); 



	o26 = new ScanDSM(&db_l_1, &attriRec_l[0], 1);
	o27 = new ScanFromJI(o26, o25, &op7);
	
	
	o28 = new JoinIndex_OneHash(o19, o27, &jon4);
	o29 = new JoinIndex_OneHash(o13, o28, &jon6);
	
	o30 = new ScanDSM(&db_s_4, &attriRec_s[3], 1);
	
	o31 = new ScanDSM(&db_s_1, &attriRec_s[0], 1);
	
	o32 = new ScanFromJI(o31, o30, &op5);
	
	
	
	o33 = new ScanDSM(&db_l_3, &attriRec_l[2], 1);
	o34 = new ScanFromJI(o33, o29, &op7);
	
	o35 = new JoinIndex_OneHash(o32, o34, &jon7);
	
	
	
	o36 = new ScanDSM(&db_n2_1, &attriRec_n[0], 1);
	o37 = new ScanDSM(&db_n2_2, &attriRec_n[1], 1);
	o38 = new ScanFromJI(o36, o37, &op6);
	
	o40 = new JoinIndex_OneHash(o38, o35, &jon8);
	
	
	
	o41 = new ScanDSM(&db_l_6, &attriRec_l[5], 1);
	o42 = new ScanFromJI(o41, o40, &op4);


	o43 = new ScanDSM(&db_l_7, &attriRec_l[6], 1);
	o44 = new ScanFromJI(o43, o42, &op4);

	o45 = new Projection(pro5, 4);
	o45->setPreOperator(o44);
	
	o46 = new Extract(ex, true, false, false);
	o46->setPreOperator(o45);
	
	o47 = new GroupBy(group, 1, aggre, 1);
	o47->setPreOperator(o46);
	
	o48 = new Sort(so1, 1);
	o48->setPreOperator(o47);


	o49 = new OutPut(TIME_OUT);
	o49->setPreOperator(o48);
	o49->init(env->getEnv());
	cout << "TEST START" << endl;
	
	cout << setprecision(2);
	cout << setiosflags(ios::fixed);
	o49->exec();
}
Example #10
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db_r_1(env->getEnv(), "1.1.DSM");
	BDBOpe db_r_2(env->getEnv(), "1.2.DSM");
	BDBOpe db_n_1(env->getEnv(), "2.1.DSM");
	BDBOpe db_n_2(env->getEnv(), "2.2.DSM");
	BDBOpe db_n_3(env->getEnv(), "2.3.DSM");
	BDBOpe db_s_1(env->getEnv(), "3.1.DSM");
	BDBOpe db_s_4(env->getEnv(), "3.4.DSM");
	BDBOpe db_c_1(env->getEnv(), "6.1.DSM");
	BDBOpe db_c_4(env->getEnv(), "6.4.DSM");
	BDBOpe db_o(env->getEnv(), "ORDERS.row");
	BDBOpe db_l(env->getEnv(), "LINEITEM.row");
	
	SecondDB *sDB,*sDB_o;
	int (*pf)(Db *sdbp, const Dbt*pkey, const Dbt *pdata, Dbt *skey);
	pf = L_1_secondary;
	sDB = new SecondDB(env->getEnv(), "8.1.secondary");
	sDB->setNumCmp();
	
	int (*pf_o)(Db *sdbp, const Dbt*pkey, const Dbt *pdata, Dbt *skey);
	pf_o = O_2_secondary;
	sDB_o = new SecondDB(env->getEnv(), "7.2.secondary");
	sDB_o->setNumCmp();
	
	db_r_1.open();
	db_r_2.open();
	db_n_1.open();
	db_n_2.open();
	db_n_3.open();
	db_s_1.open();
	db_s_4.open();
	db_c_1.open();
	db_c_4.open();
	db_o.open();
	db_l.open();
	sDB->open(0);
	db_l.associate(sDB->getDb(), pf);
	sDB->openCursor();
	sDB_o->open(0);
	db_o.associate(sDB_o->getDb(), pf_o);
	sDB_o->openCursor();


	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23, *o24, *o25, *o26, *o27, *o28, *o29, *o30;
	Operator *o31, *o32, *o33, *o34, *o35, *o36, *o37, *o38, *o39, *o40;



	TABLE_REC tableRec_r;
	TABLE_REC tableRec_n;
	TABLE_REC tableRec_c;
	TABLE_REC tableRec_o;
	TABLE_REC tableRec_l;
	TABLE_REC tableRec_s;

	
/* set table info */
	tableRec_r.tableID = 1;
	tableRec_r.attriNum = 3;
	
	tableRec_n.tableID = 2;
	tableRec_n.attriNum = 4;
	
	tableRec_s.tableID = 3;
	tableRec_s.attriNum = 7;
	
	tableRec_c.tableID = 6;
	tableRec_c.attriNum = 8;

	tableRec_o.tableID = 7;
	tableRec_o.attriNum = 9;
	
	tableRec_l.tableID = 8;
	tableRec_l.attriNum = 16;
	


/* aet attriRec */
	ATTRIBUTE_REC attriRec_r[tableRec_r.attriNum];
	ATTRIBUTE_REC attriRec_n[tableRec_n.attriNum];
	ATTRIBUTE_REC attriRec_s[tableRec_s.attriNum];
	ATTRIBUTE_REC attriRec_c[tableRec_c.attriNum];
	ATTRIBUTE_REC attriRec_o[tableRec_o.attriNum];
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];
	

	AttributeManager AM(env->getEnv());
	

	AM.getForTableID(tableRec_r, attriRec_r);
	AM.getForTableID(tableRec_n, attriRec_n);
	AM.getForTableID(tableRec_c, attriRec_c);
	AM.getForTableID(tableRec_o, attriRec_o);
	AM.getForTableID(tableRec_l, attriRec_l);
	AM.getForTableID(tableRec_s, attriRec_s);

/* selection1 */
	FixStrPosVal pv1(1,25);
	string str1("ASIA");
	pv1.setStr(str1);

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 1;
	cn1.attriID = 2;
	AxprNode an1 = AxprNode(EQ, &cn1, &vn1);
	

/* selection2 */

	DatePosVal pv2(1,(unsigned char *)"1994-01-01");
	DatePosVal pv3(1,(unsigned char *)"1995-01-01");
	

	ValueNode vn2 = ValueNode(&pv2);
	ValueNode vn3 = ValueNode(&pv3);
	ColumnRefNode cn2;
	cn2.tableID = 7;
	cn2.attriID = 5;
	AxprNode an2 = AxprNode(GE, &cn2, &vn2);
	AxprNode an3 = AxprNode(LT, &cn2, &vn3);
	AxprNode an4 = AxprNode(AND, &an2, &an3);
	
	
/* GROUP */
	IntPosVal pv5(1, 1);
	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4[2];
	cn4[0].tableID = 8;
	cn4[0].attriID = 6;
	cn4[1].tableID = 8;
	cn4[1].attriID = 7;
	ArithmeticNode arith1(SUB, &vn5, &cn4[1]);
	ArithmeticNode arith2(MUL, &cn4[0], &arith1);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith2, 2);
	
	
	OPERATION_NODE group[1];
	group[0].tableID = 2;
	group[0].attributeID = 2;
	
/* Sort 1 */
	OPERATION_NODE so1[1];
	so1[0].tableID = 0;
	so1[0].attributeID = 0;
	so1[0].position = 1;
	so1[0].option = 1;

/* Projection1 */

	OPERATION_NODE pro1[2];
	pro1[0].tableID = 2;
	pro1[0].attributeID = 1;
	pro1[1].tableID = 2;
	pro1[1].attributeID = 2;
	
/* Projection2 */

	OPERATION_NODE pro2[3];
	pro2[0].tableID = 3;
	pro2[0].attributeID = 1;
	pro2[1].tableID = 3;
	pro2[1].attributeID = 4;
	pro2[2].tableID = 2;
	pro2[2].attributeID = 2;
	
/* Projection3 */

	OPERATION_NODE pro3[3];
	pro3[0].tableID = 2;
	pro3[0].attributeID = 2;
	pro3[1].tableID = 8;
	pro3[1].attributeID = 6;
	pro3[2].tableID = 8;
	pro3[2].attributeID = 7;

/* Projection4 */

	OPERATION_NODE pro4[3];
	pro4[0].tableID = 2;
	pro4[0].attributeID = 2;
	pro4[1].tableID = 6;
	pro4[1].attributeID = 1;
	pro4[2].tableID =6;
	pro4[2].attributeID = 4;

/* Projection5 */

	OPERATION_NODE pro5[3];
	pro5[0].tableID = 2;
	pro5[0].attributeID = 2;
	pro5[1].tableID = 6;
	pro5[1].attributeID = 4;
	pro5[2].tableID = 7;
	pro5[2].attributeID = 1;

/* Projection6 */

	OPERATION_NODE pro6[5];
	pro6[0].tableID = 2;
	pro6[0].attributeID = 2;
	pro6[1].tableID = 6;
	pro6[1].attributeID = 4;
	pro6[2].tableID = 8;
	pro6[2].attributeID = 3;
	pro6[3].tableID = 8;
	pro6[3].attributeID = 6;
	pro6[4].tableID = 8;
	pro6[4].attributeID = 7;

/* Projection11 */
	
	OPERATION_NODE pro11[4];
	pro11[0].tableID = 2;
	pro11[0].attributeID = 2;
	pro11[1].tableID = 6;
	pro11[1].attributeID = 4;
	pro11[2].tableID = 7;
	pro11[2].attributeID = 1;
	pro11[3].tableID = 7;
	pro11[3].attributeID = 5;
	
	
	OPERATION_NODE op1;
	op1.tableID = 2;
	op1.attributeID = 3;
	
	OPERATION_NODE op2;
	op2.tableID = 3;
	op2.attributeID = 4;
	
	OPERATION_NODE op3;
	op3.tableID = 8;
	op3.attributeID = 3;
	
	OPERATION_NODE op4;
	op4.tableID = 7;
	op4.attributeID = 2;
	
	OPERATION_NODE op5;
	op5.tableID = 6;
	op5.attributeID = 4;

/* index position */
	
	OPERATION_NODE pro10[1];
	pro10[0].tableID = 7;
	pro10[0].attributeID = 1;
	
	
/* Join1 */
	OPERATION_NODE pn1[2];
	pn1[0].tableID = 2;
	pn1[0].attributeID = 1;
	pn1[1].tableID = 6;
	pn1[1].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn1[1];
	jpn1[0].rightNode = pn1[0];
	jpn1[0].leftNode = pn1[1];

/* Join2 */
	OPERATION_NODE pn2[2];
	pn2[0].tableID = 6;
	pn2[0].attributeID = 1;
	pn2[1].tableID = 7;
	pn2[1].attributeID = 2;

	
	JOIN_OPERATION_NODE jpn2[1];
	jpn2[0].rightNode = pn2[0];
	jpn2[0].leftNode = pn2[1];
	
/* Join3 */
	OPERATION_NODE pn3[2];
	pn3[0].tableID = 7;
	pn3[0].attributeID = 1;
	pn3[1].tableID = 8;
	pn3[1].attributeID = 1;

	
	JOIN_OPERATION_NODE jpn3[1];
	jpn3[0].rightNode = pn3[0];
	jpn3[0].leftNode = pn3[1];

/* Join4 */
	OPERATION_NODE pn4[4];
	pn4[0].tableID = 3;
	pn4[0].attributeID = 1;
	pn4[1].tableID = 3;
	pn4[1].attributeID = 4;
	pn4[2].tableID = 8;
	pn4[2].attributeID = 3;
	pn4[3].tableID = 6;
	pn4[3].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn4[2];
	jpn4[0].rightNode = pn4[0];
	jpn4[0].leftNode = pn4[2];
	jpn4[1].rightNode = pn4[1];
	jpn4[1].leftNode = pn4[3];

	
/* exec */
	
	o1 = new ScanDSM(&db_r_2, &attriRec_r[1], 1);
	o2 = new SelectBitOut((Node *)&an1 ,(unsigned int)1);
	o2->setPreOperator(o1);
	o3 = new ScanDSM(&db_r_1, &attriRec_r[0], 1);
	o4 = new BitFilter(o3, o2);

	o5 = new ScanDSM(&db_n_3, &attriRec_n[2], 1);
	o6 = new JoinIndex_OneHash(o4, o5); 

	
	o7 = new ScanDSM(&db_n_1, &attriRec_n[0], 1);
	o8 = new ScanFromJI(o7, o6, &op1);
	o9 = new ScanDSM(&db_n_2, &attriRec_n[1], 1);
	//n_name, n_natonkey, r_regionkey, n_nationkey
	o10 = new ScanFromJI(o9, o8, &op1);
	
	//n_name, n_natonkey
	o11 = new Projection(pro1, 2);
	o11->setPreOperator(o10);

	o12 = new ScanDSM(&db_c_4, &attriRec_c[3], 1);
	o13 = new ScanDSM(&db_c_1, &attriRec_c[0], 1);
	o14 = new ScanFromJI(o13, o12, &op5);
	
	o15 = new OneSideHashJoin(o10, o14 , jpn1, 1);
	//n_name, c_custkey, c_nationkey
	o16 = new Projection(pro4, 3);
	o16->setPreOperator(o15);
	
	/* ======== Nested Loop Join with Index ============ */
	IndexScan *IS_o = new IndexScan((BDBOpe *)sDB_o, attriRec_o, 9);
	o17 = new NestedJoin_Index(IS_o, o16, pn2);
	o18 = new Projection(pro11, 4);
	o18->setPreOperator(o17);

	//o17 = new ScanDSM(&db_o_5, &attriRec_o[4], 1);
	o19 = new Selection((Node *)&an4 ,(unsigned int)2);
	o19->setPreOperator(o18);
	//o19 = new ScanDSM(&db_o_2, &attriRec_o[1], 1);
	//o20 = new BitFilter(o19, o18);
	
	/* ======================================================= */
	
	
	//o21 = new ScanDSM(&db_o_1, &attriRec_o[0], 1);
	//o_order, o_custkey
	//o22 = new ScanFromJI(o21, o20, &op4);
	
	//n_name, c_custkey, c_nationkey, o_order, o_custkey
	//o23 = new OneSideHashJoin(o16, o22 , jpn2, 1);
	
	//n_name, c_nationkey, o_order
	o24 = new Projection(pro5, 3);
	o24->setPreOperator(o19);

	/* ======== Nested Loop Join with Index ============ */

	IndexScan *IS = new IndexScan((BDBOpe *)sDB, attriRec_l, 16);
	o25 = new NestedJoin_Index(IS, o24, pro10);
	o26 = new Projection(pro6, 5);
	o26->setPreOperator(o25);
	
	/* ======================================================= */
	
	//l_orderkey, l_extendedprice, l_discount, l_suppkey

	o33 = new ScanDSM(&db_s_4, &attriRec_s[3], 1);
	o34 = new ScanDSM(&db_s_1, &attriRec_s[0], 1);
	o35 = new ScanFromJI(o34, o33, &op2);

	o36 = new OneSideHashJoin(o35, o26 , jpn4, 2);



	o37 = new Projection(pro3, 3);
	o37->setPreOperator(o36);
	
	o38 = new GroupBy(group, 1, aggre, 1);
	o38->setPreOperator(o37);

	o39 = new Sort(so1, 1);
	o39->setPreOperator(o38);
	
	o40 = new OutPut(TIME_OUT);

	o40->setPreOperator(o39);
	o40->init(env->getEnv());
	cout << "TEST START Q5" << endl;
	
	cout << setprecision(4);
	cout << setiosflags(ios::fixed); 
	o40->exec();
}
Example #11
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db_r_1(env->getEnv(), "1.1.DSM");
	BDBOpe db_r_2(env->getEnv(), "1.2.DSM");
	BDBOpe db_n_1(env->getEnv(), "2.1.DSM");
	BDBOpe db_n2_1(env->getEnv(), "2.1.DSM");
	BDBOpe db_n2_2(env->getEnv(), "2.2.DSM");
	BDBOpe db_n_3(env->getEnv(), "2.3.DSM");
	BDBOpe db_s_1(env->getEnv(), "3.1.DSM");
	BDBOpe db_s_4(env->getEnv(), "3.4.DSM");
	BDBOpe db_p_1(env->getEnv(), "4.1.DSM");
	BDBOpe db_p_5(env->getEnv(), "4.5.DSM");
	BDBOpe db_c_1(env->getEnv(), "6.1.DSM");
	BDBOpe db_c_4(env->getEnv(), "6.4.DSM");
	BDBOpe db_o(env->getEnv(), "ORDERS.row");
	BDBOpe db_l(env->getEnv(), "LINEITEM.row");
	
	SecondDB *sDB1;
	int (*pf1)(Db *sdbp, const Dbt*pkey, const Dbt *pdata, Dbt *skey);
	pf1 = L_1_secondary;
	sDB1 = new SecondDB(env->getEnv(), "8.1.secondary");
	sDB1->setNumCmp();
	
	SecondDB *sDB2;
	int (*pf2)(Db *sdbp, const Dbt*pkey, const Dbt *pdata, Dbt *skey);
	pf2 = O_2_secondary;
	sDB2 = new SecondDB(env->getEnv(), "7.2.secondary");
	sDB2->setNumCmp();

	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23, *o24, *o25, *o26, *o27, *o28, *o29, *o30;
	Operator *o31, *o32, *o33, *o34, *o35, *o36, *o37, *o38, *o39, *o40;
	Operator *o41, *o42, *o43, *o44, *o45, *o46, *o47, *o48, *o49, *o50, *o51;
	db_r_1.open();
	db_r_2.open();
	db_n_1.open();
	db_n2_1.open();
	db_n2_2.open();
	db_n_3.open();
	db_s_1.open();
	db_s_4.open();
	db_p_1.open();
	db_p_5.open();
	db_c_1.open();
	db_c_4.open();
	
	
	db_o.open();
	sDB2->open(0);
	db_o.associate(sDB2->getDb(), pf2);
	sDB2->openCursor();
	
	db_l.open();
	sDB1->open(0);
	db_l.associate(sDB1->getDb(), pf1);
	sDB1->openCursor();

	TABLE_REC tableRec_r;
	TABLE_REC tableRec_n;
	TABLE_REC tableRec_s;
	TABLE_REC tableRec_p;
	TABLE_REC tableRec_c;
	TABLE_REC tableRec_o;
	TABLE_REC tableRec_l;

	tableRec_r.tableID = 1;
	tableRec_r.attriNum = 3;

	tableRec_n.tableID = 2;
	tableRec_n.attriNum = 4;
	
	tableRec_s.tableID = 3;
	tableRec_s.attriNum = 7;
	
	tableRec_p.tableID = 4;
	tableRec_p.attriNum = 9;
	
	tableRec_c.tableID = 6;
	tableRec_c.attriNum = 8;
	
	tableRec_o.tableID = 7;
	tableRec_o.attriNum = 9;
	
	tableRec_l.tableID = 8;
	tableRec_l.attriNum = 16;
	
	
	ATTRIBUTE_REC attriRec_r[tableRec_r.attriNum];
	ATTRIBUTE_REC attriRec_n[tableRec_n.attriNum];
	ATTRIBUTE_REC attriRec_s[tableRec_s.attriNum];
	ATTRIBUTE_REC attriRec_p[tableRec_p.attriNum];
	ATTRIBUTE_REC attriRec_c[tableRec_c.attriNum];
	ATTRIBUTE_REC attriRec_o[tableRec_o.attriNum];
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];

	AttributeManager AM(env->getEnv());
	
	AM.getForTableID(tableRec_r, attriRec_r);
	AM.getForTableID(tableRec_n, attriRec_n);
	AM.getForTableID(tableRec_s, attriRec_s);
	AM.getForTableID(tableRec_p, attriRec_p);
	AM.getForTableID(tableRec_c, attriRec_c);
	AM.getForTableID(tableRec_o, attriRec_o);
	AM.getForTableID(tableRec_l, attriRec_l);

/* selection1 */
	FixStrPosVal pv1(1,25);
	string str1("AMERICA");
	pv1.setStr(str1);

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 1;
	cn1.attriID = 2;
	AxprNode an1 = AxprNode(EQ, &cn1, &vn1);
	

/* selection2 */

	DatePosVal pv2(1,(unsigned char *)"1995-01-01");
	DatePosVal pv3(1,(unsigned char *)"1996-12-31");
	

	ValueNode vn2 = ValueNode(&pv2);
	ValueNode vn3 = ValueNode(&pv3);
	ColumnRefNode cn2;
	cn2.tableID = 7;
	cn2.attriID = 5;
	AxprNode an2 = AxprNode(GE, &cn2, &vn2);
	AxprNode an3 = AxprNode(LE, &cn2, &vn3);
	AxprNode an4 = AxprNode(AND, &an2, &an3);

/* selection3 */
	VarStrPosVal pv4(1,25);
	string str2("ECONOMY ANODIZED STEEL");
	pv4.set((unsigned char*)str2.c_str());

	ValueNode vn4 = ValueNode(&pv4);
	ColumnRefNode cn3;
	cn3.tableID = 4;
	cn3.attriID = 5;
	AxprNode an5 = AxprNode(EQ, &cn3, &vn4);
	

	
/*Join1*/
	OPERATION_NODE jop1, jop2;
	jop1.tableID = 6;
	jop1.attributeID = 4;
	jop2.tableID = 6;
	jop2.attributeID = 1;
	
	JOIN_OPERATION_NODE jon1;
	jon1.rightNode = jop1;
	jon1.leftNode = jop2;

/*Join2*/
	OPERATION_NODE jop3, jop4;
	jop3.tableID = 7;
	jop3.attributeID = 2;
	jop4.tableID = 7;
	jop4.attributeID = 5;
	
	JOIN_OPERATION_NODE jon2;
	jon2.rightNode = jop3;
	jon2.leftNode = jop4;

/*Join3*/
	OPERATION_NODE jop5, jop6;
	jop5.tableID = 7;
	jop5.attributeID = 5;
	jop6.tableID = 7;
	jop6.attributeID = 1;
	
	JOIN_OPERATION_NODE jon3;
	jon3.rightNode = jop5;
	jon3.leftNode = jop6;

/*Join4*/
	OPERATION_NODE jop7, jop8;
	jop7.tableID = 7;
	jop7.attributeID = 1;
	jop8.tableID = 8;
	jop8.attributeID = 1;
	
	JOIN_OPERATION_NODE jon4;
	jon4.rightNode = jop7;
	jon4.leftNode = jop8;
	
/*Join5*/
	OPERATION_NODE jop9, jop10;
	jop9.tableID = 4;
	jop9.attributeID = 1;
	jop10.tableID = 8;
	jop10.attributeID = 2;
	
	JOIN_OPERATION_NODE jon5;
	jon5.rightNode = jop9;
	jon5.leftNode = jop10;

/*Join6*/
	OPERATION_NODE jop11, jop12;
	jop11.tableID = 3;
	jop11.attributeID = 1;
	jop12.tableID = 8;
	jop12.attributeID = 3;
	
	JOIN_OPERATION_NODE jon6;
	jon6.rightNode = jop11;
	jon6.leftNode = jop12;
	
/* Projection1 */

	OPERATION_NODE pro1[1];
	pro1[0].tableID = 6;
	pro1[0].attributeID = 1;
	
	
/* Projection2 */

	OPERATION_NODE pro2[2];
	pro2[0].tableID = 7;
	pro2[0].attributeID = 1;
	pro2[1].tableID = 7;
	pro2[1].attributeID = 5;
	
/* Projection3 */

	OPERATION_NODE pro3[1];
	pro3[0].tableID = 8;
	pro3[0].attributeID = 2;
	
/* Projection4 */

	OPERATION_NODE pro4[2];
	pro4[0].tableID = 8;
	pro4[0].attributeID = 3;
	pro4[1].tableID = 2;
	pro4[1].attributeID = 2;

/* Projection5 */

	OPERATION_NODE pro5[4];
	pro5[0].tableID = 7;
	pro5[0].attributeID = 5;
	pro5[1].tableID = 2;
	pro5[1].attributeID = 2;
	pro5[2].tableID = 8;
	pro5[2].attributeID = 6;
	pro5[3].tableID = 8;
	pro5[3].attributeID = 7;
	
/* Projection6 */

	OPERATION_NODE pro6[5];
	pro6[0].tableID = 7;
	pro6[0].attributeID = 5;
	pro6[1].tableID = 8;
	pro6[1].attributeID = 2;
	pro6[2].tableID = 8;
	pro6[2].attributeID = 3;
	pro6[3].tableID = 8;
	pro6[3].attributeID = 6;
	pro6[4].tableID = 8;
	pro6[4].attributeID = 7;

/* Projection7 */

	OPERATION_NODE pro7[4];
	pro7[0].tableID = 7;
	pro7[0].attributeID = 5;
	pro7[1].tableID = 8;
	pro7[1].attributeID = 3;
	pro7[2].tableID = 8;
	pro7[2].attributeID = 6;
	pro7[3].tableID = 8;
	pro7[3].attributeID = 7;

/* Projection8 */

	OPERATION_NODE pro8[2];
	pro8[0].tableID = 3;
	pro8[0].attributeID = 1;
	pro8[1].tableID = 2;
	pro8[1].attributeID = 2;

/* Projection9 */

	OPERATION_NODE pro9[4];
	pro9[0].tableID = 2;
	pro9[0].attributeID = 2;
	pro9[1].tableID = 7;
	pro9[1].attributeID = 5;
	pro9[2].tableID = 8;
	pro9[2].attributeID = 6;
	pro9[3].tableID = 8;
	pro9[3].attributeID = 7;

/* Extract */
	OPERATION_NODE ex[1];
	ex[0].tableID = 7;
	ex[0].attributeID = 5;

/* GROUP */
	IntPosVal pv5(1, 1);
	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4[2];
	cn4[0].tableID = 8;
	cn4[0].attriID = 6;
	cn4[1].tableID = 8;
	cn4[1].attriID = 7;
	ArithmeticNode arith1(SUB, &vn5, &cn4[1]);
	ArithmeticNode arith2(MUL, &cn4[0], &arith1);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith2, 2);
	
	
	OPERATION_NODE group[1];
	group[0].tableID = 7;
	group[0].attributeID = 5;

/* Sort 1 */
	OPERATION_NODE so1[1];
	so1[0].tableID = 7;
	so1[0].attributeID = 5;
	so1[0].option = 0;
	
	


	OPERATION_NODE op1;
	op1.tableID = 2;
	op1.attributeID = 3;
	
	OPERATION_NODE op2;
	op2.tableID = 6;
	op2.attributeID = 4;
	
	OPERATION_NODE op3;
	op3.tableID = 7;
	op3.attributeID = 2;
	
	OPERATION_NODE op4;
	op4.tableID = 8;
	op4.attributeID = 1;
	
	OPERATION_NODE op5;
	op5.tableID = 3;
	op5.attributeID = 4;
	
	OPERATION_NODE op6;
	op6.tableID = 2;
	op6.attributeID = 2;
	
	
/* index position */
	
	OPERATION_NODE idx1[1];
	idx1[0].tableID = 7;
	idx1[0].attributeID = 1;
	
/* index position */
	
	OPERATION_NODE idx2[1];
	idx2[0].tableID = 6;
	idx2[0].attributeID = 1;

//===============================================================-


	o1 = new ScanDSM(&db_r_2, &attriRec_r[1], 1);
//	cout << "OK new o1" << endl;
	
	o2 = new SelectBitOut((Node *)&an1 ,(unsigned int)1);
//	cout << "OK new o2" << endl;
	o2->setPreOperator(o1);
	
	o3 = new ScanDSM(&db_r_1, attriRec_r, 1);
//	cout << "OK new o3" << endl;
	
	o4 = new BitFilter(o3, o2);
//	cout << "OK new o4" << endl;
	
	
	o5 = new ScanDSM(&db_n_3, &attriRec_n[2], 1);
//	cout << "OK new o5" << endl;
	
	o6 = new JoinIndex_OneHash(o4, o5); 
//	cout << "OK new o6" << endl;
	
	o7 = new ScanDSM(&db_n_1, &attriRec_n[0], 1);
//	cout << "OK new o7" << endl;
	
	o8 = new ScanFromJI(o7, o6, &op1);
//	cout << "OK new o8" << endl;

	o9 = new ScanDSM(&db_c_4, &attriRec_c[3], 1);
//	cout << "OK new o9" << endl;

	o10 = new JoinIndex_OneHash(o8, o9); 
//	cout << "OK new o10" << endl;
	
	o11 = new ScanDSM(&db_c_1, &attriRec_c[0], 1);
//	cout << "OK new o11" << endl;
	
	o12 = new ScanFromJI(o11, o10, &op2);
//	cout << "OK new o12" << endl;
	
	o13 = new Projection(pro1, 1);
	o13->setPreOperator(o12);
	

/* ======== Nested Loop Join with Index ============ */

	IndexScan *IS2 = new IndexScan((BDBOpe *)sDB2, attriRec_o, 9);
	o14 = new NestedJoin_Index(IS2, o13, idx2);
	//l_partkey, l_suppkey, l_extentdedprice, l_discount, o_orderdate
	//o15 = new Projection(pro6, 5);
	//o15->setPreOperator(o22);
	
/* ======================================================= */
	

	o17 = new Selection((Node *)&an4 ,(unsigned int)2);
//	cout << "OK new o17" << endl;
	o17->setPreOperator(o14);
	

	o21 = new Projection(pro2, 2);
	o21->setPreOperator(o17);
//	cout << "OK new o21" << endl;


/* ======== Nested Loop Join with Index ============ */

	IndexScan *IS1 = new IndexScan((BDBOpe *)sDB1, attriRec_l, 16);
	o22 = new NestedJoin_Index(IS1, o21, idx1);
	//l_partkey, l_suppkey, l_extentdedprice, l_discount, o_orderdate
	o23 = new Projection(pro6, 5);
	o23->setPreOperator(o22);
	
/* ======================================================= */
	
	
	

	o24 = new ScanDSM(&db_p_5, &attriRec_p[4], 1);
//	cout << "OK new o24" << endl;

	o25 = new SelectBitOut((Node *)&an5 ,1);
//	cout << "OK new o25" << endl;
	o25->setPreOperator(o24);
	
	o26 = new ScanDSM(&db_p_1, &attriRec_p[0], 1);
//	cout << "OK new o26" << endl;

	o27 = new BitFilter(o26, o25);
//	cout << "OK new o27" << endl;
	
	
	o29 = new OneSideHashJoin(o27, o23, &jon5, 1); 
//	cout << "OK new o29" << endl;
	
	o30 = new Projection(pro7, 4);
	o30->setPreOperator(o29);
//	cout << "OK new o30" << endl;
	
	
	
	
	o32 = new ScanDSM(&db_n2_1, &attriRec_n[0], 1);
//	cout << "OK new o32" << endl;
	/**/
	o33 = new ScanDSM(&db_n2_2, &attriRec_n[1], 1);
//	cout << "OK new o33" << endl;
	
	o34 = new ScanFromJI(o32, o33, &op6);
//	cout << "OK new o34" << endl;
	/*  */
	o35 = new ScanDSM(&db_s_4, &attriRec_s[3], 1);
//	cout << "OK new o35" << endl;
	
	o36 = new JoinIndex_OneHash(o34, o35); 
//	cout << "OK new o36" << endl;
	
	o37 = new ScanDSM(&db_s_1, &attriRec_s[0], 1);
//	cout << "OK new o37" << endl;
	
	o38 = new ScanFromJI(o37, o36, &op5);
//	cout << "OK new o38" << endl;

	o39 = new Projection(pro8, 2);
	o39->setPreOperator(o38);
	
	
	o40 = new OneSideHashJoin(o39, o30, &jon6,1); 
//	cout << "OK new o40" << endl;
	
	
	
	
	
	
	o41 = new Projection(pro9, 4);
	o41->setPreOperator(o40);
//	cout << "OK new o41" << endl;
	/*l_suppkey, n_name, l_partkey, o_orderdate,*/

	
	o48 = new Extract(ex, true, false, false);
	o48->setPreOperator(o41);
//	cout << "OK new o48" << endl;
	
	o49 = new GroupBy(group, 1, aggre, 1);
	o49->setPreOperator(o48);
//	cout << "OK new o49" << endl;
	
	o50 = new Sort(so1, 1);
	o50->setPreOperator(o49);
//	cout << "OK new o50" << endl;


	o51 = new OutPut(TIME_OUT);
//	cout << "OK new o51" << endl;
	o51->setPreOperator(o50);
	o51->init(env->getEnv());
	cout << "TEST START" << endl;
	
	cout << setprecision(2);
	cout << setiosflags(ios::fixed); 
	o51->exec();
	

}
Example #12
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db1(env->getEnv(), DB1);
	BDBOpe db2(env->getEnv(), DB2);
	BDBOpe db3(env->getEnv(), DB3);
	BDBOpe db4(env->getEnv(), DB4);
	BDBOpe db5(env->getEnv(), DB5);
	BDBOpe db6(env->getEnv(), DB6);
	BDBOpe db7(env->getEnv(), DB7);
	BDBOpe db8(env->getEnv(), DB8);
	BDBOpe db9(env->getEnv(), DB9);
	BDBOpe db10(env->getEnv(), DB10);
	BDBOpe db11(env->getEnv(), DB11);
	BDBOpe db12(env->getEnv(), DB12);
	BDBOpe db13(env->getEnv(), DB13);
	BDBOpe db14(env->getEnv(), DB14);
	BDBOpe db15(env->getEnv(), DB15);
	BDBOpe db16(env->getEnv(), DB16);
	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23, *o24, *o25, *o26, *o27, *o28, *o29, *o30;
	Operator *o31, *o32;
	
	db1.open();
	db2.open();
	db3.open();
	db4.open();
	db5.open();
	db6.open();
	db7.open();
	db8.open();
	db9.open();
	db10.open();
	db11.open();
	db12.open();
	db13.open();
	db14.open();
	db15.open();
	db16.open();
	TABLE_REC tableRec;
	
	tableRec.tableID = DB_tableID;
	tableRec.attriNum = DB_attriNum;
	
	ATTRIBUTE_REC attriRec[tableRec.attriNum];
	AttributeManager AM(env->getEnv());
	AM.getForTableID(tableRec, attriRec);
	
	OPERATION_NODE op1;
	op1.tableID = 16;
	op1.attributeID = 1;
	OPERATION_NODE op2;
	op2.tableID = 16;
	op2.attributeID = 4;
	
	o1 = new ScanDSM(&db1, &attriRec[0], 1);
	o2 = new ScanDSM(&db2, &attriRec[1], 1);
	o3 = new ScanDSM(&db3, &attriRec[2], 1);
	o4 = new ScanDSM(&db4, &attriRec[3], 1);
	o5 = new ScanDSM(&db5, &attriRec[4], 1);
	o6 = new ScanDSM(&db6, &attriRec[5], 1);
	o7 = new ScanDSM(&db7, &attriRec[6], 1);
	o8 = new ScanDSM(&db8, &attriRec[7], 1);
	o9 = new ScanDSM(&db9, &attriRec[8], 1);
	o10 = new ScanDSM(&db10, &attriRec[9], 1);
	o11 = new ScanDSM(&db11, &attriRec[10], 1);
	o12 = new ScanDSM(&db12, &attriRec[11], 1);
	o13 = new ScanDSM(&db13, &attriRec[12], 1);
	o14 = new ScanDSM(&db14, &attriRec[13], 1);
	o15 = new ScanDSM(&db15, &attriRec[14], 1);
	o16 = new ScanDSM(&db16, &attriRec[15], 1);
	
/*	
	o17 = new ScanFromJI(o2, o1, &op1);
	o18 = new ScanFromJI(o3, o17, &op1);
	o19 = new ScanFromJI(o4, o18, &op1);
	o20 = new ScanFromJI(o5, o19, &op1);
	o21 = new ScanFromJI(o6, o20, &op1);
	o22 = new ScanFromJI(o7, o21, &op1);
	o23 = new ScanFromJI(o8, o22, &op1);
	o24 = new ScanFromJI(o9, o23, &op1);
	o25 = new ScanFromJI(o10, o24, &op1);
	o26 = new ScanFromJI(o11, o25, &op1);
	o27 = new ScanFromJI(o12, o26, &op1);
	o28 = new ScanFromJI(o13, o27, &op1);
	o29 = new ScanFromJI(o14, o28, &op1);
	o30 = new ScanFromJI(o15, o29, &op1);
	o31 = new ScanFromJI(o16, o30, &op1);
*/	
	o17 = new OutPut(TIME_OUT);
	o18 = new OutPut(TIME_OUT);
	o19 = new OutPut(TIME_OUT);
	o20 = new OutPut(TIME_OUT);
	o21 = new OutPut(TIME_OUT);
	o22 = new OutPut(TIME_OUT);
	o23 = new OutPut(TIME_OUT);
	o24 = new OutPut(TIME_OUT);
	o25 = new OutPut(TIME_OUT);
	o26 = new OutPut(TIME_OUT);
	o27 = new OutPut(TIME_OUT);
	o28 = new OutPut(TIME_OUT);
	o29 = new OutPut(TIME_OUT);
	o30 = new OutPut(TIME_OUT);
	o31 = new OutPut(TIME_OUT);
	o32 = new OutPut(TIME_OUT);

	o17->setPreOperator(o1);
	o17->init(env->getEnv());
	o17->exec();
	o18->setPreOperator(o2);
	o18->init(env->getEnv());
	o18->exec();
	o19->setPreOperator(o3);
	o19->init(env->getEnv());
	o19->exec();
	o20->setPreOperator(o4);
	o20->init(env->getEnv());
	o20->exec();
	o21->setPreOperator(o5);
	o21->init(env->getEnv());
	o21->exec();
	o22->setPreOperator(o6);
	o22->init(env->getEnv());
	o22->exec();
	o23->setPreOperator(o7);
	o23->init(env->getEnv());
	o23->exec();
	o24->setPreOperator(o8);
	o24->init(env->getEnv());
	o24->exec();
	o25->setPreOperator(o9);
	o25->init(env->getEnv());
	o25->exec();
	o26->setPreOperator(o10);
	o26->init(env->getEnv());
	o26->exec();
	o27->setPreOperator(o11);
	o27->init(env->getEnv());
	o27->exec();
	o28->setPreOperator(o12);
	o28->init(env->getEnv());
	o28->exec();
	o29->setPreOperator(o13);
	o29->init(env->getEnv());
	o29->exec();
	o30->setPreOperator(o14);
	o30->init(env->getEnv());
	o30->exec();
	o31->setPreOperator(o15);
	o31->init(env->getEnv());
	o31->exec();
	o32->setPreOperator(o16);
	o32->init(env->getEnv());
	o32->exec();
}
Example #13
0
int main(){
	chdir(QUERY_DATA_PATH);

	EnvDB *env = new EnvDB();
	env->open();	
	
	BDBOpe db_r(env->getEnv(), "REGION.row");
	BDBOpe db_n1(env->getEnv(), "NATION.row");
	BDBOpe db_c(env->getEnv(), "CUSTOMER.row");
	BDBOpe db_o(env->getEnv(), "ORDERS.row");
	BDBOpe db_l(env->getEnv(), "LINEITEM.row");
	BDBOpe db_p(env->getEnv(), "PART.row");
	BDBOpe db_s(env->getEnv(), "SUPPLIER.row");
	BDBOpe db_n2(env->getEnv(), "NATION.row");
	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12, *o13, *o14, *o15, *o16, *o17, *o18, *o19, *o20;
	Operator *o21, *o22, *o23, *o24, *o25, *o26, *o27, *o28, *o29, *o30;
	
	db_r.open();
	db_n1.open();
	db_c.open();
	db_o.open();
	db_l.open();
	db_p.open();
	db_s.open();
	db_n2.open();

	TABLE_REC tableRec_r;
	TABLE_REC tableRec_n1;
	TABLE_REC tableRec_c;
	TABLE_REC tableRec_o;
	TABLE_REC tableRec_l;
	TABLE_REC tableRec_p;
	TABLE_REC tableRec_s;
	TABLE_REC tableRec_n2;
	
/* set table info */
	tableRec_r.tableID = 1;
	tableRec_r.attriNum = 3;
	
	tableRec_n1.tableID = 2;
	tableRec_n1.attriNum = 4;
	
	tableRec_c.tableID = 6;
	tableRec_c.attriNum = 8;

	tableRec_o.tableID = 7;
	tableRec_o.attriNum = 9;
	
	tableRec_l.tableID = 8;
	tableRec_l.attriNum = 16;

	tableRec_p.tableID = 4;
	tableRec_p.attriNum = 9;
	
	tableRec_s.tableID = 3;
	tableRec_s.attriNum = 7;
	
	tableRec_n2.tableID = 2;
	tableRec_n2.attriNum = 4;

/* aet attriRec */
	ATTRIBUTE_REC attriRec_r[tableRec_r.attriNum];
	ATTRIBUTE_REC attriRec_n1[tableRec_n1.attriNum];
	ATTRIBUTE_REC attriRec_c[tableRec_c.attriNum];
	ATTRIBUTE_REC attriRec_o[tableRec_o.attriNum];
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];
	ATTRIBUTE_REC attriRec_p[tableRec_p.attriNum];
	ATTRIBUTE_REC attriRec_s[tableRec_s.attriNum];
	ATTRIBUTE_REC attriRec_n2[tableRec_n2.attriNum];

	AttributeManager AM(env->getEnv());


	AM.getForTableID(tableRec_r, attriRec_r);
	AM.getForTableID(tableRec_n1, attriRec_n1);
	AM.getForTableID(tableRec_c, attriRec_c);
	AM.getForTableID(tableRec_o, attriRec_o);
	AM.getForTableID(tableRec_l, attriRec_l);
	AM.getForTableID(tableRec_p, attriRec_p);
	AM.getForTableID(tableRec_s, attriRec_s);
	AM.getForTableID(tableRec_n2, attriRec_n2);

/* selection1 */
	FixStrPosVal pv1(1,25);
	string str1("AMERICA");
	pv1.setStr(str1);

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 1;
	cn1.attriID = 2;
	AxprNode an1 = AxprNode(EQ, &cn1, &vn1);
	

/* selection2 */

	DatePosVal pv2(1,(unsigned char *)"1995-01-01");
	DatePosVal pv3(1,(unsigned char *)"1996-12-31");
	

	ValueNode vn2 = ValueNode(&pv2);
	ValueNode vn3 = ValueNode(&pv3);
	ColumnRefNode cn2;
	cn2.tableID = 7;
	cn2.attriID = 5;
	AxprNode an2 = AxprNode(GE, &cn2, &vn2);
	AxprNode an3 = AxprNode(LE, &cn2, &vn3);
	AxprNode an4 = AxprNode(AND, &an2, &an3);

/* selection3 */
	VarStrPosVal pv4(1,25);
	string str2("ECONOMY ANODIZED STEEL");
	pv4.set((unsigned char*)str2.c_str());

	ValueNode vn4 = ValueNode(&pv4);
	ColumnRefNode cn3;
	cn3.tableID = 4;
	cn3.attriID = 5;
	AxprNode an5 = AxprNode(EQ, &cn3, &vn4);
	
	
/* GROUP */
	IntPosVal pv5(1, 1);
	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4[2];
	cn4[0].tableID = 8;
	cn4[0].attriID = 6;
	cn4[1].tableID = 8;
	cn4[1].attriID = 7;
	ArithmeticNode arith1(SUB, &vn5, &cn4[1]);
	ArithmeticNode arith2(MUL, &cn4[0], &arith1);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith2, 2);
	
	
	OPERATION_NODE group[1];
	group[0].tableID = 7;
	group[0].attributeID = 5;




/* Join1 */

	OPERATION_NODE pn1[2];
	pn1[0].tableID = 1;
	pn1[0].attributeID = 1;
	pn1[1].tableID = 2;
	pn1[1].attributeID = 3;
	

	JOIN_OPERATION_NODE jpn1[1];
	jpn1[0].rightNode = pn1[0];
	jpn1[0].leftNode = pn1[1];
	
	
/* Join2 */
	OPERATION_NODE pn2[2];
	pn2[0].tableID = 2;
	pn2[0].attributeID = 1;
	pn2[1].tableID = 6;
	pn2[1].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn2[1];
	jpn2[0].rightNode = pn2[0];
	jpn2[0].leftNode = pn2[1];

/* Join3 */
	OPERATION_NODE pn3[2];
	pn3[0].tableID = 6;
	pn3[0].attributeID = 1;
	pn3[1].tableID = 7;
	pn3[1].attributeID = 2;

	
	JOIN_OPERATION_NODE jpn3[1];
	jpn3[0].rightNode = pn3[0];
	jpn3[0].leftNode = pn3[1];
	
/* Join4 */
	OPERATION_NODE pn4[2];
	pn4[0].tableID = 7;
	pn4[0].attributeID = 1;
	pn4[1].tableID = 8;
	pn4[1].attributeID = 1;

	
	JOIN_OPERATION_NODE jpn4[1];
	jpn4[0].rightNode = pn4[0];
	jpn4[0].leftNode = pn4[1];

/* Join5 */
	OPERATION_NODE pn5[2];
	pn5[0].tableID = 4;
	pn5[0].attributeID = 1;
	pn5[1].tableID = 8;
	pn5[1].attributeID = 2;

	
	JOIN_OPERATION_NODE jpn5[1];
	jpn5[0].rightNode = pn5[0];
	jpn5[0].leftNode = pn5[1];
	
/* Join6 */
	OPERATION_NODE pn6[2];
	pn6[0].tableID = 3;
	pn6[0].attributeID = 1;
	pn6[1].tableID = 8;
	pn6[1].attributeID = 3;

	
	JOIN_OPERATION_NODE jpn6[1];
	jpn6[0].rightNode = pn6[0];
	jpn6[0].leftNode = pn6[1];

/* Join7 */
	OPERATION_NODE pn7[2];
	pn7[0].tableID = 2;
	pn7[0].attributeID = 1;
	pn7[1].tableID = 3;
	pn7[1].attributeID = 4;

	
	JOIN_OPERATION_NODE jpn7[1];
	jpn7[0].rightNode = pn7[0];
	jpn7[0].leftNode = pn7[1];



/* Projection1 */

	OPERATION_NODE pro1[1];
	pro1[0].tableID = 1;
	pro1[0].attributeID = 1;

/* Projection2 */

	OPERATION_NODE pro2[2];
	pro2[0].tableID = 2;
	pro2[0].attributeID = 1;
	pro2[1].tableID = 2;
	pro2[1].attributeID = 3;

/* Projection3 */

	OPERATION_NODE pro3[1];
	pro3[0].tableID = 6;
	pro3[0].attributeID = 1;
	
/* Projection4 */

	OPERATION_NODE pro4[2];
	pro4[0].tableID = 7;
	pro4[0].attributeID = 1;
	pro4[1].tableID = 7;
	pro4[1].attributeID = 5;

/* Projection5 */
	
	OPERATION_NODE pro5[1];
	pro5[0].tableID = 4;
	pro5[0].attributeID = 1;

/* Projection6 */
	
	OPERATION_NODE pro6[2];
	pro6[0].tableID = 3;
	pro6[0].attributeID = 1;
	pro6[1].tableID = 3;
	pro6[1].attributeID = 4;

/* Projection7 */
	
	OPERATION_NODE pro7[2];
	pro7[0].tableID = 2;
	pro7[0].attributeID = 1;
	pro7[1].tableID = 2;
	pro7[1].attributeID = 2;

/* Projection8 */
	
	OPERATION_NODE pro8[7];
	pro8[0].tableID = 7;
	pro8[0].attributeID = 5;
	pro8[1].tableID = 2;
	pro8[1].attributeID = 2;
	pro8[2].tableID = 8;
	pro8[2].attributeID = 6;
	pro8[3].tableID = 8;
	pro8[3].attributeID = 7;
	pro8[4].tableID = 8;
	pro8[4].attributeID = 1;
	pro8[5].tableID = 8;
	pro8[5].attributeID = 2;
	pro8[6].tableID = 8;
	pro8[6].attributeID = 3;
	
	
/* Extract */
	OPERATION_NODE ex[1];
	ex[0].tableID = 7;
	ex[0].attributeID = 5;

/* Sort 1 */
	OPERATION_NODE so1[1];
	so1[0].tableID = 7;
	so1[0].attributeID = 5;
	so1[0].option = 0;

	o1 = new Scan(&db_r, attriRec_r, 3);
//	cout << "OK new o1" << endl;
	o2 = new Selection((Node *)&an1 ,(unsigned int)1);
//	cout << "OK new o2" << endl;
	o2->setPreOperator(o1);
	o3 = new Projection(pro1, 1);
	o3->setPreOperator(o2);
//	cout << "OK new o3" << endl;
	
	o4 = new Scan(&db_n1, attriRec_n1, 4);
//	cout << "OK new o4" << endl;
	o5 = new OneSideHashJoin(o3, o4 , jpn1, 1);
//	cout << "OK new o5" << endl;
	o6 = new Projection(pro2, 1);
	o6->setPreOperator(o5);
//	cout << "OK new o6" << endl;
	
	
	o7 = new Scan(&db_c, attriRec_c, 8);
//	cout << "OK new o7" << endl;
	o8 = new OneSideHashJoin(o6, o7 , jpn2, 1);
//	cout << "OK new o8" << endl;
	o9 = new Projection(pro3, 1);
	o9->setPreOperator(o8);
//	cout << "OK new o9" << endl;
	

	o10 = new Scan(&db_o, attriRec_o, 9);
//	cout << "OK new o10" << endl;
	o11 = new Selection((Node *)&an4 ,(unsigned int)2);
//	cout << "OK new o11" << endl;
	o11->setPreOperator(o10);
	
	o12 = new OneSideHashJoin(o9, o11 , jpn3, 1);
//	cout << "OK new o12" << endl;


	o13 = new Projection(pro4, 2);
	o13->setPreOperator(o12);
//	cout << "OK new o13" << endl;
	
	o14 = new Scan(&db_l, attriRec_l, 16);
//	cout << "OK new o14" << endl;
	o15 = new OneSideHashJoin(o13, o14 , jpn4, 1);
//	cout << "OK new o15" << endl;

	o16 = new Scan(&db_p, attriRec_p, 9);
//	cout << "OK new o16" << endl;
	o17 = new Selection((Node *)&an5 ,(unsigned int)1);
//	cout << "OK new o17" << endl;
	o17->setPreOperator(o16);
	o18 = new Projection(pro5, 1);
	o18->setPreOperator(o17);
//	cout << "OK new o18" << endl;
	o19 = new OneSideHashJoin(o18, o15 , jpn5, 1);
//	cout << "OK new o19" << endl;
	
	
	o20 = new Scan(&db_s, attriRec_s, 7);
//	cout << "OK new o20" << endl;
	o21 = new Projection(pro6, 2);
	o21->setPreOperator(o20);
//	cout << "OK new o21" << endl;
	o22 = new OneSideHashJoin(o21, o19 , jpn6, 1);
//	cout << "OK new o22" << endl;
	
	o23 = new Scan(&db_n2, attriRec_n2, 4);
//	cout << "OK new o23" << endl;
	o24 = new Projection(pro7, 2);
	o24->setPreOperator(o23);
//	cout << "OK new o24" << endl;
	o25 = new OneSideHashJoin(o24, o22 , jpn7, 1);
//	cout << "OK new o25" << endl;
	
	o26 = new Extract(ex, true, false, false);
	o26->setPreOperator(o25);
//	cout << "OK new o26" << endl;
	
	o27 = new Projection(pro8, 7);
	o27->setPreOperator(o26);
//	cout << "OK new o27" << endl;


	o28 = new GroupBy(group, 1, aggre, 1);
	o28->setPreOperator(o27);
//	cout << "OK new o28" << endl;

	o29 = new Sort(so1, 1);
	o29->setPreOperator(o28);
//	cout << "OK new o29" << endl;


	o30 = new OutPut(STD_OUT);
//	cout << "OK new o30" << endl;

	o30->setPreOperator(o29);
	o30->init(env->getEnv());
//	cout << "TEST START" << endl;
	
	cout << setprecision(2);
	cout << setiosflags(ios::fixed); 
	o30->exec();
}
Example #14
0
int main(){
	chdir(QUERY_DATA_PATH);
	EnvDB *env = new EnvDB();
	env->open();
	
	BDBOpe db_l_5(env->getEnv(), "8.5.DSM");
	BDBOpe db_l_6(env->getEnv(), "8.6.DSM");
	BDBOpe db_l_7(env->getEnv(), "8.7.DSM");
	BDBOpe db_l_11(env->getEnv(), "8.11.DSM");
	
	Operator *o1, *o2, *o3, *o4, *o5, *o6, *o7, *o8, *o9, *o10;
	Operator *o11, *o12;
	
	db_l_5.open();
	db_l_6.open();
	db_l_7.open();
	db_l_11.open();
	
	TABLE_REC tableRec_l;
	tableRec_l.tableID = 8;
	tableRec_l.attriNum = 16;
	ATTRIBUTE_REC attriRec_l[tableRec_l.attriNum];
	AttributeManager AM(env->getEnv());
	
	AM.getForTableID(tableRec_l, attriRec_l);
	
/* selection1 */

	DatePosVal pv1(1,(unsigned char *)"1994-01-01");

	ValueNode vn1 = ValueNode(&pv1);
	ColumnRefNode cn1;
	cn1.tableID = 8;
	cn1.attriID = 11;
	AxprNode an1 = AxprNode(GE, &cn1, &vn1);
	


	DatePosVal pv2(1,(unsigned char *)"1995-01-01");

	ValueNode vn2 = ValueNode(&pv2);
	ColumnRefNode cn2;
	cn2.tableID = 8;
	cn2.attriID = 11;
	AxprNode an2 = AxprNode(LT, &cn2, &vn2);
	
	AxprNode an7 = AxprNode(AND, &an1, &an2);
	
/* selection3 */

	FloatPosVal pv3(1, 0.06-0.01);
	FloatPosVal pv4(1, 0.06+0.01);
	

	ValueNode vn3 = ValueNode(&pv3);
	ValueNode vn4 = ValueNode(&pv4);
	ColumnRefNode cn3;
	cn3.tableID = 8;
	cn3.attriID = 7;
	AxprNode an3 = AxprNode(GE, &cn3, &vn3);
	AxprNode an4 = AxprNode(LE, &cn3, &vn4);
	AxprNode an5 = AxprNode(AND, &an3, &an4);
	
/* selection4 */

	FloatPosVal pv5(1, 24);

	ValueNode vn5 = ValueNode(&pv5);
	ColumnRefNode cn4;
	cn4.tableID = 8;
	cn4.attriID = 5;
	AxprNode an6 = AxprNode(LT, &cn4, &vn5);
	
	
/* AGGREGATION */
	ColumnRefNode cn5[2];
	cn5[0].tableID = 8;
	cn5[0].attriID = 6;
	cn5[1].tableID = 8;
	cn5[1].attriID = 7;
	ArithmeticNode arith1(MUL, &cn5[0], &cn5[1]);
	
	Aggregation *aggre[1];
	aggre[0] = new Sum(&arith1, 2);
	
	
	
	OPERATION_NODE op1;
	op1.tableID = 8;
	op1.attributeID = 7;
	
	
	
	o1 = new ScanDSM(&db_l_11, &attriRec_l[10], 1);
//	cout << "OK new o1" << endl;
	
	o2 = new SelectBitOut((Node *)&an7 ,(unsigned int)2);
//	cout << "OK new o2" << endl;
	o2->setPreOperator(o1);
	
	o3 = new ScanDSM(&db_l_5, &attriRec_l[4], 1);
//	cout << "OK new o3" << endl;
	
	o4 = new BitFilter(o3, o2);
//	cout << "OK new o4" << endl;
	
	o5 = new Selection((Node *)&an6 ,(unsigned int)1);
//	cout << "OK new o5" << endl;
	o5->setPreOperator(o4);
	
	o6 = new ScanDSM(&db_l_7, &attriRec_l[6], 1);
//	cout << "OK new o6" << endl;

	o7 = new Selection((Node *)&an5 ,(unsigned int)2);
//	cout << "OK new o7" << endl;
	o7->setPreOperator(o6);
	
	o8 = new ScanFromJI(o5, o7, &op1);
//	cout << "OK new o8" << endl;
	
	o9 = new ScanDSM(&db_l_6, &attriRec_l[5], 1);
//	cout << "OK new o9" << endl;
	
	o10 = new ScanFromJI(o9, o8, &op1);
//	cout << "OK new o10" << endl;
	
	o11 = new AggreOut(aggre, 1);
	o11->setPreOperator(o10);
//	cout << "OK new o11" << endl;
	
	o12 = new OutPut(STD_OUT);
//	cout << "OK new o12" << endl;
	o12->setPreOperator(o11);
	o12->init(env->getEnv());
	cout << "TEST START" << endl;
	
	cout << setprecision(6);
	cout << setiosflags(ios::fixed); 
	o12->exec();
}