Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions inst/tinytest/test_aggregates.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ if (!requireNamespace("palmerpenguins", quietly=TRUE)) exit_file("Remainder need

tiledb_ctx(limitTileDBCores())

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

library(palmerpenguins)
uri <- tempfile()
expect_silent(fromDataFrame(penguins, uri, sparse=TRUE))
Expand Down
42 changes: 24 additions & 18 deletions inst/tinytest/test_arrayschema.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
library(tinytest)
library(tiledb)

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)

ctx <- tiledb_ctx(limitTileDBCores())


isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

if (get_return_as_preference() != "asis") set_return_as_preference("asis") # baseline value

#test_that("tiledb_array_schema default constructor works", {
Expand Down Expand Up @@ -97,29 +104,28 @@ expect_error(tiledb:::libtiledb_array_schema_set_capacity(sch@ptr, -10))


#test_that("tiledb_array_schema created with encryption", {
if (!(isOldWindows)) {
dir.create(uri <- tempfile())
key <- "0123456789abcdeF0123456789abcdeF"
if (!isRESTCI) {
uri <- tempfile()
key <- "0123456789abcdeF0123456789abcdeF"

dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 4L), 4L, "INT32"),
tiledb_dim("cols", c(1L, 4L), 4L, "INT32")))
schema <- tiledb_array_schema(dom, attrs = c(tiledb_attr("a", type = "INT32")))
dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 4L), 4L, "INT32"),
tiledb_dim("cols", c(1L, 4L), 4L, "INT32")))
schema <- tiledb_array_schema(dom, attrs = c(tiledb_attr("a", type = "INT32")))

##tiledb_array_create_with_key(uri, schema, key)
## for now calling into function
tiledb:::libtiledb_array_create_with_key(uri, schema@ptr, key)
##tiledb_array_create_with_key(uri, schema, key)
## for now calling into function
tiledb:::libtiledb_array_create_with_key(uri, schema@ptr, key)

# ctx <- tiledb_ctx()
# arrptr <- tiledb:::libtiledb_array_open_with_key(ctx@ptr, uri, "WRITE", key)
# A <- new("tiledb_dense", ctx=ctx, uri=uri, as.data.frame=FALSE, ptr=arrptr)
## ctx <- tiledb_ctx()
## arrptr <- tiledb:::libtiledb_array_open_with_key(ctx@ptr, uri, "WRITE", key)
## A <- new("tiledb_dense", ctx=ctx, uri=uri, as.data.frame=FALSE, ptr=arrptr)

# expect_true(is(A, "tiledb_dense"))
##expect_true(is(schema(A), "tiledb_dense"))
## can't yet read / write as scheme getter not generalized for encryption
## expect_true(is(A, "tiledb_dense"))
##expect_true(is(schema(A), "tiledb_dense"))
## can't yet read / write as scheme getter not generalized for encryption

unlink(uri, recursive=TRUE)
unlink(uri, recursive=TRUE)
}
#})

#test_that("tiledb_array_schema dups setter/getter", {
dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 4L), 4L, "INT32"),
Expand Down
8 changes: 7 additions & 1 deletion inst/tinytest/test_arrayschemaevolution.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
library(tinytest)
library(tiledb)

#isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
if (Sys.info()[["sysname"]] == "Windows") exit_file("Skip on Windows")

ctx <- tiledb_ctx(limitTileDBCores())

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

if (tiledb_version(TRUE) < "2.11.0") exit_file("Needs TileDB 2.11.* or later")

df <- data.frame(key=letters[1:10],
Expand Down
15 changes: 9 additions & 6 deletions inst/tinytest/test_arrowio.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
library(tinytest)
library(tiledb)

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
if (isOldWindows) exit_file("skip this file on old Windows releases")

if (Sys.getenv("CI", "") == "") exit_file("Skip unextended test run")

ctx <- tiledb_ctx(limitTileDBCores())

if (!requireNamespace("arrow", quietly=TRUE)) exit_file("No 'arrow' package.")
suppressMessages(library(arrow))

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}


if (get_return_as_preference() != "asis") set_return_as_preference("asis") # baseline value

