DataFrameJoinVisitors::DataFrameJoinVisitors(const DataFrame& left_, const DataFrame& right_, const SymbolVector& names_left, const SymbolVector& names_right, bool warn_, bool na_match) : left(left_), right(right_), visitor_names_left(names_left), visitor_names_right(names_right), visitors(names_left.size()), warn(warn_) { IntegerVector indices_left = names_left.match_in_table(RCPP_GET_NAMES(left)); IntegerVector indices_right = names_right.match_in_table(RCPP_GET_NAMES(right)); const int nvisitors = indices_left.size(); if (indices_right.size() != nvisitors) { stop("Different size of join column index vectors"); } for (int i = 0; i < nvisitors; i++) { const SymbolString& name_left = names_left[i]; const SymbolString& name_right = names_right[i]; if (indices_left[i] == NA_INTEGER) { stop("'%s' column not found in lhs, cannot join", name_left.get_utf8_cstring()); } if (indices_right[i] == NA_INTEGER) { stop("'%s' column not found in rhs, cannot join", name_right.get_utf8_cstring()); } visitors[i] = join_visitor( Column(left[indices_left[i] - 1], name_left), Column(right[indices_right[i] - 1], name_right), warn, na_match ); } }
DataFrameJoinVisitors::DataFrameJoinVisitors(const Rcpp::DataFrame& left_, const Rcpp::DataFrame& right_, Rcpp::CharacterVector names_left, Rcpp::CharacterVector names_right, bool warn_ ) : left(left_), right(right_), visitor_names_left(names_left), visitor_names_right(names_right), nvisitors(names_left.size()), visitors(nvisitors), warn(warn_) { std::string name_left, name_right ; IntegerVector indices_left = Language( "match", names_left, RCPP_GET_NAMES(left) ).fast_eval() ; IntegerVector indices_right = Language( "match", names_right, RCPP_GET_NAMES(right) ).fast_eval() ; for( int i=0; i<nvisitors; i++){ name_left = names_left[i] ; name_right = names_right[i] ; if( indices_left[i] == NA_INTEGER ){ stop( "'%s' column not found in lhs, cannot join" ) ; } if( indices_right[i] == NA_INTEGER ){ stop( "'%s' column not found in rhs, cannot join" ) ; } visitors[i] = join_visitor( left[indices_left[i]-1], right[indices_right[i]-1], name_left, name_right, warn ) ; } }
DataFrameJoinVisitors::DataFrameJoinVisitors(const Rcpp::DataFrame& left_, const Rcpp::DataFrame& right_, Rcpp::CharacterVector names_left, Rcpp::CharacterVector names_right, bool warn_ ) : left(left_), right(right_), visitor_names_left(names_left), visitor_names_right(names_right), nvisitors(names_left.size()), visitors(nvisitors), warn(warn_) { std::string name_left, name_right ; for( int i=0; i<nvisitors; i++){ name_left = names_left[i] ; name_right = names_right[i] ; try{ visitors[i] = join_visitor( left[name_left], right[name_right], name_left, name_right, warn ) ; } catch( const std::exception& ex ){ stop( "cannot join on columns '%s' x '%s': %s ", name_left, name_right, ex.what() ) ; } catch( ... ){ stop( "cannot join on columns '%s' x '%s'", name_left, name_right ) ; } } }
DataFrameJoinVisitors::DataFrameJoinVisitors( const DataFrame& left_, const DataFrame& right_, const IntegerVector& indices_left, const IntegerVector& indices_right, bool warn_, bool na_match ) : left(left_), right(right_), visitor_names_left(), visitor_names_right(), visitors(indices_left.size()), warn(warn_) { if (indices_right.size() != size()) { stop("Different size of join column index vectors"); } SymbolVector left_names = left.names(); SymbolVector right_names = right.names(); for (int i = 0; i < size(); i++) { const int index_left = indices_left[i]; const int index_right = indices_right[i]; check_range_one_based(index_left, left.size()); check_range_one_based(index_right, right.size()); const SymbolString& name_left = left_names[index_left - 1]; const SymbolString& name_right = right_names[index_right - 1]; visitors[i] = join_visitor( Column(left[index_left - 1], name_left), Column(right[index_right - 1], name_right), warn, na_match ); visitor_names_left.push_back(name_left); visitor_names_right.push_back(name_right); } }