The Deephaven Client
Client.Rd
A Client is the entry point for interacting with the Deephaven server. It is used to create new tables, import data to and export data from the server, and run queries on the server.
Methods
Method new()
Calls initialize_for_xptr()
if the first argument is an external pointer, and initialize_for_target()
if the
first argument is a string. In the latter case, the remaining keyword arguments are passed to initialize_for_target()
.
Usage
Client$new(...)
Method initialize_for_xptr()
Initializes a Client object using a pointer to an existing client connection.
Method initialize_for_target()
Initializes a Client object and connects to a Deephaven server.
Arguments
target
String denoting the address of a Deephaven server, formatted as
"ip:port"
.auth_type
String denoting the authentication type. Can be
"anonymous"
,"basic"
,"psk"
, or any custom-built authenticator supported by the server. Default is"anonymous"
.username
String denoting the username, which only applies if
auth_type
is"basic"
. Username and password should not be used in conjunction withauth_token
. Defaults to an empty string.password
String denoting the password, which only applies if
auth_type
is"basic"
. Username and password should not be used in conjunction withauth_token
. Defaults to an empty string.auth_token
String denoting the authentication token. When
auth_type
is"anonymous"
, it will be ignored; whenauth_type
is"basic"
, it must be"user:password"
or left blank; whenauth_type
"psk"
, it must be the pre-shared key, whenauth_type
is a custom-built authenticator, it must conform to the specific requirement of that authenticator. This should not be used in conjunction withusername
andpassword
. Defaults to an empty string.session_type
String denoting the session type supported on the server. Currently,
"python"
and"groovy"
are supported. Defaults to"python"
.use_tls
Whether or not to use a TLS connection. Defaults to
FALSE
.tls_root_certs
String denoting PEM encoded root certificates to use for TLS connection, or
""
to use system defaults. Only used ifuse_tls == TRUE
. Defaults to system defaults.int_options
List of name-value pairs for int-valued options to the underlying grpc channel creation. Defaults to an empty list, which implies not using any channel options.
string_options
List of name-value pairs for string-valued options to the underlying grpc channel creation. Defaults to an empty list, which implies not using any channel options.
extra_headers
List of name-value pairs for additional headers and values to add to server requests. Defaults to an empty list, which implies not using any extra headers.
Method time_table()
Creates a ticking table on the server.
Method import_table()
Imports a new table to the Deephaven server. Note that this new table is not automatically bound to
a variable name on the server. See ?TableHandle
for more information.
Method ticket_to_table()
Retrieves a reference to a named table in the server using its Arrow Flight ticket.
Method run_script()
Runs a script on the server. The script must be in the language that the server console was started with.
Method close()
Closes the client connection. After this method is called, any further server calls will be undefined and will likely result in an error.
Examples
if (FALSE) { # \dontrun{
library(rdeephaven)
# connecting to Deephaven server
client <- Client$new("localhost:10000", auth_type = "psk", auth_token = "my_secret_token")
# create a data frame and push it to the server, retrieve a reference to it as a TableHandle
df <- data.frame(
col1 = c(1, 2, 3),
col2 = c("a", "b", "c"),
col3 = c(TRUE, FALSE, TRUE)
)
th1 <- client$import_table(df)
as.data.frame(th1)
# give table referenced by 'th' a name on the server
th1$bind_to_variable("server_table")
# use client to execute script
client$run_script('server_table_new = server_table.update("col4 = col1 + 1")')
# retrieve reference to new table on the server
th2 <- client$open_table("server_table_new")
as.data.frame(th2)
# create table on server directly with table API and retrieve a reference to it as a TableHandle
th3 <- client$empty_table(10)$update("col1 = i")
as.data.frame(th3)
# create ticking table on the server and retrieve a reference to it as a TableHandle
th4 <- client$time_table("PT1S")$update("col1 = i")
Sys.sleep(5)
as.data.frame(th4)
Sys.sleep(5)
as.data.frame(th4)
Sys.sleep(5)
as.data.frame(th4)
# close client connection
client$close()
} # }