Skip to content

Commit f615f75

Browse files
committed
rename old functions to reference functions
1 parent 978b561 commit f615f75

2 files changed

Lines changed: 15 additions & 28 deletions

File tree

R/review_structures.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ SH <- local({ # _S_erialization _H_elpers
1515
return(res)
1616
}
1717

18-
..old_hash_id <- function(row) {
18+
..ref_hash_id <- function(row) {
1919
input <- paste(row, collapse = '\1D')
2020
input <- charToRaw(input)
2121
res <- xxhashlite::xxhash_raw(input, as_raw = TRUE)
2222
return(res)
2323
}
2424

25-
..old_hash_tracked_inner <- function(row) {
25+
..ref_hash_tracked_inner <- function(row) {
2626
# FIXME: Ensure that precision of numeric values does not affect serialization
2727
# Maybe by using a string hex representation of their binary contents
2828
input <- paste(row, collapse = '\1D')
@@ -33,13 +33,13 @@ SH <- local({ # _S_erialization _H_elpers
3333

3434
hash_tracked_offsets <- c(0, 2, 3)
3535

36-
..old_hash_tracked <- function(row) {
36+
..ref_hash_tracked <- function(row) {
3737
n_col <- length(row)
3838

3939
res <- raw(n_col)
4040
for(i_col in seq(n_col)){
4141
col_indices <- (((i_col-1) + hash_tracked_offsets) %% n_col) + 1
42-
res[[i_col]] <- ..old_hash_tracked_inner(row[col_indices])[[1]] # most significant byte
42+
res[[i_col]] <- ..ref_hash_tracked_inner(row[col_indices])[[1]] # most significant byte
4343
i_col <- i_col + 1
4444
}
4545

@@ -108,9 +108,9 @@ SH <- local({ # _S_erialization _H_elpers
108108
integer_vector_to_raw = integer_vector_to_raw,
109109
hash_id = hash_id,
110110
hash_tracked = hash_tracked,
111-
..old = list(
112-
hash_id = ..old_hash_id,
113-
hash_tracked = ..old_hash_tracked
111+
..ref = list(
112+
hash_id = ..ref_hash_id,
113+
hash_tracked = ..ref_hash_tracked
114114
),
115115
read_string_from_con = read_string_from_con,
116116
read_character_vector_from_con = read_character_vector_from_con,
@@ -281,9 +281,9 @@ RS_compute_delta_memory <- function(state, df){
281281

282282
tracked_vars <- state$tracked_vars
283283
# FIXME: (LUIS): Ask Miguel about the postlude
284-
tracked_hashes <- (SH$hash_tracke(df[tracked_vars]) |> c() |>
284+
tracked_hashes <- (SH$hash_tracked(df[tracked_vars]) |> c() |>
285285
array(dim = c(length(tracked_vars), nrow(df))))
286-
286+
287287
# Assert against removal of rows
288288
local({
289289
merged <- cbind(id_hashes, state$id_hashes, deparse.level = 0)

tests/testthat/test-for_apply_bug.R

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ test_that(
7777
"apply, fixed_lapply and hash_id are identical when rows of each column have the same width", {
7878

7979
df <- generate_random_df(100, equal_length = TRUE)
80-
apply_hash_res <- apply(df, 1, SH$`..old`$hash_id, simplify = TRUE)
81-
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..old`$hash_id)
80+
apply_hash_res <- apply(df, 1, SH$`..ref`$hash_id, simplify = TRUE)
81+
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..ref`$hash_id)
8282
vectorized_hash <- SH$hash_id(df)
8383
expect_identical(apply_hash_res, fixed_apply_hash_res)
8484
expect_identical(apply_hash_res, vectorized_hash)
@@ -87,7 +87,7 @@ test_that(
8787
test_that(
8888
"fixed_lapply and hash_id are identical when rows of each column have different width", {
8989
df <- generate_random_df(100, equal_length = FALSE)
90-
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..old`$hash_id)
90+
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..ref`$hash_id)
9191
vectorized_hash <- SH$hash_id(df)
9292
expect_identical(fixed_apply_hash_res, vectorized_hash)
9393
})
@@ -96,8 +96,8 @@ test_that(
9696
"apply, fixed_lapply and hash_tracked are identical when rows of each column have the same width", {
9797

9898
df <- generate_random_df(100, equal_length = TRUE)
99-
apply_hash_res <- apply(df, 1, SH$`..old`$hash_tracked, simplify = TRUE)
100-
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..old`$hash_tracked)
99+
apply_hash_res <- apply(df, 1, SH$`..ref`$hash_tracked, simplify = TRUE)
100+
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..ref`$hash_tracked)
101101
vectorized_hash <- SH$hash_tracked(df)
102102
expect_identical(apply_hash_res, fixed_apply_hash_res)
103103
expect_identical(apply_hash_res, vectorized_hash)
@@ -106,20 +106,7 @@ test_that(
106106
test_that(
107107
"fixed_lapply and hash_tracked are identical when rows of each column have different width", {
108108
df <- generate_random_df(100, equal_length = FALSE)
109-
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..old`$hash_tracked)
109+
fixed_apply_hash_res <- fixed_apply_hash(df, SH$`..ref`$hash_tracked)
110110
vectorized_hash <- SH$hash_tracked(df)
111111
expect_identical(fixed_apply_hash_res, vectorized_hash)
112112
})
113-
114-
# df <- generate_random_df(10000, equal_length = TRUE)
115-
# microbenchmark::microbenchmark(
116-
# apply = apply(df, 1, SH$`..old`$hash_id, simplify = TRUE),
117-
# fixed_apply = fixed_apply_hash(df, SH$`..old`$hash_id),
118-
# vectorized = SH$hash_id(df)
119-
# )
120-
121-
# microbenchmark::microbenchmark(
122-
# apply = apply(df, 1, SH$`..old`$hash_tracked, simplify = TRUE),
123-
# fixed_apply = fixed_apply_hash(df, SH$`..old`$hash_tracked),
124-
# vectorized = SH$hash_tracked(df)
125-
# )

0 commit comments

Comments
 (0)