Skip to content

Commit

Permalink
update R package
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Feb 4, 2024
1 parent 78ead6c commit 55230f4
Show file tree
Hide file tree
Showing 15 changed files with 919 additions and 106 deletions.
3 changes: 3 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(parse_esri_json_raw)
export(parse_esri_json_raw_geoarrow)
export(parse_esri_json_raw_simd)
export(parse_esri_json_str)
export(parse_esri_json_str_simd)
useDynLib(serdesri, .registration = TRUE)
22 changes: 17 additions & 5 deletions r/R/dev.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# library(serdesri)
#
# url <- "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/ACS_Population_by_Race_and_Hispanic_Origin_Boundaries/FeatureServer/2/query?where=1=1&outFields=objectid&resultRecordCount=10&f=json"
# no_geo_url <- "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/ACS_Population_by_Race_and_Hispanic_Origin_Boundaries/FeatureServer/2/query?where=1=1&outFields=*&resultRecordCount=2000&f=json&returnGeometry=true"
#
# req <- httr2::request(url)
# req <- httr2::request(no_geo_url)
# resp <- httr2::req_perform(req)
# json <- httr2::resp_body_string(resp)
#
# stream <- parse_esri_json_str(json, 2)
# stream
#
# df <- as.data.frame(stream)
# head(df$geometry)
#
#
# bm <- bench::mark(
# current = arcgisutils::parse_esri_json(json),
# # arrow = arrow::as_record_batch_reader(parse_esri_json_str(json, 2))$read_table() ,
# serde_json = as.data.frame(parse_esri_json_str(json, 2)),
# # simd_json = as.data.frame(parse_esri_json_str_simd(json, 2)),
# iterations = 10,
# check = FALSE,
# # relative = TRUE
# ) |>
# dplyr::select(1:7) |>
# print()
#
#
# str(df, 1)
9 changes: 9 additions & 0 deletions r/R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ NULL
#' @export
parse_esri_json_str <- function(str, n_dim) .Call(wrap__parse_esri_json_str, str, n_dim)

#' @export
parse_esri_json_str_simd <- function(str, n_dim) .Call(wrap__parse_esri_json_str_simd, str, n_dim)

#' @export
parse_esri_json_raw_simd <- function(raw, n_dim) .Call(wrap__parse_esri_json_raw_simd, raw, n_dim)

#' @export
parse_esri_json_raw <- function(raw, n_dim) .Call(wrap__parse_esri_json_raw, raw, n_dim)

#' @export
parse_esri_json_raw_geoarrow <- function(raw, n_dim) .Call(wrap__parse_esri_json_raw_geoarrow, raw, n_dim)


# nolint end
5 changes: 3 additions & 2 deletions r/src/Makevars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TARGET_DIR = ./rust/target
LIBDIR = $(TARGET_DIR)/release
STATLIB = $(LIBDIR)/libserdesri.a
PKG_LIBS = -L$(LIBDIR) -lserdesri
STATLIB = $(LIBDIR)/libserdesri_r.a
PKG_LIBS = -L$(LIBDIR) -lserdesri_r

all: C_clean

Expand All @@ -13,6 +13,7 @@ $(STATLIB):
# In some environments, ~/.cargo/bin might not be included in PATH, so we need
# to set it here to ensure cargo can be invoked. It is appended to PATH and
# therefore is only used if cargo is absent from the user's PATH.
export RUSTFLAGS="-C target-cpu=native" && \
if [ "$(NOT_CRAN)" != "true" ]; then \
export CARGO_HOME=$(CARGOTMP); \
fi && \
Expand Down
Loading

0 comments on commit 55230f4

Please sign in to comment.