Esempio n. 1
0
void insert1(long int x,struct avl * &p)
{	if (p == NULL)
	{	p = new avl;
		p->d = x;
		p->lc=NULL;
		p->rc = NULL;
		p->h=0;
	}
	else
	{	if (x<p->d)
		{	insert1(x,p->lc);
			if ((height(p->lc) - height(p->rc))==2)
			{	if (x < p->lc->d)
					p = llrot(p);
				else
				p = lrrot(p);
			}
		}
		else if (x>p->d)
		{	insert1(x,p->rc);
			if ((height(p->rc) - height(p->lc))==2)
			{	if (x > p->rc->d)
					p = rrrot(p);
				else
					p = rlrot(p);
			}
		}
		else
		{	cout<<"\n\n SORRY ALREADY EXISTS.....RE- ENTER A VALUE CORRECTLY..";
			getch();
		}
	}
	p->h=max(height(p->lc),height(p->rc))+1;
}
Esempio n. 2
0
Node* insert(Node** root, int value)
{
    Node* r = *root;
    if (r->n == 3)
    {
        Node* a = newnode();
        a->child[0] = r;
        a->leaf = 0;
        *root= a;
        split(a,0);
        return insert1(a, value);
    } else {
        return insert1(r,value);
    }
}
Esempio n. 3
0
Threaded insert(Type n, Threaded t) {
	inserted = insert1(n, t);
	inordering = flatten(t);
	inserted->left = find(inordering, inserted)->prev;
	inserted->left = find(inordering, inserted)->next;
	return t;
}
Esempio n. 4
0
Node* insert1(Node* x, int value)
{
    int i = 0;
    while ( i < x->n && value > x->k[i])
        i++;
    if (x->leaf)
    {
        int j;
        for (j = x->n; j > i; j--)
        {
            x->k[j] = x->k[j-1];
        }
        x->k[j] = value;
        x->n++;
        return x;
    } else
    {
        if (x->child[i]->n == 3)
        {

            split(x, i);
            if (value > x->k[i])
            {
                i++;
            }
        }
        return insert1(x->child[i], value);
    }
}
Esempio n. 5
0
void main()
{
int c;
do
{
printf("\n---MENU---");
printf("\n1.Push");
printf("\n2.Pop");
printf("\n3.Display");
printf("\n4.Exit");
printf("\nEnter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1:
insert1();
break;
case 2:
delete2();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("\nEnter a valid choice");
}
}while(c!=4);
getch();
}
SEARCH_TREE insert1(element_type x,SEARCH_TREE T,avl_ptr parent)
{
  avl_ptr rotated_tree;
  if(T==NULL){
    T=(SEARCH_TREE) malloc(sizeof(struct avl_node));
    if(T==NULL)
      fatal_error("Out of space\n");
    else{
      T->element=x;
      T->height=0;
      T->left=T->right=NULL;
    }
  }else{
    if(x<T->element){
      T->left=insert1(x,T->left,T);
      if((height(T->left)-height(T->right))==2){
	if(x<T->left->element)
	  rotated_tree=s_rotated_left(T);
	else
	  rotated_tree=d_rotated_left(T);
	if(parent->left==T)
	  parent->left=rotated_tree;
	else
	  parent->right=rotated_tree;
      }else{
	T->height=node_height(T);
      }
    }else if(x>T->element){
      T->right=insert1(x,T->right,T);
      if((height(T->right)-height(T->left))==2){
	if(x>T->right->element)
	  rotated_tree=s_rotated_right(T);
	else
	  rotated_tree=d_rotated_right(T);
	if(parent->right==T)
	  parent->right=rotated_tree;
	else
	  parent->left=rotated_tree;
      }else{
	T->height=node_height(T);
      }
    }
  }
  return T;
}
Esempio n. 7
0
int main()
{
    int n;
    sqlite3 *db;
    int ret=0;
    char str[100]="create table \
        employee(id integer primary key,name text,gender text,age integer);";
    char *ss=0;
    int ret1;
    
    ret=sqlite3_open("./tesw.db",&db);
    
    if(ret!=SQLITE_OK)
    {
        fputs(sqlite3_errmsg(db),stderr);
        fputs("\n",stderr);
        exit(1);
    }
 
    fputs("Please check :Is there  a table:employee ?\n",stdout);
    fputs("\n",stdout);
    ret=sqlite3_exec(db,"select * from employee;",NULL,NULL,NULL);
    
    if(ret)
    {
        fputs("No employee \n",stdout);
        fputs("\n",stdout);
        fputs("Create a table:employee\n",stdout);
        ss=sqlite3_mprintf("%s",str);
        ret1=sqlite3_exec(db,ss,rscallback,NULL,NULL);
        if(!ret1)fputs("finish creating\n",stdout);

        }
     fputs("yse \n",stdout);
     fputs("\n",stdout);
  
   while(1){
   fputs("1.Display all records\n",stdout);
   fputs("2.Insert Record\n",stdout);
   fputs("3.Delete Record\n",stdout);
   fputs("4.Exit\n",stdout);
   fputs("Please Select[1-4]:",stdout);
   scanf ("%d",&n);
   switch(n){
       
       case 1:select1(db);empty_cache();break;
       case 2:insert1(db);empty_cache();break;
       case 3:delete1(db);empty_cache();break;
       case 4:exit(0);
       default:return 0;
            }  
            } 

   sqlite3_close(db);

   return 0;
}
Esempio n. 8
0
int main() {
	while (scanf("%d%d", &m, &n) != EOF) {
		init();
		for (int i = 0; i < m; ++i) {
			scanf("%d%d%d", &a, &b, &x);
			insert1(a, b, x);
		}
		printf("%d\n", sap(1,n));
	}
}
Esempio n. 9
0
void creat()
{
	struct nodb *s;
	int i,n,k;
	printf("n=?");
	scanf("%d",&n);
	
	for(i=1;i<n;i++)
	{
		printf("k%d=?",i);
		scanf("%d",&k);
		s=(struct nodb *)malloc(sizeof(struct nodb));
		s->data=k;s->lch=NULL;s->rch=NULL;
		insert1(s);
	}
}
Esempio n. 10
0
void main()
{
	int op;
	int again;
	clrscr();
	while(1)
	{	cout<<"\n\n1.INSERT\n\n2.EXIT";
		cout<<"\n\nENTER THE OPTION : ";
		op=get(op);
		if(op==1)
		{	cout<<"\nENTER THE DATA : ";
			dt=get(dt);
			insert1(dt,t);
			initgraph(&gdriver, &gmode, "e:\\tc\\bgi");
			Display(t,getmaxx()/2,40);
			getch();
		}
		else
		{	exit(0);	}
	}
}
SEARCH_TREE insert(element_type x,SEARCH_TREE T)
{
  return insert1(x,T,NULL);
}
void insert(char *file1,char* file,int x1)
{
      int i,j,k,v,e,b[1129],x,d[1129],h,a[1129];
      char key1[1100],key2[1100],value[140],hexval[135],val[1129],str[1100];
      lptr temp,tnode,root1,search,tem,z,ptr,ptr1,addr;
      
 
      convert(file);
      FILE *fp,*fp2;
      fp=fopen("hashvalues.txt","r");
      fp2=fopen(file,"r");
      while( (fscanf(fp,"%s",value)) !=EOF)
      {
	strcpy(val,value);
	for(i=0;i<128;i++)                        //MODIFICATION
	{
		a[i]=val[i]-48;
		
	}
	               /* for(i=0;i<128;i++) 
	                printf("%d",a[i]);
	                printf("\n");*/
	                fscanf(fp2,"%s",key1);
			puts(key1);
                        printf("\n");
                   //CREATION OF ROOT NODE
                    if(root==NULL)
                    {            printf("\n 1 ");
                                 root=(lptr)malloc(sizeof(struct node));

                                       root->df=0; 

                                       root->head=(dptr)malloc(sizeof(struct dnode));
                                       root->head->dlink=root->head;
                                       insert1(root,root->head,file1,x1);                           //posting file

                                       root->visited=0;  
                                 
                                 strcpy(root->key,key1);
                                 root->bitindex=bitindex1(a);
                                 root->rchild=root;
                                 root->lchild=NULL;
                                 for(i=0;i<128;i++)               //MODIFICATION  
                                 root->a[i]=a[i]; 
                                 //printf(" 1 ");
                           }
                     else
                     {
                             printf("prasas");
                      printf(" \nNONROOT 2 \n");
                        printf("prasas");
                                  temp=closest(a,root);
                                  printf("prasas");
                                  if(temp!=NULL)
                                  {
                                    for( k=0;k<128;k++)            //MODIFICATION
                                    b[k]=temp->a[k];
                                    v=bitindex2(a,b);
                                   } //temp!=NULL
                                   else
                                   {
                                    v=bitindex1(a);  
                                   }//temp==NULL
                                 if(v<0){
                                           if(temp!=NULL)
                                           {
                                            //temp->head=(dptr)malloc(sizeof(struct dnode));
                                            //temp->head->dlink=temp->head;
                                            insert1(temp,temp->head,file1,x1);                                   //posting file
                                           } 

                                           
                                            printf("\nTHE KEY IS ALREADY INSERTED\n");  
                                            continue;
                                          } 
                                 printf("\nThe bitindices for key %s is:-%d",key1,v);
                                 tnode=(lptr)malloc(sizeof(struct node));

                                              tnode->df=0; 
                                         
                                              tnode->head=(dptr)malloc(sizeof(struct dnode));
                                              tnode->head->dlink=tnode->head;
                                              insert1(tnode,tnode->head,file1,x1);                                 //posting file     

                                              tnode->visited=0;
                                 
                                 strcpy(tnode->key,key1);
                                 tnode->bitindex=v;
                                 for(i=0;i<128;i++)                //MODIFICATION
                                 tnode->a[i]=a[i]; 

                                 //Inserting the node
                                                   ptr=root;
                                                   ptr1=root;
                                                   while(ptr->bitindex>v)
                                                   {
                                                       ptr1=ptr;
                                                       if(tnode->a[ptr->bitindex]!=1) ptr=ptr->lchild;                  
                                                       else                    ptr=ptr->rchild;
                                                       if(ptr==NULL) break;
                                                       if(ptr->bitindex<=v || ptr1->bitindex<=ptr->bitindex) break;
                                                       }

                                                   if(v>root->bitindex)
                                                   {
                                                    //printf("\nCASE 3 \n");
                                                       if(tnode->a[v]!=1)
                                                       {
                                                        tnode->lchild=tnode;
                                                        tnode->rchild=root;
                                                        root=tnode;
                                                        printf("\nNEW NODE LEFT CHILD IS:%s\n",tnode->lchild->key);
                                                        printf("\nNEW NODE RIGHT CHILD IS:%s\n",tnode->rchild->key);  
                                                       }
                                                       else
                                                       {
                                                        tnode->lchild=root;
                                                        tnode->rchild=tnode;
                                                        root=tnode;
                                                        printf("\nNEW NODE LEFT CHILD IS:%s\n",tnode->lchild->key);
                                                        printf("\nNEW NODE RIGHT CHILD IS:%s\n",tnode->rchild->key);
                                                        }
                                                         //printf("\nCASE  3\n ");
                                                       
                                                   } 
                                                   else if(ptr==NULL)
                                                   {
                                                      ptr1->lchild=tnode;
                                                      tnode->lchild=NULL;
                                                      tnode->rchild=tnode;
                                                      printf("\nNEW NODE LEFT CHILD IS NULL\n");
                                                      printf("\nNEW NODE RIGHT CHILD IS:%s\n",tnode->rchild->key);
                                                   }
                                             
                                                   else
                                                   {
                                                     printf("\nLAST CASE \n");
                                                     if(tnode->a[ptr1->bitindex]!=1)      {
                                                                                              ptr1->lchild=tnode;
                                                                                              printf("NEW NODE IS LEFT CHILD OF :%s",ptr1->key);
                                                                                          }     
                                                                  else                    {   ptr1->rchild=tnode;
                                                                                              printf("NEW NODE IS RIGHT CHILD OF:%s",ptr1->key);
                                                                                          }  
                                                                  if(tnode->a[v]!=1)      {               
                                                                                              tnode->lchild=tnode;
                                                                                              tnode->rchild=ptr;
                                                                                              printf("\nNEW NODE LEFT CHILD IS:%s\n",tnode->lchild->key);
                                                                                              printf("\nNEW NODE RIGHT CHILD IS:%s\n",tnode->rchild->key);  
                                                                                
                                                                                          }
                                                                  else                    {
                                                                                              tnode->rchild=tnode;
                                                                                              tnode->lchild=ptr;
                                                                                              printf("\nNEW NODE LEFT CHILD IS:%s\n",tnode->lchild->key);
                                                                                              printf("\nNEW NODE RIGHT CHILD IS:%s\n",tnode->rchild->key);   
                                                                                          }
                                                      //printf("\nLAST CASE\n");                                    
                                                   }
                                                   
                                 
                           //printf("\nNONROOT2 ELSE EXIT\n");       
                           } 
                           
                } 
             
     fclose(fp2);  
     fclose(fp);   
  
      FILE *ptr11;
      ptr11=fopen("hashvalues.txt","w");
      fclose(ptr11); 
      FILE *ptr12;
      ptr12=fopen("hfile.txt","w");
      fclose(ptr12); 

}//insert
Esempio n. 13
0
 main()
{

	int n,m,i,j,k,l,o;
	
	printf("enter no. of terms in 1st polynomial:"); 
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		insert1();
	}
	
	printf("enter no. of terms in 2nd polynomial:"); 
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		insert2();
	}
	q1=start1;
	
	while(q1!=NULL)
	{
		printf("%d |",q1->coff);
		printf("%d-->",q1->exp);
		q1=q1->link;
	}printf("NULL\n");
		q2=start2;
	
	
	while(q2!=NULL)
	{
		printf("%d |",q2->coff);
		printf("%d-->",q2->exp);
		q2=q2->link;
	}printf("NULL\n");
	
	q1=start1;
	q2=start2;
	while(q1!=NULL||q2!=NULL){
		if(q1->exp>q2->exp){
		while(q1->exp>q2->exp){
		insert3(q1->coff,q1->exp);
		q1=q1->link;
		}
		}
		else if(q2->exp>q1->exp){
		while(q2->exp > q1->exp){
		insert3(q2->coff,q2->exp);
		q2=q2->link;
			}
		}
		else if(q1->exp==q2->exp){
		while(q1->exp==q2->exp){
		insert3((q2->coff+q1->coff),q1->exp);
		q1=q1->link;
		q2=q2->link;
		} }
		else
		{
		q1=q1->link;
		q2=q2->link;
		}
	}
	q3=start3;	
	while(q3!=NULL)
	{
		printf("%d |",q3->coff);
		printf("%d-->",q3->exp);
		q3=q3->link;
	}printf("NULL\n");
	
	
	return 0;
}
Esempio n. 14
0
int Bench(int argc,char **argv)
{
	REF(Module)  moduleH;
	REF(any) r;
	char moduleName[40];
	// ProcessStats    totalTime;
	// ServerStats     totalSrvTime;
	//char*	purgeVar;
	char  resultText[200];  // buffer to hold result of operation for
                                // printing outside of timing region.
	char *configfile;
	int opIndex = 2;
	int repeatCount = 1;
	BenchmarkOp whichOp = Trav1;
	bool manyXACTS = 0;

	w_rc_t rc;

#ifdef PARSETS

	LOID objtype;

	int NumNodes;

	//reinitialize some globals.
	nextAtomicId=0; 
	nextCompositeId=0;
	nextComplexAssemblyId=0;
	nextBaseAssemblyId=0;
	nextModuleId = TotalModules;
	initParSets(argc, argv);

	if (argc < 6){
	    fprintf(stderr, "Usage: %s %s\n", argv[0], usage1);
	    fprintf(stderr, "%s\n", usage3);
	    fprintf(stderr, "%s\n", usage4);

	    exit(1);
	}

	sscanf(argv[5], "%d", &NumNodes);
	printf("NUMNODES = %d\n", NumNodes);

	for (int j=0; j< NumNodes; j++)
	  CompNodes.Add(j+1);

#endif

	rc = initialize(argc, argv, usage1);
	if(rc) {
	    return 1;
	}

	rc = Shore::begin_transaction(3);
	if(rc){
	    cerr << "can't begin transaction: " << rc << endl;
	    return 1;
	}

	// initialize parameters for benchmark.
	ParseCommandLine(argc, argv, opIndex, repeatCount, whichOp, manyXACTS,
		&configfile);

#ifdef PARSETS
	SetParams(argv[1], slArgs);
#else
	SetParams(configfile);
#endif
	rc = InitGlobals();
	if(rc){
	    cerr << "Error in InitGlobals: " << rc << endl;
	    exit(1);
	}

	nextAtomicId  = TotalAtomicParts + 1;
	nextCompositeId = TotalCompParts + 1;

	rc = Shore::commit_transaction();
	if(rc){
	    cerr << "can't commit transaction: " << rc << endl;
	    return 1;
	}

#ifdef PARSETS


	SlaveRPC(CompNodes, (char *) slaveGenInit, (char *)&slArgs, sizeof(SlaveArgs));	
	SlaveRPC(CompNodes, (char *)slaveOpenPools, NULL, -1);	

#ifdef NEWCOMMUNICATION
	myParSetServer->CreateParSet("oo7db", "CompositePart", ParSet::kPrimary, objtype,(char *)createCompositePart, 4, CompNodes, ParSet::kUserDef, 
		     (char *)declusterCompositeParts);
#else
	CreateParSet("oo7db", "CompositePart", ParSet::kPrimary, objtype,
		     4, (char *)createCompositePart, CompNodes, 
		     ParSet::kUserDef, (char *)declusterCompositeParts);

#endif

	compositeParSet = new PrimaryParSet <REF(CompositePart)>("oo7db", "CompositePart");
#endif

	// Compute structural info needed by the update operations,
        // since these operations need to know which id's should
        // be used next.

	int baseCnt = NumAssmPerAssm;
	int complexCnt = 1;	for (int i = 1; i < NumAssmLevels-1; i++) {
            baseCnt = baseCnt * NumAssmPerAssm;
            complexCnt += complexCnt * NumAssmPerAssm;
	}
	nextBaseAssemblyId = TotalModules*baseCnt + 1;
	nextComplexAssemblyId = TotalModules*complexCnt + 1;
	nextAtomicId = TotalAtomicParts + 1;
	nextCompositeId = TotalCompParts + 1;


	// needed for insert and delete tests
	shared_cp = new BAIdList[TotalCompParts+NumNewCompParts+1];
	private_cp = new BAIdList[TotalCompParts+NumNewCompParts+1];


	// See if debug mode is desired, see which operation to run,
	// and how many times to run it.



	// totalTime.Start();
	// totalSrvTime.Start();

	enum {do_commit, do_chain, do_nothing, do_begin } choice=do_begin;

        // Actually run the darn thing.
	for (int iter = 0; iter < repeatCount; iter++) 
	{
	    //////////////////////////////////////////////////////////////////
	    // Run an OO7 Benchmark Operation
	    //
	    //////////////////////////////////////////////////////////////////

	    printf("RUNNING OO7 BENCHMARK OPERATION %s, iteration = %d.\n", 
	           argv[opIndex], iter);

  	    // get wall clock time
            gettimeofday(&startWallTime, IGNOREZONE &ignoreTimeZone);

	    // get starting usage values.
	    getrusage(RUSAGE_SELF, &startUsage);

	    // Start a new transaction if either this is the first iteration
	    // of a multioperation transaction or we we are running each
	    // operate as a separate transaction

#ifdef PARSETS
	    if(choice == do_begin) {
		W_COERCE(Shore::begin_transaction(3));
		SlaveRPC(CompNodes, (char *)slaveBeginTransaction, NULL, -1);
	    }

#else
	    if(choice == do_begin) {
		// E_BeginTransaction();
		W_COERCE(Shore::begin_transaction(3));
	    }
#endif

            // set random seed so "hot" runs are truly hot
            srandom(1);

	    // Use random module for the operation
//            int moduleId = (int) (random() % TotalModules) + 1;
	for (int moduleId = 1 ; moduleId <= TotalModules; moduleId++){
			
#ifdef USE_MODULE_INDEX
            sprintf(moduleName, "Module %08d", moduleId);
//	    printf("moduleName=%s\n",moduleName);
	    moduleH =  tbl->ModuleIdx.find(moduleName);
#else
	    sprintf(moduleName,"Module%d", moduleId);
	    rc = REF(Module)::lookup(moduleName, moduleH);
	    if(rc){
		cerr << "Can't find module " << moduleName << ": "
		     << rc << endl;
		return 1;
	    }
#endif
	    printf("Traversing Module= %s\n", moduleName);
	    if (moduleH == NULL)
	    {
	        fprintf(stderr, "ERROR: Unable to access %s.\n", moduleName);
		// E_AbortTransaction();
		W_COERCE(Shore::abort_transaction());
	        exit(1);
	    }

	    // Perform the requested operation on the chosen module
	    long count = 0;
	    int docCount = 0;
	    int charCount = 0;
	    int replaceCount = 0;

	    switch (whichOp) {
	        case Trav1:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 1 DFS visited %d atomic parts.\n",
			             count);
  		    break;
		 case Trav1WW:
                    RealWork = 1;
                    whichOp = Trav1;  // so traverse methods don't complain
                    count = moduleH->traverse(whichOp);
                    whichOp = Trav1WW;  // for next (hot) traversal
                    sprintf(resultText, "Traversal 1WW DFS visited %d atomic parts.\n",
                                     count);
                    break;
	        case Trav2a:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 2A swapped %d pairs of (X,Y) coordinates.\n",
 			         count);
		    break;
	        case Trav2b:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 2B swapped %d pairs of (X,Y) coordinates.\n",
			             count);
		    break;
	        case Trav2c:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 2C swapped %d pairs of (X,Y) coordinates.\n",
			             count);
		    break;
	        case Trav3a:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 3A toggled %d dates.\n",
			             count);
		    break;
	        case Trav3b:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 3B toggled %d dates.\n",
			             count);
		    break;
	        case Trav3c:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 3C toggled %d dates.\n",
			            count);
		    break;
	        case Trav4:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 4: %d instances of the character found\n",
			             count);
		    break;
	        case Trav5do:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 5(DO): %d string replacements performed\n",
			             count);
		    break;
	        case Trav5undo:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 5(UNDO): %d string replacements performed\n",
			         count);
		    break;
	        case Trav6:
	            count = moduleH->traverse(whichOp);
	            sprintf(resultText, "Traversal 6: visited %d atomic part roots.\n",
			             count);
		    break;
	        case Trav7:
	            count = traverse7();
		    sprintf(resultText, "Traversal 7: found %d assemblies using rand om atomic part.\n", 
			count);
		    break;
	        case Trav8:
	            count = moduleH->scanManual();
		    sprintf(resultText, "Traversal 8: found %d occurrences of character in manual.\n", 
			count);
		    break;
	        case Trav9:
	            count = moduleH->firstLast();
		    sprintf(resultText, "Traversal 9: match was %d.\n", 
			count);
		    break;

                case Trav10:
                    // run traversal #1 on every module.
                    count = 0;
                    whichOp = Trav1;  // so object methods don't complain
                    for (moduleId = 1; moduleId <= TotalModules; moduleId++) {
                        sprintf(moduleName, "Module %08d", moduleId);
			bool found;
	  	        shrc rc =tbl->ModuleIdx.find(moduleName,moduleH,found);
   	                if (rc || !found ||moduleH == NULL) {
                                fprintf(stderr,
                                        "ERROR: t10 Unable to access %s.\n",
                                         moduleName);
				W_COERCE(Shore::abort_transaction());
                                exit(1);
                        }
                        count += moduleH->traverse(whichOp);
                    }
                    sprintf(resultText,
                           "Traversal 10 visited %d atomic parts in %d modules.\\n",
                                     count, TotalModules);
                    whichOp = Trav10;  // for next time around
                    break;           

	        case Query1:
	            count = query1();
	            sprintf(resultText, "Query one retrieved %d atomic parts.\n",
			             count);
		    break;
	        case Query2:
	            count = query2();
	            sprintf(resultText, "Query two retrieved %d qualifying atomic parts.\n",
			         count);
		    break;
	        case Query3:
	            count = query3();
	            sprintf(resultText, "Query three retrieved %d qualifying atomic parts.\n",
			         count);
		    break;
	        case Query4:
	            count = query4();
	            sprintf(resultText, "Query four retrieved %d (document, base assembly) pairs.\n",
			         count);
		    break;
	        case Query5:
	            count = query5();
	            sprintf(resultText, "Query five retrieved %d out-of-date base assemblies.\n",
			             count);
		    break;
	        case Query6:
	            count = query6();
	            sprintf(resultText, "Query six retrieved %d out-of-date assemblies.\n",
			         count);
		    break;
	        case Query7:
	            count = query7();
		    sprintf(resultText, "Query seven iterated through %d atomic part s.\n",
			             count);
		    break;
	        case Query8:
	            count = query8();
		    sprintf(resultText, "Query eight found %d atomic part/document m atches.\n",
			 count);
		    break;
	        case Insert:
	            insert1();
	            sprintf(resultText, "Inserted %d composite parts (a total of %d atomic parts.)\n",
		      NumNewCompParts, NumNewCompParts*NumAtomicPerComp);
		    break;
	        case Delete:
	            delete1();
	            sprintf(resultText, "Deleted %d composite parts (a total of %d atomic parts.)\n",
	             NumNewCompParts, NumNewCompParts*NumAtomicPerComp);
		    break;

		 case Reorg1:
		     count = reorg1();
		     sprintf(resultText, "Reorg1 replaced %d atomic parts.\n", 
			count);
		     break;

	    	 case Reorg2:
		     count = reorg2();
		     sprintf(resultText, "Reorg2 replaced %d atomic parts.\n", 
			count);
		     break;
