Skip to content

Commit

Permalink
shave off some hash lookup overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 2, 2025
1 parent e6cfbc3 commit cfe1d51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion R/class_database.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ database_class <- R6::R6Class(
lookup_get(.subset2(self, "lookup"), name)
},
set_row = function(row) {
lookup <- .subset2(self, "lookup")
name <- as.character(.subset2(row, "name"))
object <- as.list(row)
lookup[[name]] <- object
Expand Down
13 changes: 8 additions & 5 deletions R/class_meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ meta_init <- function(path_store = path_store_default()) {
}

meta_new <- function(database = NULL, depends = NULL, store = NULL) {
meta_class$new(database, depends, store = store)
meta_class$new(database, depends, store = store, lookup = database$lookup)
}

meta_class <- R6::R6Class(
Expand All @@ -21,15 +21,18 @@ meta_class <- R6::R6Class(
database = NULL,
depends = NULL,
store = NULL,
lookup = NULL,
repository_cas_lookup_table = NULL,
initialize = function(
database = NULL,
depends = NULL,
store = NULL
store = NULL,
lookup = NULL
) {
self$database <- database
self$depends <- depends
self$store <- store
self$lookup <- lookup
},
get_depend = function(name) {
.subset2(.subset2(self, "depends"), name)
Expand Down Expand Up @@ -71,12 +74,12 @@ meta_class <- R6::R6Class(
remove <- setdiff(names_records, names_current)
self$del_records(remove)
},
hash_dep = function(name, pipeline) {
.subset2(.subset2(.subset2(self, "database"), "get_row")(name), "data")
hash_dep = function(name) {
.subset2(.subset2(lookup, name), "data")
},
hash_deps = function(deps, pipeline) {
deps <- sort_chr(deps)
hashes <- lapply(X = deps, FUN = self$hash_dep, pipeline = pipeline)
hashes <- lapply(X = deps, FUN = hash_dep)
names(hashes) <- deps
hashes <- unlist(hashes, use.names = TRUE)
string <- paste(c(names(hashes), hashes), collapse = "")
Expand Down

0 comments on commit cfe1d51

Please sign in to comment.