Expand Down Expand Up @@ -40,7 +43,7 @@ tiledb_arrow_array_del(aa)
## round-turn test 1: write tiledb first, create arrow object via zero-copy
suppressMessages(library(bit64))
n <- 10L
dir.create(tmp <- tempfile())
tmp <- tempfile()
dim <- tiledb_dim("rows", domain=c(1L,n), type="INT32", tile=1L)
dom <- tiledb_domain(dim)
sch <- tiledb_array_schema(dom,
Expand Down Expand Up @@ -111,7 +114,7 @@ for (col in c("int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "u

## n=15
## round-turn test 2: create arrow object, write tiledb second via zero-copy
dir.create(tmp <- tempfile())
tmp <- tempfile()
n <- 10L

## create a schema but don't fill it yet
Expand Down
11 changes: 8 additions & 3 deletions inst/tinytest/test_attr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ library(tiledb)

ctx <- tiledb_ctx(limitTileDBCores())

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
isWindows <- Sys.info()[["sysname"]] == "Windows"

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

#test_that("tiledb_attr constructor works", {
a1 <- tiledb_attr(type = "FLOAT64")
expect_true(is(a1, "tiledb_attr"))
Expand Down Expand Up @@ -54,7 +60,6 @@ expect_true(is.na(tiledb::cell_val_num(attrs)))
#})

#test_that("tiledb_attr set fill", {
if (isOldWindows) exit_file("skip remainder of this file on old Windows releases")

## test for default
dom <- tiledb_domain(dims = tiledb_dim("rows", c(1L, 4L), 4L, "INT32"))
Expand Down Expand Up @@ -238,7 +243,7 @@ expect_equal(D, res)


## lower-level testing tiledb_query_set_buffer
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
v <- D[, "val"]
v[3] <- TRUE # without nullable for simplicity
dim <- tiledb_dim(name = "dim", domain = c(0L, 3L), type = "INT32")
Expand Down
3 changes: 0 additions & 3 deletions inst/tinytest/test_ctx.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
library(tinytest)
library(tiledb)

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
if (isOldWindows) exit_file("skip this file on old Windows releases")

tiledb_ctx(limitTileDBCores())

#test_that("tiledb_ctx default constructor", {
Expand Down
36 changes: 19 additions & 17 deletions inst/tinytest/test_dataframe.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
library(tinytest)
library(tiledb)

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
if (isOldWindows) exit_file("skip this file on old Windows releases")

ctx <- tiledb_ctx(limitTileDBCores())

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

#test_that("tiledb_fromdataframe", {
uri <- tempfile()
## turn factor into character
Expand Down Expand Up @@ -84,7 +88,7 @@ expect_equal(df, chk[,-1]) # omit first col which is added

if (tiledb_version(TRUE) < "2.1.0") exit_file("Remaining tests require TileDB 2.1.0 or later")

if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, col_index=1)
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
Expand All @@ -93,7 +97,7 @@ expect_equal(df[,2], na.omit(chk)[,2]) # compare column by column
expect_equal(df[,3], na.omit(chk)[,3])


if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, col_index="index")
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
Expand All @@ -106,7 +110,7 @@ olddf <- df
df <- data.frame(chars=olddf$chars,
index=olddf$index, # index not in first column
val=olddf$vals)
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri)
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
Expand All @@ -116,15 +120,15 @@ if (getRversion() < '4.0.0') {
}
expect_equal(df, chk[,-1]) # omit first col which is added

if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, col_index=2)
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
if (getRversion() < '4.0.0') chk$chars <- as.character(chk$chars)
expect_equal(df[,1], na.omit(chk)[,2]) # compare column by column
expect_equal(df[,3], na.omit(chk)[,3])

if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, col_index="index")
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
Expand Down Expand Up @@ -154,14 +158,14 @@ df <- data.frame(time=round(Sys.time(), "secs") + trunc(cumsum(runif(nobs)*3600)
nanotime=as.nanotime(Sys.time() + cumsum(runif(nobs)*3600)),
stringsAsFactors=FALSE)

if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, sparse=TRUE)

chk <- tiledb_array(uri, return_as="data.frame", extended=FALSE)
expect_equivalent(df, chk[]) # skip attribute

