Skip to content

Commit 5998863

Browse files
Merge branch 'master' into offsetPointer
2 parents e99dbbc + 6725de1 commit 5998863

29 files changed

+486
-456
lines changed

.ci/atime/tests.R

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ for (extra.arg in extra.args.6107){
1313
tmp_csv = tempfile()
1414
fwrite(DT, tmp_csv)
1515
},
16+
FasterIO = "60a01fa65191c44d7997de1843e9a1dfe5be9f72", # First commit of the PR (https://github.com/Rdatatable/data.table/pull/6925/commits) that reduced time usage
1617
Slow = "e9087ce9860bac77c51467b19e92cf4b72ca78c7", # Parent of the merge commit (https://github.com/Rdatatable/data.table/commit/a77e8c22e44e904835d7b34b047df2eff069d1f2) of the PR (https://github.com/Rdatatable/data.table/pull/6107) that fixes the issue
1718
Fast = "a77e8c22e44e904835d7b34b047df2eff069d1f2") # Merge commit of the PR (https://github.com/Rdatatable/data.table/pull/6107) that fixes the issue
1819
this.test$expr = str2lang(sprintf("data.table::fread(tmp_csv, %s)", extra.arg))
@@ -128,6 +129,18 @@ test.list <- atime::atime_test_list(
128129
paste0('useDynLib(', new.Package_))
129130
},
130131

