int mainasdf(int argc, const char** argv){

	int master;
	printf("Master(0) or Slave(others)?\n");
	scanf("%d",&master);
	if(master==0){






		Environment::getInstance(true);

		const unsigned block_size=atoi(argv[1]);
		const unsigned thread_count=atoi(argv[2]);
		int f=atoi(argv[3]);
		const unsigned expander_buffer=atoi(argv[4]);
		const unsigned lowers_1=atoi(argv[5]);
		const unsigned lowers_2=atoi(argv[6]);
		std::vector<std::string> upper_ip_list;
		upper_ip_list.push_back("10.11.1.211");

		std::vector<std::string> lower_ip_list;

		lower_ip_list.push_back("10.11.1.201");
		lower_ip_list.push_back("10.11.1.202");
		lower_ip_list.push_back("10.11.1.203");
		lower_ip_list.push_back("10.11.1.204");


		lower_ip_list.push_back("10.11.1.209");
//		lower_ip_list.push_back("10.11.1.210");
//		lower_ip_list.push_back("10.11.1.201");
		lower_ip_list.push_back("10.11.1.214");

		lower_ip_list.push_back("10.11.1.207");
		lower_ip_list.push_back("10.11.1.208");
		lower_ip_list.push_back("10.11.1.205");
		lower_ip_list.push_back("10.11.1.206");




		std::vector<std::string> used_lowers_1;
		for(unsigned i=0;i<lowers_1;i++){
			used_lowers_1.push_back(lower_ip_list[i]);
		}

//
		std::vector<std::string> used_lowers_2;

		for(unsigned i=lower_ip_list.size()-1;i>=lower_ip_list.size()-lowers_2;i--){
			used_lowers_2.push_back(lower_ip_list[i]);
		}



		std::vector<column_type> column_list,column_list_;
		column_list.push_back(column_type(t_int));

		Schema* schema=new SchemaFix(column_list);

		/*ColumnScan*/
		ExpandableBlockStreamSingleColumnScan::State ebssc_state("/home/imdb/temp/Uniform_0_999.column",schema,block_size);
		BlockStreamIteratorBase* ebssc=new ExpandableBlockStreamSingleColumnScan(ebssc_state);
//
//		FilterIterator::AttributeComparator filter1(column_type(t_int),Comparator::L,0,&f);
//		std::vector<FilterIterator::AttributeComparator> ComparatorList;
//		ComparatorList.push_back(filter1);
//		ExpandableBlockStreamFilter::State ebsf_state(schema,ebssc,ComparatorList,block_size);
//		BlockStreamIteratorBase* bbsf=new ExpandableBlockStreamFilter(ebsf_state);

		/*Expander*/
		BlockStreamExpander::State bse_state_1(schema,ebssc,thread_count,block_size,expander_buffer);
		BlockStreamIteratorBase* bse_1=new BlockStreamExpander(bse_state_1);

		/* Exchange */
		const int exchange_id_1=1;
		ExpandableBlockStreamExchangeEpoll::State ebse_state_1(schema,bse_1,block_size,used_lowers_2,used_lowers_1,exchange_id_1);
		BlockStreamIteratorBase* ebse_1=new ExpandableBlockStreamExchangeEpoll(ebse_state_1);

		/*Filter*/
		FilterIterator::AttributeComparator filter1(column_type(t_int),Comparator::L,0,&f);
		std::vector<FilterIterator::AttributeComparator> ComparatorList;
		ComparatorList.push_back(filter1);
		ExpandableBlockStreamFilter::State ebsf_state(schema,ebse_1,ComparatorList,block_size);
		BlockStreamIteratorBase* bbsf=new ExpandableBlockStreamFilter(ebsf_state);

		/*Expander*/
		BlockStreamExpander::State bse_state(schema,bbsf,thread_count,block_size,expander_buffer);
		BlockStreamIteratorBase* bse=new BlockStreamExpander(bse_state);


		/* Exchange */
		const int exchange_id=0;
		ExpandableBlockStreamExchangeEpoll::State ebse_state(schema,bse,block_size,used_lowers_1,upper_ip_list,exchange_id);
		BlockStreamIteratorBase* ebse=new ExpandableBlockStreamExchangeEpoll(ebse_state);

		/* Performance Monitor*/
		BlockStreamPerformanceMonitorTop::State bspfm_state(schema,ebse,block_size,1000);
		BlockStreamIteratorBase* bspfm=new BlockStreamPerformanceMonitorTop(bspfm_state);

//		BlockStreamBase *block=new BlockStreamFix(block_size,4);


		volatile int choice;

		printf("Continue(1) or Not(0) ?\n");
		scanf("%d",&choice);
		unsigned tuple_count=0;
		while(choice==1){


	//		bsf->open();

			bspfm->open();
//			unsigned long long int start=curtick();
//			tuple_count=0;
			while(bspfm->next(0)){
//				BlockStreamBase::BlockStreamTraverseIterator *it=block->createIterator();
//				void* tuple;
//				while(tuple=it->nextTuple()){
////					printf("tuple:%d \n",*(int*)tuple);
//					tuple_count++;
//				}
//				block->setEmpty();
			}
//			printf("Total tupls:%d\n",tuple_count);
//			printf("Time=%f Throughput=%f.\n",getSecond(start),1024/getSecond(start));
			bspfm->close();

			printf("Continue(0) or Not(1) ?\n");
//			getchar();
			scanf("%d",&choice);
			printf("you input %d\n",choice);

		}
	}
	else{
		Environment::getInstance(false);
	}

	printf("Waiting~~~~~....\n");
	while(true){
		sleep(1);
	}
}
Ejemplo n.º 2
0
static int in_iterator_test ()
{
    cout << "test in\n";
    std::vector<column_type> column_list;
    column_list.push_back(column_type(t_u_long));
    column_list.push_back(column_type(t_int));
    column_list.push_back(column_type(t_u_long));
    column_list.push_back(column_type(t_int));
    column_list.push_back(column_type(t_int));
    column_list.push_back(column_type(t_int));

    Schema* input=new SchemaFix(column_list);
    Schema* output=new SchemaFix(column_list);

    unsigned block_size = 64*1024-sizeof(unsigned);

    ExpandableBlockStreamSingleColumnScan::State ebsscs1_state("/home/claims/data/wangli/T0G0P0",input, block_size);
    BlockStreamIteratorBase* ebssc1=new ExpandableBlockStreamSingleColumnScan(ebsscs1_state);

    unsigned long f = 20000;
    AttributeComparator fA(column_type(t_u_long),Comparator::L,0,&f);
    std::vector<AttributeComparator> ComparatorList;
    ComparatorList.push_back(fA);
    ExpandableBlockStreamFilter::State ebsf_state(input, ebssc1, ComparatorList, block_size);
    BlockStreamIteratorBase* ebfs = new ExpandableBlockStreamFilter(ebsf_state);


    ExpandableBlockStreamSingleColumnScan::State ebsscs2_state("/home/claims/data/wangli/T0G0P0",input, block_size);
    BlockStreamIteratorBase* ebssc2=new ExpandableBlockStreamSingleColumnScan(ebsscs1_state);


    BlockStreamInIterator::State bsii_state(ebfs, ebssc2, input, input, 0, 0, block_size);
    BlockStreamIteratorBase* bsii = new BlockStreamInIterator(bsii_state);

    std::vector<string> attr_name;
    attr_name.push_back("rowid");
    attr_name.push_back("Trade_Date");
    attr_name.push_back("Order_No");
    attr_name.push_back("Sec_Code");
    attr_name.push_back("Trade_Dir");
    attr_name.push_back("Order_Type");

    BlockStreamPrint::State bsp1_state(input, ebfs, block_size, attr_name, "\t");
    BlockStreamIteratorBase* bsp1 = new BlockStreamPrint(bsp1_state);

    bsp1->print();
    bsp1->open(0);
    BlockStreamBase* block = BlockStreamBase::createBlock(input, block_size);
    while(bsp1->next(block));
    {
    }
    bsp1->close();

    BlockStreamPrint::State bsp_state(input, bsii, block_size, attr_name, "\t");
    BlockStreamIteratorBase* bsp = new BlockStreamPrint(bsp_state);

    bsp->open(0);
//	BlockStreamBase* block = BlockStreamBase::createBlock(input, block_size);
    while(bsp->next(block));
    {
    }
    bsp->close();

    PhysicalQueryPlan IM(bsp);
    Message4K M4K = PhysicalQueryPlan::serialize4K(IM);
    PhysicalQueryPlan tmp = PhysicalQueryPlan::deserialize4K(M4K);
    tmp.run();


    return 0;
}