Skip to content

Commit fc9db7d

Browse files
authored
Merge branch 'master' into master
2 parents 44bd220 + 2d9216a commit fc9db7d

3 files changed

Lines changed: 134 additions & 11 deletions

File tree

.ci/atime/tests.R

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,125 @@ test.list <- atime::atime_test_list(
136136
"NAMESPACE",
137137
sprintf('useDynLib\\("?%s"?', Package_regex),
138138
paste0('useDynLib(', new.Package_))
139+
pkg_find_replace(
140+
file.path("src", "Makevars.*in"),
141+
"@PKG_CFLAGS@", "@PKG_CFLAGS@ -DSTRING_PTR_RO=STRING_PTR_RO")
142+
backports = c(
143+
"src/data.table.h" = '
144+
#include <Rversion.h>
145+
#if R_VERSION >= R_Version(4, 6, 0)
146+
// backports.c
147+
void SETLENGTH(SEXP x, R_xlen_t n);
148+
R_xlen_t TRUELENGTH(SEXP x);
149+
void SET_TRUELENGTH(SEXP x, R_xlen_t n);
150+
void SET_GROWABLE_BIT(SEXP);
151+
int LEVELS(SEXP);
152+
int NAMED(SEXP);
153+
#define REFCNT(x) NAMED(x)
154+
SEXP ATTRIB(SEXP);
155+
void SET_ATTRIB(SEXP, SEXP);
156+
int OBJECT(SEXP);
157+
void SET_OBJECT(SEXP, int);
158+
#define isFrame(x) isDataFrame(x)
159+
#define GetOption(x, none) GetOption1(x)
160+
#undef findVar // Rf_ mapping remains
161+
#define findVar(sym, env) R_getVar(sym, env, FALSE)
162+
#define STRING_PTR(x) ((SEXP *)STRING_PTR_RO(x))
163+
int IS_S4_OBJECT(SEXP);
164+
void SET_S4_OBJECT(SEXP);
165+
void UNSET_S4_OBJECT(SEXP);
166+
void SET_TYPEOF(SEXP, int);
167+
#define VECTOR_ELT(x, i) VECTOR_ELT_(x, i)
168+
SEXP VECTOR_ELT_(SEXP, R_xlen_t);
169+
#define VECTOR_PTR(x) ((SEXP*)DATAPTR_RO(x))
170+
#define DATAPTR(x) ((void*)DATAPTR_RO(x))
171+
#endif
172+
',
173+
"src/backports.c" = '
174+
#include "data.table.h"
175+
#if R_VERSION >= R_Version(4, 6, 0)
176+
#define NAMED_BITS 16
177+
struct sxpinfo_struct {
178+
SEXPTYPE type : TYPE_BITS; // in Rinternals.h
179+
unsigned int scalar: 1;
180+
unsigned int obj : 1;
181+
unsigned int alt : 1;
182+
unsigned int gp : 16;
183+
unsigned int mark : 1;
184+
unsigned int debug : 1;
185+
unsigned int trace : 1;
186+
unsigned int spare : 1;
187+
unsigned int gcgen : 1;
188+
unsigned int gccls : 3;
189+
unsigned int named : NAMED_BITS;
190+
unsigned int extra : 32 - NAMED_BITS;
191+
};
192+
193+
struct vecsxp_struct {
194+
R_xlen_t length;
195+
R_xlen_t truelength;
196+
};
197+
198+
typedef struct VECTOR_SEXPREC {
199+
struct sxpinfo_struct sxpinfo;
200+
SEXP attrib;
201+
SEXP gengc_next_node, gengc_prev_node;
202+
struct vecsxp_struct vecsxp;
203+
} *VECSEXP;
204+
205+
void SETLENGTH(SEXP x, R_xlen_t n) {
206+
((VECSEXP)x)->vecsxp.length = n;
207+
}
208+
R_xlen_t TRUELENGTH(SEXP x) {
209+
return ((VECSEXP)x)->vecsxp.truelength;
210+
}
211+
void SET_TRUELENGTH(SEXP x, R_xlen_t n) {
212+
((VECSEXP)x)->vecsxp.truelength = n;
213+
}
214+
void SET_GROWABLE_BIT(SEXP x) {
215+
((VECSEXP)x)->sxpinfo.gp |= 0x20;
216+
}
217+
int LEVELS(SEXP x) {
218+
return ((VECSEXP)x)->sxpinfo.gp;
219+
}
220+
int NAMED(SEXP x) {
221+
return ((VECSEXP)x)->sxpinfo.named;
222+
}
223+
int OBJECT(SEXP x) {
224+
return ((VECSEXP)x)->sxpinfo.obj;
225+
}
226+
void SET_OBJECT(SEXP x, int o) {
227+
((VECSEXP)x)->sxpinfo.obj = o;
228+
}
229+
SEXP ATTRIB(SEXP x) {
230+
return ((VECSEXP)x)->attrib;
231+
}
232+
void SET_ATTRIB(SEXP x, SEXP att) {
233+
((VECSEXP)x)->attrib = att;
234+
}
235+
#define S4_OBJECT (1<<4)
236+
int IS_S4_OBJECT(SEXP x) {
237+
return ((VECSEXP)x)->sxpinfo.gp & S4_OBJECT;
238+
}
239+
void SET_S4_OBJECT(SEXP x) {
240+
((VECSEXP)x)->sxpinfo.gp |= S4_OBJECT;
241+
}
242+
void UNSET_S4_OBJECT(SEXP x) {
243+
((VECSEXP)x)->sxpinfo.gp &= ~S4_OBJECT;
244+
}
245+
void SET_TYPEOF(SEXP x, int type) {
246+
((VECSEXP)x)->sxpinfo.type = type;
247+
}
248+
SEXP VECTOR_ELT_(SEXP x, R_xlen_t i) {
249+
return ALTREP(x) ? (VECTOR_ELT)(x, i) : ((SEXP*)DATAPTR_RO(x))[i];
250+
}
251+
#endif
252+
')
253+
for (n in names(backports)) {
254+
f = file(file.path(new.pkg.path, n), "a")
255+
writeLines(backports[[n]], f)
256+
close(f)
257+
}
139258
},
140259