132+
# Constant overhead improvement https://github.com/Rdatatable/data.table/pull/6925
133+
# Test case adapted from https://github.com/Rdatatable/data.table/pull/7022#discussion_r2107900643
134+
"fread disk overhead improved in #6925" = atime::atime_test(
135+
N = 2^seq(0, 20), # smaller N because we are doing multiple fread calls.
136+
setup = {
137+
fwrite(iris[1], iris.csv <- tempfile())
138+
},
139+
expr = replicate(N, data.table::fread(iris.csv)),
140+
Fast = "60a01fa65191c44d7997de1843e9a1dfe5be9f72", # First commit of the PR (https://github.com/Rdatatable/data.table/pull/6925/commits) that reduced time usage
141+
Slow = "e25ea80b793165094cea87d946d2bab5628f70a6" # Parent of the first commit (https://github.com/Rdatatable/data.table/commit/60a01fa65191c44d7997de1843e9a1dfe5be9f72)
142+
),
143+
131144
# Performance regression discussed in https://github.com/Rdatatable/data.table/issues/4311
132145
# Test case adapted from https://github.com/Rdatatable/data.table/pull/4440#issuecomment-632842980 which is the fix PR.
133146
"shallow regression fixed in #4440" = atime::atime_test(
@@ -177,8 +190,9 @@ test.list <- atime::atime_test_list(
177190
# Fixed in https://github.com/Rdatatable/data.table/pull/4558
178191
"DT[by] fixed in #4558" = atime::atime_test(
179192
setup = {
193+
N9 <- as.integer(N * 0.9)
180194
d <- data.table(
181-
id = sample(c(seq.int(N * 0.9), sample(N * 0.9, N * 0.1, TRUE))),
195+
id = sample(c(seq.int(N9), sample(N9, N-N9, TRUE))),
182196
v1 = sample(5L, N, TRUE),
183197
v2 = sample(5L, N, TRUE)
184198
)
@@ -251,5 +265,15 @@ test.list <- atime::atime_test_list(
251265
Before = "f339aa64c426a9cd7cf2fcb13d91fc4ed353cd31", # Parent of the first commit https://github.com/Rdatatable/data.table/commit/fcc10d73a20837d0f1ad3278ee9168473afa5ff1 in the PR https://github.com/Rdatatable/data.table/pull/6393/commits with major change to fwrite with gzip.
252266
PR = "3630413ae493a5a61b06c50e80d166924d2ef89a"), # Close-to-last merge commit in the PR.
253267

254-
tests=extra.test.list)
268+
# Test case created directly using the atime code below (not adapted from any other benchmark), based on the PR, Removes unnecessary data.table call from as.data.table.array https://github.com/Rdatatable/data.table/pull/7010
269+
"as.data.table.array improved in #7010" = atime::atime_test(
270+
setup = {
271+
dims = c(N, 1, 1)
272+
arr = array(seq_len(prod(dims)), dim=dims)
273+
},
274+
expr = data.table:::as.data.table.array(arr, na.rm=FALSE),
275+
Slow = "73d79edf8ff8c55163e90631072192301056e336", # Parent of the first commit in the PR (https://github.com/Rdatatable/data.table/commit/8397dc3c993b61a07a81c786ca68c22bc589befc)
276+
Fast = "8397dc3c993b61a07a81c786ca68c22bc589befc"), # Commit in the PR (https://github.com/Rdatatable/data.table/pull/7019/commits) that removes inefficiency
277+
278+
tests=extra.test.list)
255279
# nolint end: undesirable_operator_linter.

.github/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ See [`?test`](https://rdatatable.gitlab.io/data.table/reference/test.html).
7676
1. **[Squashing Github pull requests into a single commit](http://eli.thegreenplace.net/2014/02/19/squashing-github-pull-requests-into-a-single-commit)**.
7777
1. **[Github help](https://help.github.com/articles/using-pull-requests/)** - you'll need the *fork and pull* model.
7878

79+
#### Performance testing
80+
81+
If your PR may have an effect on time/memory usage, please consider adding a performance test, either in the same PR, or a follow-up PR. Note that first-time contributors _must_ do so in a follow-up PR, since the tests are only run on PRs from branches created directly in the Rdatatable/data.table repo. See the [Performance testing](https://github.com/Rdatatable/data.table/wiki/Performance-testing) wiki page for details.
82+
7983
Minimal first time PR
8084
---------------------
8185

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
4. `as.Date()` method for `IDate` no longer coerces to `double` [#6922](https://github.com/Rdatatable/data.table/issues/6922). Thanks @MichaelChirico for the report and PR. The only effect should be on overly-strict tests that assert `Date` objects have `double` storage, which is not in general true, especially from R 4.5.0.
1616

17+
5. `as.data.table()` is slightly more efficient at converting arrays to data.tables, [#7019](https://github.com/Rdatatable/data.table/pull/7019). Thanks @eliocamp.
18+
1719
### BUG FIXES
1820

1921
1. Custom binary operators from the `lubridate` package now work with objects of class `IDate` as with a `Date` subclass, [#6839](https://github.com/Rdatatable/data.table/issues/6839). Thanks @emallickhossain for the report and @aitap for the fix.
@@ -45,6 +47,12 @@
4547

4648
3. {data.table} now depends on R 3.4.0 (2017).
4749

50+
4. Changes to `fread()` output and errors:
51+
52+
+ When the size of the file exceeds the size of the address space, `fread()` now signals an informative error instead of trying to map its size modulo the address space.
53+
+ On non-Windows systems, `fread()` now prints the reason why the file couldn't be opened, which could also be due to it being too large to map.
54+
+ With `verbose=TRUE`, file sizes are now printed using correct binary SI prefixes (the sizes have always been reported as bytes denominated in powers of `2^10`, so e.g. `1024*1024` bytes was reported as `1 MB` where `1 MiB` or `1.05 MB` is correct).
55+
4856
## data.table [v1.17.0](https://github.com/Rdatatable/data.table/milestone/34) (20 Feb 2025)
4957

5058
### POTENTIALLY BREAKING CHANGES

R/as.data.table.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ as.data.table.array = function(x, keep.rownames=FALSE, key=NULL, sorted=TRUE, va
9696
dnx = dimnames(x)
9797
# NULL dimnames will create integer keys, not character as in table method
9898
val = if (is.null(dnx)) {
99-
lapply(dx, seq.int)
99+
lapply(dx, seq_len)
100100
} else if (any(nulldnx <- vapply_1b(dnx, is.null))) {
101-
dnx[nulldnx] = lapply(dx[nulldnx], seq.int) #3636
101+
dnx[nulldnx] = lapply(dx[nulldnx], seq_len) #3636
102102
dnx
103103
} else dnx
104104
val = rev(val)
@@ -107,7 +107,8 @@ as.data.table.array = function(x, keep.rownames=FALSE, key=NULL, sorted=TRUE, va
107107
if (value.name %chin% names(val))
108108
stopf("Argument 'value.name' should not overlap with column names in result: %s", brackify(rev(names(val))))
109109
N = NULL
110-
ans = data.table(do.call(CJ, c(val, sorted=FALSE)), N=as.vector(x))
110+
ans = do.call(CJ, c(val, sorted=FALSE))
111+
set(ans, j="N", value=as.vector(x))
111112
if (isTRUE(na.rm))
112113
ans = ans[!is.na(N)]
113114
setnames(ans, "N", value.name)

src/assign.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,4 +1335,3 @@ SEXP setcharvec(SEXP x, SEXP which, SEXP newx)
13351335
}
13361336
return R_NilValue;
13371337
}
1338-

src/chmatch.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,3 @@ system.time(ans2 <- .Call("Cchmatch2", x,y,0L)) # 0.17sec as of 1.12.0 and
169169
system.time(ans3 <- chmatchdup(x,y,0L)) # 0.09sec from 1.12.2; but goal wasn't speed rather simplified code; e.g. rbindlist.c down from 960 to 360 lines
170170
identical(ans2,ans3) # test 2000
171171
*/
172-

src/cj.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,3 @@ SEXP cj(SEXP base_list) {
9999
UNPROTECT(1);
100100
return out;
101101
}
102-

src/coalesce.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,3 @@ SEXP coalesce(SEXP x, SEXP inplaceArg) {
172172
UNPROTECT(nprotect);
173173
return first;
174174
}
175-

src/data.table.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,3 @@ SEXP dt_has_zlib(void);
356356
SEXP startsWithAny(SEXP, SEXP, SEXP);
357357
SEXP convertDate(SEXP, SEXP);
358358
SEXP fastmean(SEXP);
359-

src/fastmean.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,3 @@ SEXP fastmean(SEXP args)
134134
COMPLEX(ans)[0].i = (double) si;
135135
break;
136136
*/
137-

0 commit comments

Comments
 (0)