[Rprotobuf-commits] r885 - papers/jss

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 25 03:42:24 CET 2014


Author: murray
Date: 2014-03-25 03:42:19 +0100 (Tue, 25 Mar 2014)
New Revision: 885

Modified:
   papers/jss/article.R
   papers/jss/article.Rnw
Log:
Ditch the non-portable int64 examples with a description of what the
option does.



Modified: papers/jss/article.R
===================================================================
--- papers/jss/article.R	2014-03-24 23:33:30 UTC (rev 884)
+++ papers/jss/article.R	2014-03-25 02:42:19 UTC (rev 885)
@@ -196,45 +196,14 @@
 
 
 ###################################################
-### code chunk number 25: article.Rnw:1040-1043
+### code chunk number 25: article.Rnw:1078-1080
 ###################################################
-test <- new(JSSPaper.Example1)
-test$repeated_int64 <- c(2^53, 2^53+1)
-length(unique(test$repeated_int64))
-
-
-###################################################
-### code chunk number 26: article.Rnw:1050-1051
-###################################################
-test$repeated_int64 <- c("9007199254740992", "9007199254740993")
-
-
-###################################################
-### code chunk number 27: article.Rnw:1062-1068
-###################################################
-options("RProtoBuf.int64AsString" = FALSE)
-test$repeated_int64
-length(unique(test$repeated_int64))
-options("RProtoBuf.int64AsString" = TRUE)
-test$repeated_int64
-length(unique(test$repeated_int64))
-
-
-###################################################
-### code chunk number 28: article.Rnw:1071-1072
-###################################################
-options("RProtoBuf.int64AsString" = FALSE)
-
-
-###################################################
-### code chunk number 29: article.Rnw:1089-1091
-###################################################
 msg <- serialize_pb(iris, NULL)
 identical(iris, unserialize_pb(msg))
 
 
 ###################################################
-### code chunk number 30: article.Rnw:1122-1125
+### code chunk number 26: article.Rnw:1111-1114
 ###################################################
 datasets <- as.data.frame(data(package="datasets")$results)
 datasets$name <- sub("\\s+.*$", "", datasets$Item)
@@ -242,13 +211,13 @@
 
 
 ###################################################
-### code chunk number 31: article.Rnw:1135-1136
+### code chunk number 27: article.Rnw:1124-1125
 ###################################################
 m <- sum(sapply(datasets$name, function(x) can_serialize_pb(get(x))))
 
 
 ###################################################
-### code chunk number 32: article.Rnw:1149-1156
+### code chunk number 28: article.Rnw:1138-1145
 ###################################################
 attr(CO2, "formula")
 msg <- serialize_pb(CO2, NULL)
@@ -260,7 +229,7 @@
 
 
 ###################################################
-### code chunk number 33: article.Rnw:1172-1191
+### code chunk number 29: article.Rnw:1161-1180
 ###################################################
 datasets$object.size <- unname(sapply(datasets$name, function(x) object.size(eval(as.name(x)))))
 
@@ -284,7 +253,7 @@
 
 
 ###################################################
-### code chunk number 34: article.Rnw:1399-1404
+### code chunk number 30: article.Rnw:1388-1393
 ###################################################
 require(RProtoBuf)
 require(HistogramTools)
@@ -294,7 +263,7 @@
 
 
 ###################################################
-### code chunk number 35: article.Rnw:1472-1479 (eval = FALSE)
+### code chunk number 31: article.Rnw:1461-1468 (eval = FALSE)
 ###################################################
 ## library("RProtoBuf")
 ## library("httr")
@@ -306,7 +275,7 @@
 
 
 ###################################################
-### code chunk number 36: article.Rnw:1538-1554 (eval = FALSE)
+### code chunk number 32: article.Rnw:1527-1543 (eval = FALSE)
 ###################################################
 ## library("httr")       
 ## library("RProtoBuf")
@@ -327,7 +296,7 @@
 
 
 ###################################################
-### code chunk number 37: article.Rnw:1558-1561 (eval = FALSE)
+### code chunk number 33: article.Rnw:1547-1550 (eval = FALSE)
 ###################################################
 ## fnargs <- unserialize_pb(inputmsg)
 ## val <- do.call(stats::rnorm, fnargs)

Modified: papers/jss/article.Rnw
===================================================================
--- papers/jss/article.Rnw	2014-03-24 23:33:30 UTC (rev 884)
+++ papers/jss/article.Rnw	2014-03-25 02:42:19 UTC (rev 885)
@@ -1034,44 +1034,33 @@
 \pkg{RProtoBuf} allows users to get and set 64-bit integer values by specifying 
 them as character strings.
 
-If we try to set an int64 field in \proglang{R} to double values, we lose
-precision:
-
-<<>>=
-test <- new(JSSPaper.Example1)
-test$repeated_int64 <- c(2^53, 2^53+1)
-length(unique(test$repeated_int64))
-@
-
-But when the values are specified as character strings, \pkg{RProtoBuf}
-will automatically coerce them into a true 64-bit integer types 
-before storing them in the Protocol Buffer message:
-
-<<>>=
-test$repeated_int64 <- c("9007199254740992", "9007199254740993")
-@
-
-When reading the value back into \proglang{R}, numeric types are returned by
-default, but when the full precision is required a character value
-will be returned if the \code{RProtoBuf.int64AsString} option is set
-to \code{TRUE}.  The character values are useful because they can
+On 64-bit platforms, character strings representing large decimal
+numbers will be coerced to int64 during assignment to 64-bit protocol
+buffer types to work around the lack of native 64-bit types in \proglang{R}.  The
+values are stored as distinct int64 values in memory but when accessed
+from \proglang{R} language code they will be coerced into numeric values.  If the
+full 64-bit precision is required, the \code{RProtoBuf.int64AsString}
+option can be set to \code{TRUE} to return int64 values from messages as character
+strings.  The character values are useful because they can
 accurately be used as unique identifiers and can easily be passed to \proglang{R}
 packages such as \pkg{int64} \citep{int64} or \pkg{bit64}
 \citep{bit64} which represent 64-bit integers in \proglang{R}.
 
-<<>>=
-options("RProtoBuf.int64AsString" = FALSE)
-test$repeated_int64
-length(unique(test$repeated_int64))
-options("RProtoBuf.int64AsString" = TRUE)
-test$repeated_int64
-length(unique(test$repeated_int64))
-@
+% test <- new(JSSPaper.Example1)
+% test$repeated_int64 <- c(2^53, 2^53+1)
+% length(unique(test$repeated_int64))
 
-<<echo=FALSE,print=FALSE>>=
-options("RProtoBuf.int64AsString" = FALSE)
-@
+% test$repeated_int64 <- c("9007199254740992", "9007199254740993")
 
+% options("RProtoBuf.int64AsString" = FALSE)
+% test$repeated_int64
+% length(unique(test$repeated_int64))
+% options("RProtoBuf.int64AsString" = TRUE)
+% test$repeated_int64
+% length(unique(test$repeated_int64))
+
+% options("RProtoBuf.int64AsString" = FALSE)
+
 \section[Converting R data structures into Protocol Buffers]{Converting \proglang{R} data structures into Protocol Buffers}
 \label{sec:evaluation}
 



More information about the Rprotobuf-commits mailing list