charport 0.3.0 (2026-11-26)
CRAN release: 2026-11-27
- A
Reader’s views of acharvecorcharpackstay valid when the vector is materialized while theReaderis open, for example through another reference to it or a wrapper around it. Both classes count open Readers and keep their packed data while any is open; it is then freed with the vector. Thecharpackserialization format is unchanged. - Readers are acquired and released on the main thread, and worker threads only call access methods. Keep the vector protected until its
Readeris released.charport_info()now reportsstateful_readerforcharvecandcharpack. - A failed
resize()or copy assignment ofcharport::ByteViewsorcharport::StrViewsleaves the buffer as it was. An allocation failure could previously leavesize()larger than one of its arrays. These are inline header classes, so a consumer package picks up the fix on rebuild. - A moved-from
charport::Readeris empty, with size 0. It previously kept its length and access callbacks without its state. Also a header fix. -
charport_materialize()materializes any character vector through R’s accessor, including base R deferred strings. -
Store(n, initial_slice_bytes)andRecordTable(n)initialize records to NA. Passcharvec::uninitializedto skip the fill when the caller writes every record, including missing values. Fixed-size builders use that path. -
charvec::placeholder()creates a charvec that receives a completed Store throughBuilder::fill_placeholder()orcharvec::fill_store(). To create an NA-filled charvec, wrap a two-argument Store. Thealloc_na()entry point has been removed. -
charvec::Writerhas been removed. Usecharvec::Builderto fill the records and callrelease_store()when you need the finished Store. - New
charport::is_ascii(ptr, len)incharport/ascii.h: an R-free ASCII scan that is fast on ASCII text and stops early on non-ASCII text. - Test-only native entry points and forced-wide charpack controls now live in a test-built library.
as_charpack()has a dedicated production converter. -
as_charvec()andas_charpack()read registered ALTREP inputs through the broker, so conversion between charvec and charpack keeps the source packed. Unregistered ALTREP inputs retain the ordinary R fallback. - Document that non-empty records in a finished
charvec::Storemust have disjoint byte ranges, because element assignment can reuse those bytes.
charport 0.2.0 (2026-11-06)
CRAN release: 2026-11-06
- New
charpackclass: a compact ALTREP character vector whose strings live in one R raw vector, for many short vectors. AReaderreaches any element directly, without allocating.as_charpack()converts to one andis_charpack()tests for one. In C++,charpack::from_store()copies a finishedcharvec::Storeinto one, so a producer can build with thecharvecbuilders and choose the class at the end. Reading an element through ordinary R access materializes the wholecharpack; aReaderkeeps it packed, and so do vector subsets such asx[i], which return a newcharpack. -
charvec::alloc_na(),charvec::get_store()andcharvec::Writerfill acharvecin place after it is created. - On R >= 4.6,
Readernow handles basewrap_stringALTREP without materialization. -
charport_materialize()also materializes acharpack. - Fix
x[i]on acharvecreturningNAfor a real index betweenlength(x)andlength(x) + 1, instead of the last element. - A filled
charpackserializes in its compact form, likecharvec, without materializing; on a little-endian host its raw vector is written and read back without a copy. Both write little-endian on every host; big-endiancharvecstates from earlier versions still load. - Serialization is now safe across locales. A
charvecorcharpackwith native-encoded strings is saved in packed form only in a UTF-8 locale; elsewhere it is saved as an ordinary character vector, so R converts its strings on reading, and the source stays packed. Native strings in a packed state read outside a UTF-8 locale are marked UTF-8.charvecstates are now version 2; version 1 states from 0.1 still load, with native strings read as the current locale’s, as before. - New C function
charport_native_is_utf8()(C++:charport::native_is_utf8()) reports whether R currently reads native strings as UTF-8, followingSys.setlocale(). -
Readernow calls a registered class’initfirst, and otherwise falls back toSTRING_PTR_RO.