MCPcopy Create free account
hub / github.com/apache/arrow / Materialize

Method Materialize

r/src/altrep.cpp:893–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

891 }
892
893 static SEXP Materialize(SEXP alt) {
894 if (Base::IsMaterialized(alt)) {
895 return Representation(alt);
896 }
897
898 const auto& chunked_array = GetChunkedArray(alt);
899 SEXP data2 = PROTECT(Rf_allocVector(STRSXP, chunked_array->length()));
900 MARK_NOT_MUTABLE(data2);
901
902 R_xlen_t i = 0;
903 RStringViewer& r_string_viewer = string_viewer();
904 r_string_viewer.reset_null_was_stripped();
905 r_string_viewer.set_strip_out_nuls(GetBoolOption("arrow.skip_nul", false));
906 for (const auto& array : chunked_array->chunks()) {
907 r_string_viewer.SetArray(array);
908
909 auto ni = array->length();
910 for (R_xlen_t j = 0; j < ni; j++, i++) {
911 SET_STRING_ELT(data2, i, r_string_viewer.Convert(j));
912 }
913 }
914
915 if (r_string_viewer.nul_was_stripped()) {
916 Rf_warning("Stripping '\\0' (nul) from character vector");
917 }
918
919 // only set to data2 if all the values have been converted
920 SetRepresentation(alt, data2);
921 UNPROTECT(1); // data2
922
923 // remove reference to chunked array
924 R_set_altrep_data1(alt, R_NilValue);
925
926 return data2;
927 }
928
929 static const void* Dataptr_or_null(SEXP alt) {
930 if (Base::IsMaterialized(alt)) {

Callers

nothing calls this directly

Calls 8

GetBoolOptionFunction · 0.85
set_strip_out_nulsMethod · 0.80
nul_was_strippedMethod · 0.80
lengthMethod · 0.45
chunksMethod · 0.45
SetArrayMethod · 0.45
ConvertMethod · 0.45

Tested by

no test coverage detected