Esempio n. 1
0
int OneSideHashJoin::getRow(PosVal **pv_, unsigned int pvNum_){
	int returnCode;
	//ONESIDE_HASH_NODE *hnp;
	unsigned int hashkey;
	
	if(getRowFlag == 0){
		while(1){
			returnCode = outerOpeNode->getRow(&pv[innerAttriNum], outerAttriNum);
			if(returnCode != 0){
				delHash();
				getRowFlag = -1;
				return -1;
			}else{
				hashkey = 0;
				for(unsigned int i = 0; i < nodeNum; i++)
					hashkey += hashFunc(pv[outerPos[i]]);
				hashkey = hashkey%HASH_SIZE;
				innerHash->ScanNode->setHashkey(hashkey);
				getRowFlag = 1;
				break;
			}
		}
	}			

	if(getRowFlag == -1){
		return -1;
	}

	while(1){
		returnCode = innerHash->ScanNode->getRow(pv, innerAttriNum);
		if(returnCode == 0){
			unsigned int posIndex;
			for(posIndex = 0; posIndex < nodeNum; posIndex++){
				if(!(*pv[innerPos[posIndex]] == pv[outerPos[posIndex]]))
					break;
			}
			if(posIndex == nodeNum){
				for(unsigned int i = 0; i < attriNum; i++) *pv_[i] = *pv[i];
				return 0;
			}
			continue;
		}

		returnCode = outerOpeNode->getRow(&pv[innerAttriNum], outerAttriNum);
		if(returnCode != 0){
			getRowFlag = -1;
			delHash();
			return -1;
		}else{
			hashkey = 0;
			for(unsigned int i = 0; i < nodeNum; i++)
				hashkey += hashFunc(pv[outerPos[i]]);
			hashkey %= HASH_SIZE;
			innerHash->ScanNode->setHashkey(hashkey);
		}
	}	
}			
Esempio n. 2
0
int main()
{
	FILE *file;
	file = fopen("txt.txt", "r");
	while(!feof(file))
	{
		char string[12];
		fscanf(file, "%s", string);
		addHash(string);
	}
	printHash();
	delHash();
	std :: cin.get();
	return 0;
}