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

Postgresql #1

Merged
merged 12 commits into from Feb 13, 2019
Merged

Postgresql #1

merged 12 commits into from Feb 13, 2019

Conversation

mattyb
Copy link
Member

@mattyb mattyb commented Feb 13, 2019

No description provided.

@mattyb mattyb requested a review from patr1ckm February 13, 2019 01:37
@mattyb mattyb closed this Feb 13, 2019
@mattyb mattyb deleted the postgresql branch February 13, 2019 01:51
@mattyb mattyb restored the postgresql branch February 13, 2019 01:52
@mattyb mattyb reopened this Feb 13, 2019
Copy link

@patr1ckm patr1ckm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of notes on dependencies and a simplification.

High level

  • Are you planning to merge this intor-lib/memoise?
  • Is it worth setting up a postgres instance in travis for testing?

Also Keith and I were just talking about this yesterday!

DESCRIPTION Outdated
@@ -13,12 +13,15 @@ Description: Cache the results of a function so that when you call it
URL: https://github.com/r-lib/memoise
BugReports: https://github.com/r-lib/memoise/issues
Imports:
digest (>= 0.6.3)
digest (>= 0.6.3),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no comma probably

if (!(requireNamespace("readr"))) { stop("Package `readr` must be installed for `cache_postgresql()`.") } # nocov

cache_reset <- function() {
dbSendQuery(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are failing from R packaging, e.g. DBI::dbSendQuery needs to be added to all the imported functions used

temp_file <- file.path(path, key)
on.exit(unlink(temp_file))
saveRDS(value, file = temp_file, compress = compress, ascii = TRUE)
encoded <- readr::read_file(temp_file)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the readr dependency necessary? Would readBin from base do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

key = key
)
)
readr::write_file(rs[1][[1]], temp_file)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to read the file directly from rs instead of writing to/from temporary files?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My answer is no, I don't think you can serialize without using textConnections, which have memory limits.

)
is_here <- nrow(rs) == 1
# if not result is logical(0)
if(identical(is_here, logical(0))){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!is.null(rs) && nrow(rs) == 1) TRUE else FALSE will do it one line

@codecov-io
Copy link

codecov-io commented Feb 13, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@1650ad7). Click here to learn what that means.
The diff coverage is 89.13%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #1   +/-   ##
=========================================
  Coverage          ?   68.37%           
=========================================
  Files             ?        6           
  Lines             ?      313           
  Branches          ?        0           
=========================================
  Hits              ?      214           
  Misses            ?       99           
  Partials          ?        0
Impacted Files Coverage Δ
R/cache_postgresql.R 89.13% <89.13%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1650ad7...576afa4. Read the comment docs.

@mattyb
Copy link
Member Author

mattyb commented Feb 13, 2019

Back to you!

@patr1ckm
Copy link

This is as good as I can review! LGTM

@patr1ckm patr1ckm assigned mattyb and unassigned patr1ckm Feb 13, 2019
@mattyb mattyb merged commit 7edf915 into master Feb 13, 2019
@mattyb mattyb deleted the postgresql branch February 13, 2019 22:14
@patr1ckm
Copy link

Thanks for looping me in too, I learned a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants