Skip to content

Commit

Permalink
R Client 2.0 - Table Ops (deephaven#4240)
Browse files Browse the repository at this point in the history
* Delete outdated testing files

* Continue api expansion

* More api stuff

* Continue API expansion

* Document new methods, start unit testing file. Roxygen not called yet

* Rearrange methods, change gitignore, generate roxygen

* Continue API expansion, do not expose all package functions to user

* Get rid of experimenting that should not have been committed

* Clean up R wrapping, implement agg_by, configure NAMESPACE to only expose relevant functions via roxygen tags

* Refactor type conversion logic, R-level type checking, actually add NAMESPACE this time

* Fix helper functions, add Aggregation to NAMESPACE

* Fix error handling, move unit tests to install automatically

* Update README to simplify install command in light of automatic test installation

* Add Sorter class to make tableHandle.sort() work, change functions to not conflict with S3, more error handling, more unit tests

* More unit tests

* Overhaul table ops API for Dplyr feel

* More unit tests

* Simplify sorting API, more unit tests

* Reorder table operations logically, connect ClientWrapper to newly exposed methods in C++

* Fix new table methods, add tests, add conversion functions to be used in queries

* Update generics

* Reorder agg_by ops, start agg_by testing

* enable empty _by and agg ops

* agg_by testing

* Finish agg_by testing

* Add table ops documentation, not hooked into R yet

* Fix unit tests after renames

* More unit tests

* Even more unit tests

* Naming consistency in table operations

* Group_by and ungroup tests

* empty_table and time_table tests

* Join unit tests

* Add close method

* Apply Tidyverse style guide

* Fix rbind implementation

* Update DESCRIPTION w/ version

* Fix problems from merge conflict

* Refactor helper functions

* Correction to helper function refactor

* Add new clientOptionsWrapper in S4. Does not support piping

* More rewrite

* Working unit tests, refactor complete

* Apply code review comments

* Implement merge

* Code review change

* Cpp formatting

* Test base pipe

* Code review suggestions

* Refactor import_table to as_dh_table with generics

* Applying more code review

* Applying even more code review

* Update cpp to conform to new styleguide, need to uncomment pct when cpp fixed

* Uncomment pct, all tests pass

* Refactor auth API to conform to Python

* Support multiple int/string options and extra headers

* Code review to helper functions

* Rename connect to dhConnect

* Update NAMESPACE, add warnings, apply styleguide

* Enable size 0 empty_table

* Assert options inputs

* Starting client_wrapper docs

* Support ncol() and dim()

* Get rid of mistakenly committed docs, add list type verification in merge

* Code review suggestions

* Verified that exact_join is an analog of left_join

* Expand sort API, constrain merge args, add username and password to dhConnect

* Apply code review

* Kill merge, make merge_tables

* Update version

* Change to abs_sort

* Support merge_tables(NULL)

* Change push_to_table to import_table
  • Loading branch information
alexpeters1208 committed Aug 15, 2023
1 parent 7ae3a23 commit c09b038
Show file tree
Hide file tree
Showing 24 changed files with 3,951 additions and 1,448 deletions.
4 changes: 3 additions & 1 deletion R/rdeephaven/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ lib/cpp-client/
lib/cpp-examples/
lib/cpp-dependencies/local
lib/cpp-dependencies/src
lib/cpp-dependencies/env.sh
lib/cpp-dependencies/env.sh
*.o
*.so
4 changes: 2 additions & 2 deletions R/rdeephaven/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rdeephaven
Type: Package
Title: R Client for Deephaven Core
Version: 1.0
Version: 0.27.1
Date: 2023-05-12
Author: Deephaven Data Labs
Maintainer: Alex Peters <alexpeters@deephaven.io>
Expand All @@ -13,7 +13,7 @@ Description: The `rdeephaven` package provides an R API for communicating with t
and bind it to a server-side variable so you can access it from any Deephaven client. Finally, you can run Python or Groovy
scripts on the Deephaven server, so long as your server is equipped with that capability.
License: Apache License (== 2.0)
Depends: R (> 4.1.2), Rcpp (>= 1.0.10), arrow (>= 12.0.0), R6 (>= 2.5.0), dplyr (>= 1.1.0)
Depends: R (> 4.1.2), Rcpp (>= 1.0.10), arrow (>= 12.0.0), dplyr (>= 1.1.0)
Imports: Rcpp (>= 1.0.10), arrow (>= 12.0.0), R6 (>= 2.5.0), dplyr (>= 1.1.0)
LinkingTo: Rcpp
Suggests: testthat (>= 3.0.0)
Expand Down
82 changes: 79 additions & 3 deletions R/rdeephaven/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,79 @@
useDynLib(rdeephaven, .registration=TRUE)
importFrom(Rcpp, evalCpp)
exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand

export(agg_abs_sum)
export(agg_avg)
export(agg_count)
export(agg_first)
export(agg_last)
export(agg_max)
export(agg_median)
export(agg_min)
export(agg_percentile)
export(agg_std)
export(agg_sum)
export(agg_var)
export(agg_w_avg)
export(merge_tables)
export(sort)
exportClasses(Aggregation)
exportClasses(Client)
exportClasses(TableHandle)
exportMethods(abs_sum_by)
exportMethods(agg_by)
exportMethods(as.data.frame)
exportMethods(as_arrow_table)
exportMethods(as_data_frame)
exportMethods(as_record_batch_reader)
exportMethods(as_tibble)
exportMethods(avg_by)
exportMethods(bind_to_variable)
exportMethods(close)
exportMethods(count_by)
exportMethods(cross_join)
exportMethods(dhConnect)
exportMethods(dim)
exportMethods(drop_columns)
exportMethods(empty_table)
exportMethods(exact_join)
exportMethods(first_by)
exportMethods(group_by)
exportMethods(head)
exportMethods(head_by)
exportMethods(is_static)
exportMethods(last_by)
exportMethods(max_by)
exportMethods(median_by)
exportMethods(min_by)
exportMethods(natural_join)
exportMethods(ncol)
exportMethods(nrow)
exportMethods(open_table)
exportMethods(percentile_by)
exportMethods(import_table)
exportMethods(run_script)
exportMethods(select)
exportMethods(sort)
exportMethods(std_by)
exportMethods(sum_by)
exportMethods(tail)
exportMethods(tail_by)
exportMethods(time_table)
exportMethods(ungroup)
exportMethods(update)
exportMethods(update_view)
exportMethods(var_by)
exportMethods(view)
exportMethods(w_avg_by)
exportMethods(where)
import(Rcpp)
importFrom(Rcpp,evalCpp)
importFrom(arrow,RecordBatchReader)
importFrom(arrow,RecordBatchStreamReader)
importFrom(arrow,Table)
importFrom(arrow,arrow_table)
importFrom(arrow,as_arrow_table)
importFrom(arrow,as_record_batch_reader)
importFrom(dplyr,as_data_frame)
importFrom(dplyr,as_tibble)
importFrom(magrittr,"%>%")
useDynLib(rdeephaven, .registration = TRUE)
89 changes: 89 additions & 0 deletions R/rdeephaven/R/aggregate_wrapper.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#' @export
setClass(
"Aggregation",
representation(
.internal_rcpp_object = "Rcpp_INTERNAL_Aggregate"
)
)

### All of the functions below return an instance of the above class

#' @export
agg_first <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_first(cols)))
}

#' @export
agg_last <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_last(cols)))
}

#' @export
agg_min <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_min(cols)))
}

#' @export
agg_max <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_max(cols)))
}

#' @export
agg_sum <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_sum(cols)))
}

#' @export
agg_abs_sum <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_abs_sum(cols)))
}

#' @export
agg_avg <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_avg(cols)))
}

#' @export
agg_w_avg <- function(wcol, cols = character()) {
verify_string("wcol", wcol, TRUE)
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_w_avg(wcol, cols)))
}

#' @export
agg_median <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_median(cols)))
}

#' @export
agg_var <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_var(cols)))
}

#' @export
agg_std <- function(cols = character()) {
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_std(cols)))
}

#' @export
agg_percentile <- function(percentile, cols = character()) {
verify_in_unit_interval("percentile", percentile, TRUE)
verify_string("cols", cols, FALSE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_percentile(percentile, cols)))
}

#' @export
agg_count <- function(col) {
verify_string("col", col, TRUE)
return(new("Aggregation", .internal_rcpp_object = INTERNAL_agg_count(col)))
}
117 changes: 0 additions & 117 deletions R/rdeephaven/R/client_options_wrapper.R

This file was deleted.

Loading

0 comments on commit c09b038

Please sign in to comment.