⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indextest.c

📁 TV-tree的c实现源码
💻 C
📖 第 1 页 / 共 2 页
字号:
         }       cout << "\n";       cout << "Search file name " << tp.sfilename << "\n";       cout << "Number of elements searched : " << tp.numsearch << "\n";       cout << "Skip between element : " << tp.searchskip << "\n";       cout << "Skip from head of file : " << tp.searchskiphead << "\n";     }  else     cout << "No insertion performed\n";  cout << endl << endl;  if (tp.saveindex)     cout << "Index saved at file " << tp.svfilename << "\n";  else     cout << "Index not saved\n";  cout << endl;}main(int argc, char *argv[]){  TestPara tp;  TVTree *ind1;  eletested = 0;  // Change options  ChangeOptions(argc, argv, tp);  // Print options selected  PrintOptions(tp);  // Creat Storage  globstorage = new Storage(tp.ip.page_size, tp.buffersize);  // Create index  if (tp.loadindex)     ind1 = new TVTree(tp.lifilename, ReadData, GetFeature);  else     ind1 = new TVTree(tp.ip, PHASES);    #ifdef DEBUG  cout << "\nEnd of create index\n";#endif// cout << "Count : " << ind1->Count() << endl;  if (tp.performinsert)     {        ifstream ifile(tp.ifilename, ios::in);        // inserting data        for (int icount = 0 ; icount < tp.numinput; icount++)          {/*	     DataPoints dp;	     ifile >> dp;	     size = dp.Size();	     char *newdata = dp();	     Leaf_Element e(newdata, size);*/	     DataPoints *dp = new DataPoints;	     ifile >> *dp;	     int size = dp->Size();/*if (icount == 3542) cout << icount << "  Hello\n";*/// cout << "icount : " << icount << "  Count : " << ind1->Count() << endl;	     Leaf_Element e((char *)dp, size);                         ind1->InsertElement(e, GetFeature);	     DataPoints dump;             for (int skipcount = 0; skipcount < tp.inskip; skipcount++)	        ifile >> dump;//	     delete [] newdata;          }        ifile.close();     }#ifdef DEBUG   cout << "end of insert\n";#endif   cout << "Build buffer result : " << *globstorage <<  "   Time for read,write : " << (globstorage->diskfetchcount + globstorage->pagewritecount) * tp.disktime / 1000.0 << " seconds"<< endl;   if (tp.printindex)       ind1->TVTreePrint(cout, PrintData, tp.onedataperline);   globstorage->emptybuffer();   globstorage->initstats();   if (tp.checkvalid)      {	cout << "Checking validity : ";        if (ind1->ValidityCheck())	   cout << "good";        else	   cout << "ERROR!!!";	cout << "   Count : " << ind1->Count() << endl;      }   // Search   if (tp.performsearch)      {	ind1->IncrementPhase(); // new phase for gathering search stats	int size;        ifstream sfile(tp.sfilename, ios::in);        int hitcount = 0;        globstorage->emptybuffer();        globstorage->initstats();        ostream *search_print_out;        ofstream search_print_out_file;        // Set output for search results        if (tp.searchprint)           {             if (tp.searchprintfile)                {                   search_print_out_file.open(tp.searchprintfile, ios::out);                   search_print_out = &search_print_out_file;                }             else                search_print_out = &cout;           }        else          search_print_out = NULL;        int i;        // Skip the top of the file        for (i = 0; i < tp.searchskiphead; i++)	   {	   DataPoints dp1;	   sfile >> dp1;	   }	for (int scount = 0; scount < tp.numsearch; scount++)            {	        DataPoints dp;                sfile >> dp;		int curhitcount;		// Searching		switch (tp.searchoption) {		  case searchexact : {		                        if (tp.searchprint)			                           (*search_print_out) << "\n -- " << dp << " : ";							  char **res;	                                int size = dp.Size();					curhitcount = ind1->Search((char *)&dp, size, res, GetKey, GetFeature, Equal, tp.searchcode);					hitcount += curhitcount;				        if (tp.searchprint)						   {						for (int spp = 0; spp < curhitcount;)						  {						  	(*search_print_out) << res[spp++] << " / ";							if (!(spp % 10))						           (*search_print_out) << endl;						  }						(*search_print_out) << endl;					   }				     }				     break;		   case searchappdia : {					  TVector v = GetTVector(dp, 3);					  float lower[3], upper[3];					  for (int j = 0; j < 3; j++)						   {						lower[j] = v[j] - tp.searchdist;						upper[j] = v[j] + tp.searchdist;					   }								                          if (tp.searchprint)						     {		                              (*search_print_out) << "\n -- " << dp  << " {(" << lower[0];							      int pv;					      for (pv = 1; pv < 3; pv++)						 (*search_print_out) << ", " << lower[pv];		                              (*search_print_out) << "), (" << upper[0];							      for (pv = 1; pv < 3; pv++)						 (*search_print_out) << ", " << upper[pv];		                              (*search_print_out) << ")} : ";							     }					  char **res;	                                  int size = dp.Size();					  curhitcount = ind1->Search((char *)&dp, size, 3, lower, upper,  res, GetKey, GetFeature, tp.searchcode);					  hitcount += curhitcount;		                          (*search_print_out) << " Count : " << curhitcount << " ";				          if (tp.searchprint)						     {						for (int spp = 0; spp < curhitcount;)						  {						  	(*search_print_out) << res[spp++] << " / ";							if (!(spp % 10))						           (*search_print_out) << endl;						  }						(*search_print_out) << endl;					     }					}				      break;		   case searcheditdist : {		                        if (tp.searchprint)			                           (*search_print_out) << "\n -- " << dp << " : ";							char **res;	                                int size = dp.Size();					curhitcount = ind1->Search(tp.searchdist, (char *)&dp, size,  res, GetKey, GetFeature, Distance, tp.searchcode);					hitcount += curhitcount;				        if (tp.searchprint)						   {						for (int spp = 0; spp < curhitcount;)						  {						  	(*search_print_out) << res[spp++] << " / ";							if (!(spp % 10))						           (*search_print_out) << endl;						  }						(*search_print_out) << endl;					   }				       }		   case searchappdis : {		                        if (tp.searchprint)			                           (*search_print_out) << "\n -- " << dp << " : ";							char **res;	                                int size = dp.Size();					curhitcount = ind1->Search(tp.searchdist, (char *)&dp, size,  res, GetKey, GetFeature, tp.searchcode);					hitcount += curhitcount;				        if (tp.searchprint)						   {						for (int spp = 0; spp < curhitcount;)						  {						  	(*search_print_out) << res[spp++] << " / ";							if (!(spp % 10))						           (*search_print_out) << endl;						  }						(*search_print_out) << endl;					   }				       }		   default : 			     break;		  }            	       // skipping elements               for (i = 0; i < tp.searchskip; i++)                sfile >> dp;// cout << scount << " " << *globstorage << endl;            }	sfile.close();        cout << endl << "Total hits : " << hitcount << endl;        cout << "Search result : " << *globstorage <<  "   Time for read,write : " << (globstorage->diskfetchcount + globstorage-> pagewritecount) * tp.disktime / 1000.0 << " seconds"<< endl;        cout << "Element tested : " << eletested << endl;      }#ifdef DEBUG   cout << "end of search\n";#endif   // Print stats  ind1->GatherTreeStats();  ind1->PrintStats(cout);  if (tp.saveindex)    ind1->SaveTVTree(tp.svfilename, WriteData);    ind1->FreeTree();  delete ind1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -