[rkward-cvs] SF.net SVN: rkward:[2644] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Sep 7 11:06:18 UTC 2009


Revision: 2644
          http://rkward.svn.sourceforge.net/rkward/?rev=2644&view=rev
Author:   tfry
Date:     2009-09-07 11:06:17 +0000 (Mon, 07 Sep 2009)

Log Message:
-----------
For very large data.frames (e.g. 5000row/1000cols), this patch speeds up structure fetching quite dramatically.
Not sure why the speedup is quite _this_ huge.
Yields identical structures at least for the standard packages and lme4. I hope there are no surprises elsewhere.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rbackend/rkstructuregetter.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-09-03 17:23:22 UTC (rev 2643)
+++ trunk/rkward/ChangeLog	2009-09-07 11:06:17 UTC (rev 2644)
@@ -1,3 +1,4 @@
+- Fetching object structure is much faster for very large data.frames
 - Fix crash when loading certain packages on Windows
 - Fix some potential path issues on Windows
 - "Analysis" menu was restructured, slightly

Modified: trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2009-09-03 17:23:22 UTC (rev 2643)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2009-09-07 11:06:17 UTC (rev 2644)
@@ -417,13 +417,15 @@
 			}
 		} else if (do_cont) {
 			RK_DO (qDebug ("recurse into list %s", name.toLatin1().data ()), RBACKEND, DL_DEBUG);
-			if (Rf_isList (value) && (!Rf_isObject (value))) {		// old style list
+			// print.c in R has special handling for objects of this sort, so we better play it safe for those, too. It is not really certain that we need this, though (originally introduced in SVN rev 1826 without decent comment).
+			bool may_be_special = Rf_isObject (value) && (Rf_length (value) == 0);
+			if (Rf_isList (value) && (!may_be_special)) {		// old style list
 				for (unsigned int i = 0; i < childcount; ++i) {
 					SEXP child = CAR (value);
 					getStructureSafe (child, childnames[i], false, children[i]);
 					CDR (value);
 				}
-			} else if (Rf_isNewList (value) && (!Rf_isObject (value))) {				// new style list
+			} else if (Rf_isNewList (value) && (!may_be_special)) {				// new style list
 				for (unsigned int i = 0; i < childcount; ++i) {
 					SEXP child = VECTOR_ELT(value, i);
 					getStructureSafe (child, childnames[i], false, children[i]);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list