Skip to content

Commit

Permalink
silence the entire output
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Feb 19, 2023
1 parent 068ae6e commit 0acb5bd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/readsas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ Rcpp::List readsas(const char * filePath,
for (auto pg = 0; pg < pagecount; ++pg) {
checkUserInterrupt();

Rcout << "--- new page ------------------------------------" << std::endl;
// Rcout << "--- new page ------------------------------------" << std::endl;

/* should already be at this position for pg == 1 */
if (pagecount > 0) {
Expand Down Expand Up @@ -503,10 +503,10 @@ Rcpp::List readsas(const char * filePath,

pageseqnum[pg] = pageseqnum32;

// if (debug) {
if (debug) {
Rcout << "pageseqnum: " << pageseqnum32 << std::endl;
// Rcout << unk1 << " " << unk2 << " " << PAGE_DELETED_POINTER_LENGTH << std::endl;
// }
Rcout << unk1 << " " << unk2 << " " << PAGE_DELETED_POINTER_LENGTH << std::endl;
}

PAGE_TYPE = readbin(PAGE_TYPE, sas, swapit);
BLOCK_COUNT = readbin(BLOCK_COUNT, sas, swapit);
Expand Down Expand Up @@ -724,7 +724,7 @@ Rcpp::List readsas(const char * filePath,
if (debug) Rcout << "pgsize " << pgsize << std::endl;
unk64 = readbin(unk64, sas, swapit);
rcmix = readbin(rcmix, sas, swapit);
// if (debug)
if (debug)
Rcout << "rcmix " << rcmix << std::endl;

/* next two indicate the end of the initial header ? */
Expand Down Expand Up @@ -942,7 +942,7 @@ Rcpp::List readsas(const char * filePath,
unk32 = readbin(unk32, sas, swapit);
if (debug) Rcout << unk32 << std::endl;
rcmix = readbin((int32_t)rcmix, sas, swapit);
// if (debug)
if (debug)
Rcout << "rcmix " << rcmix << std::endl;
uunk32 = readbin(uunk32, sas, swapit);
if (debug) Rcout << uunk32 << std::endl;
Expand Down
21 changes: 11 additions & 10 deletions src/writesas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,
writebin(unkdub, sas, 0);
writebin(unkdub, sas, 0);

Rcout << "pageseqnum32: " << pageseqnum32 << std::endl;

if (debug) Rcout << "pageseqnum32: " << pageseqnum32 << std::endl;
writebin(pageseqnum32, sas, 0);
writebin(unk32, sas, 0);

Expand Down Expand Up @@ -442,7 +443,7 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,
if (bit32 == 1) unk3 = 0;

/* unk3 something like max number of something per page? */
Rcout << "pageseqnum32: " << pageseqnum32 << std::endl;
if (debug) Rcout << "pageseqnum32: " << pageseqnum32 << std::endl;
// Page Offset Table
if (u64 == 4) {
writebin(pageseqnum32, sas, swapit);
Expand Down Expand Up @@ -498,8 +499,8 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,

if (debug) Rcout << " ---------- writing data ------------- " << std::endl;

// if (debug)
Rcout << sas.tellg() << std::endl;
if (debug)
Rcout << sas.tellg() << std::endl;

auto data_pos_page1 = sas.tellg();
// Rcout << pos_at_end_of_page1 << " < " << data_pos_page1 << " < " << rowlength << std::endl;
Expand Down Expand Up @@ -578,8 +579,8 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,
}
}
}
// if (debug)
Rcout << sas.tellg() << std::endl;
if (debug)
Rcout << sas.tellg() << std::endl;

rows_written = rows_on_page1;
rows_pending = n - rows_written;
Expand Down Expand Up @@ -1692,7 +1693,7 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,

++pagecount;

// if (debug)
if (debug)
Rcout << "@@@@ write additoinal page @@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;

sas.seekg(pos, sas.beg);
Expand All @@ -1717,7 +1718,7 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,
}

auto rows_on_page = BLOCK_COUNT + rows_written;
Rcout << rows_on_page << std::endl;
if (debug) Rcout << rows_on_page << std::endl;

// if (n <= (rows_on_page)) {
// rows_on_page = n;
Expand All @@ -1727,7 +1728,7 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,
unk32 = 0, unk1 = 0, unk2 = 0, unk3 = 0;

// Page Offset Table
Rcout << "pageseqnum32: " << pageseqnum32 << std::endl;
if (debug) Rcout << "pageseqnum32: " << pageseqnum32 << std::endl;
if (u64 == 4) {
writebin(pageseqnum32, sas, swapit);
writebin(unk32, sas, swapit);
Expand Down Expand Up @@ -1829,7 +1830,7 @@ void writesas(const char * filePath, Rcpp::DataFrame dat, uint8_t compress,

}
}
// if (debug)
if (debug)
Rcout << sas.tellg() << std::endl;

rows_written = rows_on_page;
Expand Down
22 changes: 11 additions & 11 deletions tests/testthat/test_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ test_that("basic write sas works", {
df <- read.sas(tmp)
expect_equal(df, mtcars, ignore_attr = TRUE)

# 32 bit
write.sas(mtcars, tmp, bit32 = TRUE)
df <- read.sas(tmp)
expect_equal(df, mtcars, ignore_attr = TRUE)
# # 32 bit
# write.sas(mtcars, tmp, bit32 = TRUE)
# df <- read.sas(tmp)
# expect_equal(df, mtcars, ignore_attr = TRUE)

})

Expand All @@ -21,14 +21,14 @@ test_that("basic write sas works", {
data$Species <- as.character(data$Species)
tmp <- tempfile(fileext = ".sas7bdat")

expect_warning(write.sas(data, tmp))
write.sas(data, tmp)
df <- read.sas(tmp)
expect_equal(df, data, ignore_attr = TRUE)

# 32 bit
expect_warning(write.sas(data, tmp))
df <- read.sas(tmp)
expect_equal(df, data, ignore_attr = TRUE)
# # 32 bit
# write.sas(data, tmp)
# df <- read.sas(tmp)
# expect_equal(df, data, ignore_attr = TRUE)

})

Expand All @@ -42,15 +42,15 @@ test_that("formats work", {
)

tmp <- tempfile(fileext = ".sas7bdat")
write.sas(dd, tmp, bit32 = F)
write.sas(dd, tmp, bit32 = FALSE)

attributes(df)$formats


df <- read.sas(tmp)
expect_equal(dd, df, ignore_attr = TRUE)

exp <- c("DATETIME", "DATE", "BEST", "$")
exp <- c("DATETIME", "DATE", "BEST", "")
got <- attributes(df)$formats
expect_equal(exp, got)

Expand Down

0 comments on commit 0acb5bd

Please sign in to comment.