search for: rawsxp

Displaying 20 results from an estimated 40 matches for "rawsxp".

2010 Aug 22
1
Handle RAWSXP in inspect.c:typename()
Hi all I had written a gdb macro to dump the string representation of an SEXPREC type when I realised everything I needed was in inspect.c already in the typename() function. However, the typename function doesnt handle the RAWSXP type, so if possible, could the following patch be applied (I've just put in inline as it is a trivial 1-liner)? Index: src/main/inspect.c =================================================================== --- src/main/inspect.c (revision 52221) +++ src/main/inspect.c (working copy) @@...
2006 Jan 27
1
rbind/cbind unimplemented for raw (RAWSXP) types. (PR#8529)
Full_Name: Hin-Tak Leung Version: R 2.2.1 OS: x86_64-redhat-linux-gnu Submission from: (NULL) (131.111.186.92) rbind/cbind is unimplemented for raw (RAWSXP) types. I have a working patch implementing the functionality, to follow. --please do not edit the information below-- Version: platform = x86_64-redhat-linux-gnu arch = x86_64 os = linux-gnu system = x86_64, linux-gnu status = major = 2 minor = 2.1 year = 2005 month = 12 day = 20 svn...
2006 Nov 21
2
packBits (PR#9374)
...t;integer") does not work. z<-packBits(rbinom(32,1,.5)==1,"integer") Error in packBits(x, type) : argument 'x' must be raw, integer or logical Taking a closer look at the C code main/character.c do_packBits rutin one can find the following checking if (TYPEOF(x) != RAWSXP && TYPEOF(x) != RAWSXP && TYPEOF(x) != INTSXP) errorcall(call, _("argument 'x' must be raw, integer or logical")); It's obvious that some of the RAWSXP should be LGLSXP
2009 May 10
2
In C, a fast way to slice a vector?
Hello, Suppose in the following code, PROTECT(sr = R_tryEval( .... )) sr is a RAWSXP vector. I wish to return another RAWSXP starting at position 13 onwards (base=0). I could create another RAWSXP of the correct length and then memcpy the required bytes and length to this new one. However is there a more efficient method? Regards Saptarshi Guha
2010 Jun 19
1
more powerful iconv
...mple > iconv("foo", to="UTF-16") Error in iconv("foo", to = "UTF-16") : embedded nul in string: '\xff\xfef\0o\0o\0' However, I don't believe embedded nulls are at issue here, but rather that R's iconv doesn't accept objects of type RAWSXP. The iconv mechanism, after all, operates on encoded binary data, and not necessarily null terminated C strings. I'd like to submit a very small patch (12 lines w/o documentation) that allows R's iconv to operate on raw objects, while not interfering or affecting the behavior of iconv on ch...
2005 Aug 20
1
Implementing a single-precision class with raw
...ll() function to access the raw vectors. However, there don't seem to be any macros for handling raw vectors in Rdefines.h. I've made a guess at what those macros would be and was wondering whether my guesses were correct and/or might be included in 2.2.0: #define NEW_RAW(n) allocVector(RAWSXP,n) #define RAW_POINTER(x) (RAW(x)) #define AS_RAW(x) coerceVector(x,RAWSXP) I'm not sure whether coerceVector(x,RAWSXP) will actually work. Also, there isn't an Rf_isRaw() function, which would be useful for an IS_RAW(x) macro. Another issue with the "float" class is that it w...
2017 Mar 29
3
Transferring ownership of R-managed buffer
I have a use case where I would like to create an SEXP around an existing buffer that is managed by R, thus avoiding a copy operation. If I have something like: void *p = (void*) RAW(PROTECT(Rf_allocVector(RAWSXP, n))); ... additional maniupulation ... SEXP x = somefunc(SXPTYPE, n, p); // ???? Is there a "placement" constructor available? (I have arranged for the corresponding UNPROTECT.) I've looked at and experimented with R_allocator and allocVector3, but can't quite get it right. I k...
2015 Mar 17
2
Reduce memory peak when serializing to raw vectors
...rialize(object, &out); val = CloseMemOutPStream(&out); The serialized object is being stored in a buffer pointed by out.data. Then in CloseMemOutPStream() R copies the whole buffer to a newly allocated SEXP object (the raw vector that stores the final result): PROTECT(val = allocVector(RAWSXP, mb->count)); memcpy(RAW(val), mb->buf, mb->count); free_mem_buffer(mb); UNPROTECT(1); Before calling free_mem_buffer() the process is using ~1.2GB (the original data frame + the serialization buffer + final serialized raw vector). One possible solution would be to allocate a buffer...
2005 May 12
0
Patch to address (PR#7853) -- tested briefly, seems to
...int Fort, > const char *name, R_toCConverter **converter, > int targetType) > { > + unsigned char *rawptr; > int *iptr; > float *sptr; > double *rptr; > @@ -228,6 +229,16 @@ > } > > switch(TYPEOF(s)) { > + case RAWSXP: > + n = LENGTH(s); > + rawptr = RAW(s); > + if (dup) { > + rawptr = (unsigned char *) R_alloc(n, sizeof(unsigned char)); > + for (i = 0; i < n; i++) > + rawptr[i] = RAW(s)[i]; > + } > + return (void *) rawptr; > + break; >...
2010 Jun 20
1
How to debug: Cons memory exhausted
Hello, I get an error when binary structures from a pipe 'Error: cons memory exhausted (limit reached?)' (but R does not crash) This is probably due to some bug in my code, but occurs after reading about 85K pairs of RAWSXP objects (each < 20 bytes). I do not have any explicit calls to malloc/calloc I'm going through my code and have inserted the (brute force) printf statements my question is: Does anybody have an advice on debugging this particular error? Any help will be appreciated Regards Saptarshi [[a...
2010 Sep 08
0
Correction to vec-subset speed patch
...appen: pairlists are coerced to lists */ - case LANGSXP: - if (0 <= ii && ii < nx && ii != NA_INTEGER) { - tmp2 = nthcdr(x, ii); - SETCAR(tmp, CAR(tmp2)); - SET_TAG(tmp, TAG(tmp2)); - } - else - SETCAR(tmp, R_NilValue); - tmp = CDR(tmp); - break; - case RAWSXP: - if (0 <= ii && ii < nx && ii != NA_INTEGER) - RAW(result)[i] = RAW(x)[ii]; - else - RAW(result)[i] = (Rbyte) 0; - break; - default: - errorcall(call, R_MSG_ob_nonsub, type2char(mode)); - } + case LANGSXP: + for (i = 0; i<n; i++) { +...
2015 Mar 17
2
Reduce memory peak when serializing to raw vectors
...(&out); > > > > The serialized object is being stored in a buffer pointed by out.data. > Then in CloseMemOutPStream() R copies the whole buffer to a newly allocated > SEXP object (the raw vector that stores the final result): > > > > PROTECT(val = allocVector(RAWSXP, mb->count)); > > memcpy(RAW(val), mb->buf, mb->count); > > free_mem_buffer(mb); > > UNPROTECT(1); > > > > Before calling free_mem_buffer() the process is using ~1.2GB (the > original data frame + the serialization buffer + final serialize...
2010 Aug 26
2
Speeding up transpose
...gt;=len) j -= (len-1); SET_STRING_ELT(r, i, STRING_ELT(a,j)); } break; case VECSXP: for (i = 0, j = 0; i<len; i += 1, j += nrow) { if (j>=len) j -= (len-1); SET_VECTOR_ELT(r, i, VECTOR_ELT(a,j)); } break; case RAWSXP: for (i = 0, j = 0; i<len; i += 1, j += nrow) { if (j>=len) j -= (len-1); RAW(r)[i] = RAW(a)[j]; } break; default: UNPROTECT(1); goto not_matrix; }
2008 Jan 25
3
strsignif.c, util.c (PR#10635)
In R 2.6.1, a couple of places (discovered using valgrind) where the requested size of string buffers fails to account correctly for the trailing null byte: 1. In src/appl/strsignif.c, 'f0' and 'form' at l. 108-9 each need at least 1 extra byte. 2. In src/main/util.c, 'out' at l. 1081 needs at least one extra byte. (Remember that the return value of strlen does not
2013 Dec 16
1
External pointers and changing SEXPTYPE
...cts get unprotected before return // finalizer is registered as well return Rdata; Later on in read_my_data() I read the pointer: my_data_ptr *mydata = (my_data_ptr*) R_ExternalPtrAddr(Rdata); // and REAL(mydata->R_a) yields error since TYPEOF(mydata->R_a) is not REALSXP as it should be but RAWSXP for some reason // (sometimes it's STRSXP or INTSXP while it should always be REALSXP) // The error message says: // REAL() can only be applied to a 'numeric', not a 'raw' // mydata->ans is the object returned to R where all the data is made available to R user: return mydat...
2009 Sep 20
1
Return a list from a .Call but segfaults
...et the following message [Thread debugging using libthread_db enabled] Error while reading shared library symbols: Cannot find new threads: generic error Cannot find new threads: generic error] and cannot proceed. ==== Code ==== SEXP returnListOfKV(SEXP raw,SEXP numread){ if(TYPEOF(raw)!=RAWSXP){ return(R_NilValue); } int num = INTEGER(numread)[0]; char *rawdata = (char*)RAW(raw); SEXP KV ,rval; int r; PROTECT(rval = Rf_allocVector(VECSXP, num)); for(int i=0;i<num;i++){ SEXP k = R_NilValue; PROTECT(KV = Rf_allocVector(VECSXP, 2));...
2013 Apr 09
2
Behaviors of diag() with character vector in R 3.0.0
Dear all, According to CHANGES IN R 3.0.0: o diag() as used to generate a diagonal matrix has been re-written in C for speed and less memory usage. It now forces the result to be numeric in the case diag(x) since it is said to have 'zero off-diagonal entries'. diag(x) does not work for character vector in R 3.0.0 any more. For example, v <- c("a",
2017 Mar 29
2
Transferring ownership of R-managed buffer
...from the general heap, but rather allocated using R's allocator and therefore returnable (hypothesis!) to the R interpreter as a vector (not external pointer) without a copy operation. > > If I have >> something like: >> >> void *p = (void*) RAW(PROTECT(Rf_allocVector(RAWSXP, n))); >> ... additional maniupulation ... >> SEXP x = somefunc(SXPTYPE, n, p); // ???? >> >> Is there a "placement" constructor available? >> > > What's a "placement" constructor? > Function that constructs an object using previously...
2015 Mar 17
0
Reduce memory peak when serializing to raw vectors
...; > val = CloseMemOutPStream(&out); > > The serialized object is being stored in a buffer pointed by out.data. Then in CloseMemOutPStream() R copies the whole buffer to a newly allocated SEXP object (the raw vector that stores the final result): > > PROTECT(val = allocVector(RAWSXP, mb->count)); > memcpy(RAW(val), mb->buf, mb->count); > free_mem_buffer(mb); > UNPROTECT(1); > > Before calling free_mem_buffer() the process is using ~1.2GB (the original data frame + the serialization buffer + final serialized raw vector). > > One possible solu...
2015 Mar 17
0
Reduce memory peak when serializing to raw vectors
...rialize(object, &out); val = CloseMemOutPStream(&out); The serialized object is being stored in a buffer pointed by out.data. Then in CloseMemOutPStream() R copies the whole buffer to a newly allocated SEXP object (the raw vector that stores the final result): PROTECT(val = allocVector(RAWSXP, mb->count)); memcpy(RAW(val), mb->buf, mb->count); free_mem_buffer(mb); UNPROTECT(1); Before calling free_mem_buffer() the process is using ~1.2GB (the original data frame + the serialization buffer + final serialized raw vector). One possible solution would be to allocate a buffer...