Skip to content

Commit

Permalink
multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Aug 31, 2016
1 parent f3fb181 commit fd859c0
Show file tree
Hide file tree
Showing 25 changed files with 352 additions and 171 deletions.
10 changes: 8 additions & 2 deletions inst/include/dplyr/BoolResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ namespace dplyr {
BoolResult(bool result_) : result(result_) {}
BoolResult(bool result_, const std::string& msg) : result(result_), message(msg) {}

void set_true() { result = true ; message.clear() ; }
void set_false( const char* msg ) { result = false; message = msg ; }
void set_true() {
result = true ;
message.clear() ;
}
void set_false( const char* msg ) {
result = false;
message = msg ;
}

inline operator SEXP() const {
LogicalVector res = LogicalVector::create( result ) ;
Expand Down
15 changes: 10 additions & 5 deletions inst/include/dplyr/Collecter.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,17 @@ namespace dplyr {
return new Collecter_Impl<REALSXP>(n) ;
case CPLXSXP:
return new Collecter_Impl<CPLXSXP>(n) ;
case LGLSXP: return new Collecter_Impl<LGLSXP>(n) ;
case STRSXP: return new Collecter_Impl<STRSXP>(n) ;
case LGLSXP:
return new Collecter_Impl<LGLSXP>(n) ;
case STRSXP:
return new Collecter_Impl<STRSXP>(n) ;
case VECSXP:
if( Rf_inherits( model, "POSIXlt" )) {
stop( "POSIXlt not supported" ) ;
}
return new Collecter_Impl<VECSXP>(n) ;
default: break ;
default:
break ;
}

stop("Unsupported vector type %s", Rf_type2char(TYPEOF(model))) ;
Expand Down Expand Up @@ -403,12 +406,14 @@ namespace dplyr {
if( Rf_inherits( model, "Date" ) )
return new TypedCollecter<REALSXP>(n, get_date_classes() ) ;
return new Collecter_Impl<REALSXP>(n) ;
case LGLSXP: return new Collecter_Impl<LGLSXP>(n) ;
case LGLSXP:
return new Collecter_Impl<LGLSXP>(n) ;
case STRSXP:
if( previous->is_factor_collecter() )
Rf_warning("binding factor and character vector, coercing into character vector") ;
return new Collecter_Impl<STRSXP>(n) ;
default: break ;
default:
break ;
}
stop("Unsupported vector type %s", Rf_type2char(TYPEOF(model))) ;
return 0 ;
Expand Down
8 changes: 6 additions & 2 deletions inst/include/dplyr/DataFrameJoinVisitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ namespace dplyr {
return (SEXP)out ;
}

const CharacterVector& left_names() const { return visitor_names_left ;}
const CharacterVector& right_names() const { return visitor_names_right ;}
const CharacterVector& left_names() const {
return visitor_names_left ;
}
const CharacterVector& right_names() const {
return visitor_names_right ;
}

private:
const DataFrame& left ;
Expand Down
16 changes: 12 additions & 4 deletions inst/include/dplyr/DataFrameSubsetVisitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,20 @@ namespace dplyr {
) ;
}

inline int size() const { return nvisitors ; }
inline SubsetVectorVisitor* get(int k) const { return visitors[k] ; }
inline int size() const {
return nvisitors ;
}
inline SubsetVectorVisitor* get(int k) const {
return visitors[k] ;
}

Rcpp::String name(int k) const { return visitor_names[k] ; }
Rcpp::String name(int k) const {
return visitor_names[k] ;
}

inline int nrows() const { return data.nrows() ; }
inline int nrows() const {
return data.nrows() ;
}

private:

Expand Down
20 changes: 14 additions & 6 deletions inst/include/dplyr/DataFrameVisitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ namespace dplyr {

DataFrameVisitors( const Rcpp::DataFrame& data_, const Rcpp::CharacterVector& names ) ;

inline int size() const { return nvisitors ; }
inline VectorVisitor* get(int k) const { return visitors[k] ; }

Rcpp::String name(int k) const { return visitor_names[k] ; }

inline int nrows() const { return data.nrows() ; }
inline int size() const {
return nvisitors ;
}
inline VectorVisitor* get(int k) const {
return visitors[k] ;
}

Rcpp::String name(int k) const {
return visitor_names[k] ;
}

inline int nrows() const {
return data.nrows() ;
}

private:

Expand Down
60 changes: 38 additions & 22 deletions inst/include/dplyr/Gatherer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace dplyr {
typename Data::group_iterator git = gdf.group_begin() ;
int i = 0 ;
for(; i<first_non_na; i++) ++git ;
++git; i++ ;
++git;
i++ ;
for(; i<ngroups; i++, ++git) {
SlicingIndex indices = *git ;
Shield<SEXP> subset( proxy.get( indices ) ) ;
Expand Down Expand Up @@ -107,7 +108,8 @@ namespace dplyr {
typename Data::group_iterator git = gdf.group_begin() ;
int i = 0 ;
for(; i<first_non_na; i++) ++git ;
++git; i++ ;
++git;
i++ ;
for(; i<ngroups; i++, ++git) {
SlicingIndex indices = *git ;
List subset( proxy.get(indices) ) ;
Expand Down Expand Up @@ -268,13 +270,20 @@ namespace dplyr {
stop("`mutate` does not support `POSIXlt` results");
}
switch( TYPEOF(x) ) {
case INTSXP: return new ConstantGathererImpl<INTSXP>( x, n ) ;
case REALSXP: return new ConstantGathererImpl<REALSXP>( x, n ) ;
case LGLSXP: return new ConstantGathererImpl<LGLSXP>( x, n ) ;
case STRSXP: return new ConstantGathererImpl<STRSXP>( x, n ) ;
case CPLXSXP: return new ConstantGathererImpl<CPLXSXP>( x, n ) ;
case VECSXP: return new ConstantGathererImpl<STRSXP>( x, n ) ;
default: break ;
case INTSXP:
return new ConstantGathererImpl<INTSXP>( x, n ) ;
case REALSXP:
return new ConstantGathererImpl<REALSXP>( x, n ) ;
case LGLSXP:
return new ConstantGathererImpl<LGLSXP>( x, n ) ;
case STRSXP:
return new ConstantGathererImpl<STRSXP>( x, n ) ;
case CPLXSXP:
return new ConstantGathererImpl<CPLXSXP>( x, n ) ;
case VECSXP:
return new ConstantGathererImpl<STRSXP>( x, n ) ;
default:
break ;
}
stop("Unsupported vector type %s", Rf_type2char(TYPEOF(x))) ;
return 0 ;
Expand All @@ -292,25 +301,32 @@ namespace dplyr {
int ng = gdf.ngroups() ;
int i = 0 ;
while( all_na(first) ) {
i++ ; if( i == ng ) break ;
i++ ;
if( i == ng ) break ;
++git ;
indices = *git ;
first = proxy.get(indices) ;
}

switch( TYPEOF(first) ) {
case INTSXP:
{
if( Rf_inherits(first, "factor"))
return new FactorGatherer<Data, Subsets>( first, indices, proxy, gdf, i) ;
return new GathererImpl<INTSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
}
case REALSXP: return new GathererImpl<REALSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
case LGLSXP: return new GathererImpl<LGLSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
case STRSXP: return new GathererImpl<STRSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
case VECSXP: return new ListGatherer<Data,Subsets> ( List(first), indices, proxy, gdf, i ) ;
case CPLXSXP: return new GathererImpl<CPLXSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
default: break ;
case INTSXP:
{
if( Rf_inherits(first, "factor"))
return new FactorGatherer<Data, Subsets>( first, indices, proxy, gdf, i) ;
return new GathererImpl<INTSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
}
case REALSXP:
return new GathererImpl<REALSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
case LGLSXP:
return new GathererImpl<LGLSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
case STRSXP:
return new GathererImpl<STRSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
case VECSXP:
return new ListGatherer<Data,Subsets> ( List(first), indices, proxy, gdf, i ) ;
case CPLXSXP:
return new GathererImpl<CPLXSXP,Data,Subsets> ( first, indices, proxy, gdf, i ) ;
default:
break ;
}

check_supported_type(first, name);
Expand Down
62 changes: 40 additions & 22 deletions inst/include/dplyr/OrderVisitorImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ namespace dplyr {
return compare::is_less( vec[i], vec[j] ) ;
}

SEXP get() { return vec ; }
SEXP get() {
return vec ;
}

private:
VECTOR vec ;
Expand All @@ -50,7 +52,9 @@ namespace dplyr {
return compare::is_greater( vec[i], vec[j] ) ;
}

SEXP get() { return vec ; }
SEXP get() {
return vec ;
}

private:
VECTOR vec ;
Expand All @@ -72,7 +76,9 @@ namespace dplyr {
return orders.before(i,j);
}

SEXP get() { return vec; }
SEXP get() {
return vec;
}

private:
CharacterVector vec ;
Expand Down Expand Up @@ -208,12 +214,18 @@ namespace dplyr {
template <bool ascending>
inline OrderVisitor* order_visitor_asc_matrix( SEXP vec ) {
switch( check_supported_type(vec) ) {
case DPLYR_INTSXP: return new OrderVisitorMatrix<INTSXP , ascending>( vec ) ;
case DPLYR_REALSXP: return new OrderVisitorMatrix<REALSXP , ascending>( vec ) ;
case DPLYR_LGLSXP: return new OrderVisitorMatrix<LGLSXP , ascending>( vec ) ;
case DPLYR_STRSXP: return new OrderVisitorMatrix<STRSXP , ascending>( vec ) ;
case DPLYR_CPLXSXP: return new OrderVisitorMatrix<CPLXSXP , ascending>( vec ) ;
case DPLYR_VECSXP: stop("Matrix can't be a list", Rf_type2char(TYPEOF(vec))) ;
case DPLYR_INTSXP:
return new OrderVisitorMatrix<INTSXP , ascending>( vec ) ;
case DPLYR_REALSXP:
return new OrderVisitorMatrix<REALSXP , ascending>( vec ) ;
case DPLYR_LGLSXP:
return new OrderVisitorMatrix<LGLSXP , ascending>( vec ) ;
case DPLYR_STRSXP:
return new OrderVisitorMatrix<STRSXP , ascending>( vec ) ;
case DPLYR_CPLXSXP:
return new OrderVisitorMatrix<CPLXSXP , ascending>( vec ) ;
case DPLYR_VECSXP:
stop("Matrix can't be a list", Rf_type2char(TYPEOF(vec))) ;
}

stop("Unreachable") ;
Expand All @@ -223,19 +235,25 @@ namespace dplyr {
template <bool ascending>
inline OrderVisitor* order_visitor_asc_vector( SEXP vec ) {
switch( TYPEOF(vec) ) {
case INTSXP: return new OrderVectorVisitorImpl<INTSXP , ascending, Vector<INTSXP > >( vec ) ;
case REALSXP: return new OrderVectorVisitorImpl<REALSXP, ascending, Vector<REALSXP> >( vec ) ;
case LGLSXP: return new OrderVectorVisitorImpl<LGLSXP , ascending, Vector<LGLSXP > >( vec ) ;
case STRSXP: return new OrderCharacterVectorVisitorImpl<ascending>( vec ) ;
case CPLXSXP: return new OrderVectorVisitorImpl<CPLXSXP , ascending, Vector<CPLXSXP > >( vec ) ;
case VECSXP:
{
if( Rf_inherits( vec, "data.frame" ) ) {
return new OrderVisitorDataFrame<ascending>( vec ) ;
}
break ;
}
default: break ;
case INTSXP:
return new OrderVectorVisitorImpl<INTSXP , ascending, Vector<INTSXP > >( vec ) ;
case REALSXP:
return new OrderVectorVisitorImpl<REALSXP, ascending, Vector<REALSXP> >( vec ) ;
case LGLSXP:
return new OrderVectorVisitorImpl<LGLSXP , ascending, Vector<LGLSXP > >( vec ) ;
case STRSXP:
return new OrderCharacterVectorVisitorImpl<ascending>( vec ) ;
case CPLXSXP:
return new OrderVectorVisitorImpl<CPLXSXP , ascending, Vector<CPLXSXP > >( vec ) ;
case VECSXP:
{
if( Rf_inherits( vec, "data.frame" ) ) {
return new OrderVisitorDataFrame<ascending>( vec ) ;
}
break ;
}
default:
break ;
}

stop("Unsupported vector type %s", Rf_type2char(TYPEOF(vec))) ;
Expand Down
18 changes: 12 additions & 6 deletions inst/include/dplyr/Replicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ namespace dplyr {
inline Replicator* replicator( SEXP v, const Data& gdf ) {
int n = Rf_length(v) ;
switch( TYPEOF(v) ) {
case INTSXP: return new ReplicatorImpl<INTSXP , Data> ( v, n, gdf.ngroups() ) ;
case REALSXP: return new ReplicatorImpl<REALSXP, Data> ( v, n, gdf.ngroups() ) ;
case STRSXP: return new ReplicatorImpl<STRSXP , Data> ( v, n, gdf.ngroups() ) ;
case LGLSXP: return new ReplicatorImpl<LGLSXP , Data> ( v, n, gdf.ngroups() ) ;
case CPLXSXP: return new ReplicatorImpl<CPLXSXP, Data> ( v, n, gdf.ngroups() ) ;
default: break ;
case INTSXP:
return new ReplicatorImpl<INTSXP , Data> ( v, n, gdf.ngroups() ) ;
case REALSXP:
return new ReplicatorImpl<REALSXP, Data> ( v, n, gdf.ngroups() ) ;
case STRSXP:
return new ReplicatorImpl<STRSXP , Data> ( v, n, gdf.ngroups() ) ;
case LGLSXP:
return new ReplicatorImpl<LGLSXP , Data> ( v, n, gdf.ngroups() ) ;
case CPLXSXP:
return new ReplicatorImpl<CPLXSXP, Data> ( v, n, gdf.ngroups() ) ;
default:
break ;
}

stop("Unsupported vector type %s", Rf_type2char(TYPEOF(v))) ;
Expand Down
21 changes: 14 additions & 7 deletions inst/include/dplyr/Result/DelayedProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ namespace dplyr {
case INTSXP:
case LGLSXP:
return true ;
default: break ;
default:
break ;
}
return false ;
}
Expand All @@ -38,7 +39,8 @@ namespace dplyr {
case INTSXP:
case LGLSXP:
return true ;
default: break ;
default:
break ;
}
return false ;
}
Expand Down Expand Up @@ -95,11 +97,16 @@ namespace dplyr {
virtual DelayedProcessor_Base<CLASS>* promote(int i, const RObject& chunk) {
int rtype = TYPEOF(chunk) ;
switch( rtype ) {
case LGLSXP: return new DelayedProcessor<LGLSXP , CLASS>(i, chunk, res ) ;
case INTSXP: return new DelayedProcessor<INTSXP , CLASS>(i, chunk, res ) ;
case REALSXP: return new DelayedProcessor<REALSXP, CLASS>(i, chunk, res ) ;
case CPLXSXP: return new DelayedProcessor<CPLXSXP, CLASS>(i, chunk, res ) ;
default: break ;
case LGLSXP:
return new DelayedProcessor<LGLSXP , CLASS>(i, chunk, res ) ;
case INTSXP:
return new DelayedProcessor<INTSXP , CLASS>(i, chunk, res ) ;
case REALSXP:
return new DelayedProcessor<REALSXP, CLASS>(i, chunk, res ) ;
case CPLXSXP:
return new DelayedProcessor<CPLXSXP, CLASS>(i, chunk, res ) ;
default:
break ;
}
return 0 ;
}
Expand Down
Loading

0 comments on commit fd859c0

Please sign in to comment.