// NEW
	        case WarmUpdate:
		    // first do the t1 traversal to warm the cache
	            count = moduleH->traverse(Trav1);
		    // then call T2 to do the update
	            count = moduleH->traverse(Trav2a);
	            sprintf(resultText, 
			"Warm update swapped %d pairs of (X,Y) coordinates.\n",
 			         count);
		     break;
	        default:
	            fprintf(stderr, "Sorry, that operation isn't available yet.\n");
		    // E_AbortTransaction();
		    W_COERCE(Shore::abort_transaction());
	            exit(1);
	    }
		printf("Visited=%d\n", count);
	}
	{ 
#ifdef PARSETS

	    if ((iter == repeatCount-1) || manyXACTS){
		printf("Calling commit transaction\n");
		SlaveRPC(CompNodes, (char *)slaveCommitTransaction, NULL, -1);
		choice = do_commit;
	    }
#else
	    // Commit the current transaction if 
	    // we are running the last iteration 
	    // or running a multitransaction test and not chaining
	    // Chain the tx if we are chaining and not on
	    // the last iteration

	    if (iter == repeatCount-1) {
		choice=do_commit;
		// commit 
	    } else if(manyXACTS) {
		// not last iteration, multi tx test
		if(chain_tx) {
		    choice=do_chain;
		} else {
		    choice=do_commit;
		}
	    } else choice=do_nothing;
#endif
	    if(choice==do_commit) {
		//E_CommitTransaction();
		W_COERCE(Shore::commit_transaction());
		choice = do_begin;
	    } else if (choice==do_chain) {
		W_COERCE(Shore::chain_transaction());
		choice = do_nothing;
	    } 
	}

            // compute and report wall clock time
            gettimeofday(&endWallTime, IGNOREZONE &ignoreTimeZone);
	    printf("SHORE, operation= %s, iteration= %d, elapsedTime= %f seconds\n",
               argv[opIndex], iter,
               ComputeWallClockTime(&startWallTime, &endWallTime));
            if (iter == 1) startWarmTime = startWallTime;

            // Compute and report CPU time.
	    getrusage(RUSAGE_SELF, &endUsage);
            fprintf(stdout, resultText);
	    fprintf(stdout, "CPU time: %f seconds.\n", 
	                ComputeUserTime(&startUsage, &endUsage) +
			ComputeSystemTime(&startUsage, &endUsage));
	    fprintf(stdout, "(%f seconds user, %f seconds system.)\n", 
	                ComputeUserTime(&startUsage, &endUsage),
			ComputeSystemTime(&startUsage, &endUsage));

	    if ((repeatCount > 2) && (iter == repeatCount-2)) 
	    {
	       // compute average hot time for 2nd through n-1 th iterations
               printf("SHORE, operation=%s, average hot elapsedTime=%f seconds\n",
	       	  argv[opIndex], 
	          ComputeWallClockTime(&startWarmTime, &endWallTime)/(repeatCount-2)); 
	    }
	  }

	//////////////////////////////////////////////////////////////////
	//
	// Shutdown 
	//
	//////////////////////////////////////////////////////////////////

#ifdef PARSETS
	cleanupParSets();
#endif
	// totalTime.Stop();
	// totalSrvTime.Stop();
	// fprintf(stdout, "Total stats (client,server):\n");
	// totalTime.PrintStatsHeader(stdout);
	// totalTime.PrintStats(stdout, "TotalCli");
	// totalSrvTime.PrintStats(stdout, "TotalSrv");

	// Exit
	W_COERCE(Shore::exit());
	return(0);
}
Esempio n. 15
0
inline void MonomialIdeal::insert_minimal(Bag *b)
{
  insert1(mi, b);
  count += 2;
}