141260
# Constant overhead improvement https://github.com/Rdatatable/data.table/pull/6925

NEWS.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,9 @@
4444

4545
4. `rowwiseDT()` now provides a helpful error message when a complex object that is not a list (e.g., a function) is provided as a cell value, instructing the user to wrap it in `list()`, [#7219](https://github.com/Rdatatable/data.table/issues/7219). Thanks @kylebutts for the report and @venom1204 for the fix.
4646

47-
5. Non-equi joins combining an equality condition with two inequality conditions on the same column (e.g., `on = .(id == id, val >= lo, val <= hi)`) no longer error, [#7641](https://github.com/Rdatatable/data.table/issues/7641). The internal `chmatchdup` remapping of duplicate `rightcols` was overwriting the original column indices, causing downstream code to reference non-existent columns. Thanks @tarun-t for the report and fix, and @aitap for the diagnosis.
47+
5. `fread()` can now read from connections directly by spilling to a temporary file first, [#561](https://github.com/Rdatatable/data.table/issues/561). For the best throughput, point `tmpdir=` (or the global temp directory) to fast storage like an SSD or RAM. Thanks to Chris Neff for the report and @ben-schwen for the implementation.
4848

49-
6. By-reference sub-assignments of strings to factor columns now _actually_ match the levels in UTF-8 when required and now don't result in invalid factors being created, [#7648](https://github.com/Rdatatable/data.table/issues/7648), amending a previous incomplete fix to [#6886](https://github.com/Rdatatable/data.table/issues/6886) in v1.17.2. Thanks @BASS-JN for the report and @aitap for the fix.
50-
51-
7. `fread()` can now read from connections directly by spilling to a temporary file first, [#561](https://github.com/Rdatatable/data.table/issues/561). For the best throughput, point `tmpdir=` (or the global temp directory) to fast storage like an SSD or RAM. Thanks to Chris Neff for the report and @ben-schwen for the implementation.
52-
53-
8. `frollapply()` no longer produces output longer than the input when the window length is also longer than the input [#7646](https://github.com/Rdatatable/data.table/issues/7646). Thanks to @hadley-johnson for reporting and @jangorecki for the fix.
54-
55-
9. `fread()` no longer replaces a literal header column name `"NA"` with an auto-generated `Vn` name when `na.strings` includes `"NA"`, [#5124](https://github.com/Rdatatable/data.table/issues/5124). Data rows still continue to parse `"NA"` as missing. Thanks @Mashin6 for the report and @shrektan for the fix.
56-
57-
10. `fread()` no longer misreads dates with negative years, [#7704](https://github.com/Rdatatable/data.table/issues/7704). Thanks to @kevinushey for the report and @aitap for the fix.
49+
6. `fread()` no longer replaces a literal header column name `"NA"` with an auto-generated `Vn` name when `na.strings` includes `"NA"`, [#5124](https://github.com/Rdatatable/data.table/issues/5124). Data rows still continue to parse `"NA"` as missing. Thanks @Mashin6 for the report and @shrektan for the fix.
5850

5951
### Notes
6052

@@ -70,6 +62,18 @@
7062

7163
6. Enhanced tests for OpenMP support, detecting incompatibilities such as R-bundled runtime _vs._ newer Xcode and testing for a manually installed runtime from <https://mac.r-project.org/openmp>, [#6622](https://github.com/Rdatatable/data.table/issues/6622). Thanks to @dvg-p4 for initial report and testing, @twitched for the pointers, @tdhock and @aitap for the fix.
7264

65+
## data.table [v1.18.4](https://github.com/Rdatatable/data.table/milestone/45) (6 May 2026)
66+
67+
### BUG FIXES
68+
69+
1. Non-equi joins combining an equality condition with two inequality conditions on the same column (e.g., `on = .(id == id, val >= lo, val <= hi)`) no longer error, [#7641](https://github.com/Rdatatable/data.table/issues/7641). The internal `chmatchdup` remapping of duplicate `rightcols` was overwriting the original column indices, causing downstream code to reference non-existent columns. Thanks @tarun-t for the report and fix, and @aitap for the diagnosis.
70+
71+
2. By-reference sub-assignments of strings to factor columns now _actually_ match the levels in UTF-8 when required and now don't result in invalid factors being created, [#7648](https://github.com/Rdatatable/data.table/issues/7648), amending a previous incomplete fix to [#6886](https://github.com/Rdatatable/data.table/issues/6886) in v1.17.2. Thanks @BASS-JN for the report and @aitap for the fix.
72+
73+
3. `fread()` no longer misreads dates with negative years, [#7704](https://github.com/Rdatatable/data.table/issues/7704). Thanks to @kevinushey for the report and @aitap for the fix.
74+
75+
4. `frollapply()` no longer produces output longer than the input when the window length is also longer than the input [#7646](https://github.com/Rdatatable/data.table/issues/7646). Thanks to @hadley-johnson for reporting and @jangorecki for the fix.
76+
7377
## data.table [v1.18.2.1](https://github.com/Rdatatable/data.table/milestone/44?closed=1) (22 January 2026)
7478

7579
### BUG FIXES

inst/tests/tests.Rraw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18419,7 +18419,7 @@ test(2264.8, print(DT, show.indices=TRUE), output=ans)
1841918419
if (test_bit64) local({
1842018420
DT = data.table(a = 'abc', b = as.integer64(1))
1842118421
suppressPackageStartupMessages(unloadNamespace("bit64"))
18422-
on.exit(suppressPackageStartupMessages(library(bit64, pos="package:base")))
18422+
on.exit(suppressWarnings(suppressPackageStartupMessages(library(bit64, pos="package:base"))))
1842318423
test(2265, DT, output="abc\\s*1$")
1842418424
})
1842518425

0 commit comments

Comments
 (0)