Exemple #1
0
/*******#include "../physical_operator/ExpandableBlockStreamSingleColumnScan.h"
*****Local Disk Access******#include "../physical_operator/ExpandableBlockStreamSingleColumnScanDisk.h"
******/
int main_ld (int argc, char** argv)
{
	const unsigned block_size = atoi(argv[1]);
	const unsigned thread_count = atoi(argv[2]);
	const unsigned expander_buffer = atoi(argv[3]);
	const int columns_num = atoi(argv[4]);
	unsigned long random_size = atoi(argv[5]);	//number of columns which are randomly accessed
	random_size = random_size*sizeof(int);
	unsigned long scan_size = (unsigned long)4*1024*1024*1024-random_size*columns_num;

	cout << "columns_num: " << columns_num << "\t random_size: " << random_size/sizeof(int) << endl;

	std::vector<column_type> column_list,column_list_;
	column_list.push_back(column_type(t_int));
	for (int i = 0; i < columns_num; i++)
		column_list_.push_back(column_type(t_int));

	Schema* i_schema = new SchemaFix(column_list);
	Schema* d_schema = new SchemaFix(column_list_);

//	ExpandableBlockStreamSingleColumnScan::State ebssc_state1("/home/claims/temp/6_0.column", d_schema, block_size);
//	BlockStreamIteratorBase* ebssc1 = new ExpandableBlockStreamSingleColumnScan(ebssc_state1);
//	ebssc1->open();
//	BlockStreamBase* block_=BlockStreamBase::createBlock(i_schema,block_size);
//	while (ebssc1->next(block_)) {};
//	ebssc1->close();
//	block_->~BlockStreamBase();

	ExpandableBlockStreamSingleColumnScanDisk::State ebsscsd_state("/home/claims/temp/5_0.column", d_schema, block_size, scan_size);
	PhysicalOperatorBase* ebsscsd = new ExpandableBlockStreamSingleColumnScanDisk(ebsscsd_state);

	ExpandableBlockStreamSingleColumnScan::State ebssc_state("/home/claims/temp/6_0.column", i_schema, block_size, random_size);
	PhysicalOperatorBase* ebssc = new ExpandableBlockStreamSingleColumnScan(ebssc_state);

//	BlockStreamExpander::State bse_state(i_schema,ebssc,thread_count,block_size,expander_buffer);
//	BlockStreamIteratorBase* bse=new BlockStreamExpander(bse_state);

	ExpandableBlockStreamRandomDiskAccess::State ebsrda_state("/home/claims/temp/Uniform_0_9999.column", ebssc, d_schema, i_schema, block_size);
	PhysicalOperatorBase* ebsrda = new ExpandableBlockStreamRandomDiskAccess(ebsrda_state);

	Expander::State bse_state1(d_schema,ebsscsd,thread_count,block_size,expander_buffer);
	PhysicalOperatorBase* bse1=new Expander(bse_state1);
	Expander::State bse_state2(d_schema,ebsrda,thread_count,block_size,expander_buffer);
	PhysicalOperatorBase* bse2=new Expander(bse_state2);

	BlockStreamPerformanceTest::State bspt_state(d_schema, bse1, bse2, block_size, 1000);
	PhysicalOperatorBase* bspt = new BlockStreamPerformanceTest(bspt_state);

	bspt->Open();
	while (bspt->Next(0));
	bspt->Close();

	return 0;
}
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);
	}
}