Esempio n. 1
0
	const PositionListPairPtr ColumnBaseTyped<Type>::nested_loop_join(ColumnPtr join_column_){
				assert(join_column_!=NULL);
				if(join_column_->type()!=typeid(Type)){
					std::cout << "Fatal Error!!! Typemismatch for columns " << this->name_  << " and " << join_column_->getName() << std::endl;
					std::cout << "File: " << __FILE__ << " Line: " << __LINE__ << std::endl;
					exit(-1);
				}
				
				shared_pointer_namespace::shared_ptr<ColumnBaseTyped<Type> > join_column = shared_pointer_namespace::static_pointer_cast<ColumnBaseTyped<Type> >(join_column_); //static_cast<IntColumnPtr>(column1);

				PositionListPairPtr join_tids( new PositionListPair());
				join_tids->first = PositionListPtr( new PositionList() );
				join_tids->second = PositionListPtr( new PositionList() );

		for(unsigned int i=0;i<this->size();i++){
			for(unsigned int j=0;j<join_column->size();j++){
				if((*this)[i]==(*join_column)[j]){
					if(debug) std::cout << "MATCH: (" << i << "," << j << ")" << std::endl;
					join_tids->first->push_back(i);
					join_tids->second->push_back(j);
				}
			}
		}

		return join_tids;
	}
Esempio n. 2
0
	const PositionListPairPtr ColumnBaseTyped<Type>::sort_merge_join(ColumnPtr join_column_){

				if(join_column_->type()!=typeid(Type)){
					std::cout << "Fatal Error!!! Typemismatch for columns " << this->name_  << " and " << join_column_->getName() << std::endl;
					std::cout << "File: " << __FILE__ << " Line: " << __LINE__ << std::endl;
					exit(-1);
				}
				
				shared_pointer_namespace::shared_ptr<ColumnBaseTyped<Type> > join_column = shared_pointer_namespace::static_pointer_cast<ColumnBaseTyped<Type> >(join_column_); //static_cast<IntColumnPtr>(column1);

				PositionListPairPtr join_tids( new PositionListPair());
				join_tids->first = PositionListPtr( new PositionList() );
				join_tids->second = PositionListPtr( new PositionList() );

				return join_tids;
	}
Esempio n. 3
0
	const PositionListPairPtr ColumnBaseTyped<T>::hash_join(ColumnPtr join_column_){

		typedef boost::unordered_multimap < T, TID, boost::hash<T>, std::equal_to<T> > HashTable;

				if(join_column_->type()!=typeid(T)){
					std::cout << "Fatal Error!!! Typemismatch for columns " << this->name_  << " and " << join_column_->getName() << std::endl;
					std::cout << "File: " << __FILE__ << " Line: " << __LINE__ << std::endl;
					exit(-1);
				}
				
				shared_pointer_namespace::shared_ptr<ColumnBaseTyped<T> > join_column = shared_pointer_namespace::static_pointer_cast<ColumnBaseTyped<T> >(join_column_); //static_cast<IntColumnPtr>(column1);

				PositionListPairPtr join_tids( new PositionListPair());
				join_tids->first = PositionListPtr( new PositionList() );
				join_tids->second = PositionListPtr( new PositionList() );


	//create hash table
	HashTable hashtable;
	for(unsigned int i=0;i<this->size();i++)	
		hashtable.insert(
								std::pair<T,TID> ((*this)[i],i)
					);

	//probe larger relation
	for(unsigned int i=0;i<join_column->size();i++){
		std::pair<typename HashTable::iterator, typename HashTable::iterator> range =  hashtable.equal_range((*join_column)[i]);
		for(typename HashTable::iterator it=range.first ; it!=range.second;it++){
			if(it->first==(*join_column)[i]){
				join_tids->first->push_back(it->second);
				join_tids->second->push_back(i);
				//cout << "match! " << it->second << ", " << i << "	"  << it->first << endl;
			}
		}
	}

		return join_tids;
	}