Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r] Make DataFrame objects shapeable at ingest #3089

Merged
merged 1 commit into from
Oct 1, 2024
Merged
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
22 changes: 22 additions & 0 deletions apis/r/R/write_soma.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,31 @@ write_soma.data.frame <- function(
choices = names(x),
several.ok = TRUE
)

# For index_column_name being soma_joinid -- this being the default
# -- set that domain slot to match the data. This will endow the
# dataframe with something users think of as a "shape". For the
# other slots, set the domain wide open.
#
domain <- NULL
if (.new_shape_feature_flag_is_enabled()) {
domain <- list()
for (index_column_name in index_column_names) {
if (index_column_name == "soma_joinid") {
domain[["soma_joinid"]] <- c(0, nrow(x) - 1)
} else {
domain[[index_column_name]] <- NULL
}
}
}

# Create the SOMADataFrame
tbl <- arrow::arrow_table(x)
sdf <- SOMADataFrameCreate(
uri = uri,
schema = tbl$schema,
index_column_names = index_column_names,
domain = domain,
ingest_mode = ingest_mode,
platform_config = platform_config,
tiledbsoma_ctx = tiledbsoma_ctx
Expand All @@ -239,6 +258,9 @@ write_soma.data.frame <- function(
NULL
}
}
if (ingest_mode %in% c('resume') && sdf$tiledbsoma_has_upgraded_domain()) {
sdf$resize_soma_joinid(nrow(x))
}
if (!is.null(tbl)) {
sdf$write(tbl)
}
Expand Down
5 changes: 5 additions & 0 deletions apis/r/tests/testthat/test-write-soma-resume.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ test_that("Resume-mode data frames", {
}
}

if (.new_shape_feature_flag_is_enabled()) {
sdfp$reopen("WRITE")
sdfp$resize_soma_joinid(nrow(co2))
}

expect_s3_class(
sdfc <- write_soma(
co2,
Expand Down
Loading