Beispiel #1
0
void FingerTable::initfingers() 
{
	ChordId EmptyId ;
	for (int pos = 1; pos <= getTableLength(); pos++) 
	{
        /*generater start*/
		ChordId start = ChordId(localnode->getChordId().GetId(),constants,"","");
		start.add(ChordId(int(pow(2,pos-1)),constants,"",""));

		/*generater end*/
		ChordId end = ChordId(localnode->getChordId().GetId(),constants,"","");
		if(pos != NBITS) 
			end.add(ChordId(int(pow(2,pos)),constants,"",""));
    
		fingers[pos-1].start = start ;
		fingers[pos-1].interval[0] = start ;
		fingers[pos-1].interval[1] = end ;

		//init the all nodes
		fingers[pos-1].node = EmptyId ;
    }

	setPredecessor(EmptyId) ;
	clearSuccList() ;
}
void 
run() {
  int i = 0; 
  int pageNum; 
  PagePointer cursor; 
  PagePointer cursorPrev; 
  for (; i < INSTRUCTIONSIZE; i++) {
    usleep(256000); 
    pageNum = instructionArray[i] / PAGESIZE; 
    if (isInTable(pageNum) == 1) {
      printf("[命中: address#%d\tin page#%d]\t", instructionArray[i], pageNum); printTable(); 
      /*printf("Hit: address#%d\tin page#%d\t", instructionArray[i], pageNum); printTable(); */
    } else {
      if (getTableLength() < 5) {
        cursor = pageTable->next; 
        cursorPrev = pageTable; 
        while (cursor != NULL) {
          cursor = cursor->next; 
          cursorPrev = cursorPrev->next; 
        }
        cursor = (PagePointer)malloc(sizeof(PageNode)); 
        cursor->num = pageNum; 
        cursor->next = NULL; 
        cursorPrev->next = cursor; 
        printf("[调入: address#%d\tin page#%d]\t", instructionArray[i], pageNum); printTable(); 
        /*printf("In : address#%d\tin page#%d\t", instructionArray[i], pageNum); printTable(); */
      } else {
        PagePointer out = pageTable->next; 
        pageTable->next = out->next; 
        printf("[换出: page#%d]\t", out->num); 
        /*printf("Out: page#%d\t", out->num); */
        out->num = pageNum; 
        out->next = NULL; 
        cursor = pageTable->next; 
        cursorPrev = pageTable; 
        while (cursor != NULL) {
          cursor = cursor->next; 
          cursorPrev = cursorPrev->next; 
        }
        cursorPrev->next = out; 
        printf("[调入: address#%d\tin page#%d]\t", instructionArray[i], pageNum); printTable(); 
        /*printf("In : address#%d\tin page#%d\t", instructionArray[i], pageNum); printTable(); */
      }
    }
  }

}
Beispiel #3
0
    void GeneratedPseudoGenome<uint_read_len, uint_reads_cnt, uint_pg_len, GeneratedReadsListClass>::buildRepetitiveReadsFilter() {
        clock_checkpoint();

        uint_max filterCount = 0;

        genReadsList->setDuplicateFilterKmerLength(this->duplicateFilterKmerLength);
        
        uint_pg_len* lookup = new uint_pg_len[getTableLength()]();
        
        uint_max lookupIdx = 0;
        for (uint_read_len i = 0; i < this->duplicateFilterKmerLength; i++)
            lookupIdx = lookupIdx * this->properties->symbolsCount + this->properties->symbolOrder[(unsigned char) this->getSymbol(i)];

        uint_max popSymbol[UCHAR_MAX] = {0};
        for(uchar j = 1; j < this->properties->symbolsCount; j++) {
            popSymbol[j] = j;
            for(uchar k = 1; k < this->duplicateFilterKmerLength; k++)
                popSymbol[j] *= this->properties->symbolsCount;
        }

        uint_reads_cnt readsListIndex = 0;
        
        uint_pg_len i = 0;
        while (i < this->length) {
            while ((int_max) genReadsList->getReadPosition(readsListIndex) < (int_max) i + this->duplicateFilterKmerLength - this->maxReadLength())
                readsListIndex++;            
            
            while (lookup[lookupIdx] >= genReadsList->getReadPosition(readsListIndex) + 1) {
                genReadsList->setDuplicateFilterFlag(readsListIndex);
                filterCount++;
                readsListIndex++;
            }
                
            lookup[lookupIdx] = i + 1;
            lookupIdx -= popSymbol[this->properties->symbolOrder[(unsigned char) this->getSymbol(i)]];
            lookupIdx = lookupIdx * this->properties->symbolsCount + this->properties->symbolOrder[(unsigned char) this->getSymbol(i++ + this->duplicateFilterKmerLength)];
        }

        delete[] lookup;
        
        cout << "Found " << filterCount << " reads containing duplicate " << (int) genReadsList->getDuplicateFilterKmerLength()
                << "-mers in " << clock_millis() << " msec!\n";
    }
Beispiel #4
0
int FingerTable::toString(char **buf , unsigned int &length) 
{
	/**/
	char *buffer = new char[4000] ;
	if (buffer==NULL)
	  return -1;

	char *message = buffer ;

	sprintf(message,"**********FINGER TABLE**********") ;
	message = message + strlen (message);
	strncpy (message, "\r\n\0", 2);
	message = message + 2;

	for(int i = 0 ; i < getTableLength() ; i++)
	{
		sprintf (message, "finger[%d]:	node:%d		start:%d	interval:%d~%d", 
			i+1,
			getFinger(i+1)->node.GetId() ,
			getFinger(i+1)->start.GetId() ,
			getFinger(i+1)->interval[0].GetId() ,
			getFinger(i+1)->interval[1].GetId() 
			);
		message = message + strlen (message);
		strncpy (message, "\r\n\0", 2);
		message = message + 2;
	}

	sprintf(message,"**********SUCC LIST**********") ;
	message = message + strlen (message);
	strncpy (message, "\r\n\0", 2);
	message = message + 2;

	for(i = 0 ; i < getSuccNum() ; i++)
	{
		sprintf (message, "SUCCLIST[%d]:	id:%d		ip:%s", 
			i,
			getSuccessor(i).GetId() ,
			getSuccessor(i).GetAddress() 
			);
		message = message + strlen (message);
		strncpy (message, "\r\n\0", 2);
		message = message + 2;
	}

	sprintf(message,"\r\n**********PREDECESSOR**********") ;
	message = message + strlen (message);
	strncpy (message, "\r\n\0", 2);
	message = message + 2;

	sprintf (message, "PREDECESSOR:		id:%d		ip:%s", 
			getPredecessor().GetId() ,
			getPredecessor().GetAddress() 
			);
	message = message + strlen (message);
	strncpy (message, "\r\n\0", 2);
	message = message + 2;

	strncpy(message,"\0",1) ;
	*buf = buffer ;
	length = strlen(buffer) ;
	return 0 ;
}