for (i in seq_len(dim(df)[2])) {
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, sparse=TRUE, col_index=i)
chk <- tiledb_array(uri, return_as="data.frame")
expect_equal(df, chk[][,colnames(df)]) # index col comes first so need re-order
Expand All @@ -181,17 +185,16 @@ df <- data.frame(time = round(Sys.time(), "secs") + trunc(cumsum(runif(nobs)*360
stringsAsFactors=FALSE)


if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, sparse=TRUE)

chk <- tiledb_array(uri, return_as="data.frame", extended=FALSE)
newdf <- chk[]
if (getRversion() < '4.0.0') newdf$txt <- as.character(newdf$txt)
expect_equivalent(df, newdf) # skip attribute


for (i in seq_len(dim(df)[2])) {
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, sparse=TRUE, col_index=i)
chk <- tiledb_array(uri, return_as="data.frame")
newdf <- chk[]
Expand All @@ -201,14 +204,14 @@ for (i in seq_len(dim(df)[2])) {

combinations <- list(c(1,2), c(1,3), c(2,4), c(3,5), c(4,5), c(2,3,4))
for (comb in combinations) {
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, sparse=TRUE, col_index=comb) # by index
chk <- tiledb_array(uri, return_as="data.frame")
newdf <- chk[]
if (getRversion() < '4.0.0') newdf$txt <- as.character(newdf$txt)
expect_equal(df, newdf[][, colnames(df)])

if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
fromDataFrame(df, uri, sparse=TRUE, col_index=colnames(df)[comb]) # by name
chk <- tiledb_array(uri, return_as="data.frame")
newdf <- chk[]
Expand Down Expand Up @@ -292,7 +295,6 @@ library(palmerpenguins)
data <- penguins

uri <- tempfile()

fromDataFrame(data, uri, col_index=1:2, mode="schema_only")
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
Expand All @@ -305,7 +307,7 @@ chk <- arr[]
expect_equal(nrow(chk), nrow(data)) # all data
expect_equal(ncol(chk), ncol(data)) # all columns

tiledb_vfs_remove_dir(uri)
uri <- tempfile()
fromDataFrame(data, uri, col_index=1:2) # default mode
arr <- tiledb_array(uri, return_as="data.frame")
chk <- arr[]
Expand Down
10 changes: 7 additions & 3 deletions inst/tinytest/test_datetime.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
library(tinytest)
library(tiledb)

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
if (isOldWindows) exit_file("skip this file on old Windows releases")

isMacOS <- (Sys.info()['sysname'] == "Darwin")

ctx <- tiledb_ctx(limitTileDBCores())

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

#test_that("Can read / write a simple Date dense vector", {
uri <- tempfile()

Expand Down
15 changes: 9 additions & 6 deletions inst/tinytest/test_dim.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
library(tinytest)
library(tiledb)

isOldWindows <- Sys.info()[["sysname"]] == "Windows" && grepl('Windows Server 2008', osVersion)
if (isOldWindows) exit_file("skip this file on old Windows releases")

ctx <- tiledb_ctx(limitTileDBCores())

isRESTCI <- Sys.getenv("TILEDB_CLOUD_REST_BIN", "") != ""
if (isRESTCI) {
## we can rely on the normal tempfile semantics but override the tmpdir
## argument to be our REST CI base url in the unit test namespace
tempfile <- function() { base::tempfile(tmpdir="tiledb://unit") }
}

#test_that("tiledb_dim default constructor", {
dim <- tiledb_dim("foo", c(1, 100))
expect_true(is(dim, "tiledb_dim"))
Expand Down Expand Up @@ -92,7 +96,6 @@ suppressMessages({
})
atttype <- "INT32"
intmax <- .Machine$integer.max # shorthand
uri <- tempfile()
dimtypes <- c("ASCII", # Variable length string
"INT8", # 8-bit integer
"UINT8", # 8-bit unsigned integer
Expand All @@ -119,7 +122,7 @@ dimtypes <- c("ASCII", # Variable length string
"DATETIME_AS" # attosecond
)
for (dtype in dimtypes) {
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
dom <- switch(dtype,
"ASCII" = NULL,
"INT8" =,
Expand Down Expand Up @@ -287,7 +290,7 @@ dimtypes <- c("ASCII", # Variable length string
"DATETIME_AS" # attosecond
)
for (dtype in dimtypes) {
if (dir.exists(uri)) unlink(uri, recursive=TRUE)
uri <- tempfile()
dom <- switch(dtype,
"ASCII" = NULL,
"INT8" =,
Expand Down
Loading