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] Fix 32-bit build #3307

Merged
merged 3 commits into from
Aug 15, 2020
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
2 changes: 1 addition & 1 deletion R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Booster <- R6::R6Class(

# Create parameters and handle
params <- append(params, list(...))
handle <- 0.0
handle <- lgb.null.handle()

# Attempts to create a handle for the dataset
try({
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Dataset <- R6::R6Class(
if (!is.null(private$reference)) {
ref_handle <- private$reference$.__enclos_env__$private$get_handle()
}
handle <- NA_real_
handle <- lgb.null.handle()

# Not subsetting
if (is.null(private$used_indices)) {
Expand Down
8 changes: 8 additions & 0 deletions R-package/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ lgb.is.Dataset <- function(x) {
lgb.check.r6.class(x, "lgb.Dataset") # Checking if it is of class lgb.Dataset or not
}

lgb.null.handle <- function() {
if (.Machine$sizeof.pointer == 8L) {
return(NA_real_)
} else {
return(NA_integer_)
}
}

lgb.is.null.handle <- function(x) {
is.null(x) || is.na(x)
}
Expand Down
2 changes: 1 addition & 1 deletion R-package/tests/testthat/test_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test_that("lgb.Dataset: nrow is correct for a very sparse matrix", {

test_that("lgb.Dataset: Dataset should be able to construct from matrix and return non-null handle", {
rawData <- matrix(runif(1000L), ncol = 10L)
handle <- NA_real_
handle <- lgb.null.handle()
ref_handle <- NULL
handle <- lightgbm:::lgb.call(
"LGBM_DatasetCreateFromMat_R"
Expand Down