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

Method Elt

r/src/altrep.cpp:861–887  ·  view source on GitHub ↗

Get a single string as a CHARSXP SEXP

Source from the content-addressed store, hash-verified

859
860 // Get a single string as a CHARSXP SEXP
861 static SEXP Elt(SEXP alt, R_xlen_t i) {
862 if (Base::IsMaterialized(alt)) {
863 return STRING_ELT(Representation(alt), i);
864 }
865
866 auto altrep_data =
867 reinterpret_cast<ArrowAltrepData*>(R_ExternalPtrAddr(R_altrep_data1(alt)));
868 auto resolve = altrep_data->locate(i);
869 const auto& array =
870 altrep_data->chunked_array()->chunk(static_cast<int>(resolve.chunk_index));
871 auto j = resolve.index_in_chunk;
872
873 SEXP s = NA_STRING;
874 RStringViewer& r_string_viewer = string_viewer();
875 r_string_viewer.SetArray(array);
876 // Note: we don't check GetBoolOption("arrow.skip_nul", false) here
877 // because it is too expensive to do so. We do set this value whenever
878 // an altrep string; however, there is a chance that this value could
879 // be out of date by the time a value in the vector is accessed.
880 r_string_viewer.reset_null_was_stripped();
881 s = r_string_viewer.Convert(j);
882 if (r_string_viewer.nul_was_stripped()) {
883 Rf_warning("Stripping '\\0' (nul) from character vector");
884 }
885
886 return s;
887 }
888
889 static void* Dataptr(SEXP alt, Rboolean writeable) {
890 return const_cast<void*>(DATAPTR_RO(Materialize(alt)));

Callers

nothing calls this directly

Calls 6

locateMethod · 0.80
chunked_arrayMethod · 0.80
nul_was_strippedMethod · 0.80
SetArrayMethod · 0.45
ConvertMethod · 0.45

Tested by

no test coverage detected