Skip to content

Commit

Permalink
Internal helper get_type_size() now accept the "list" type
Browse files Browse the repository at this point in the history
  • Loading branch information
hpages committed Aug 16, 2018
1 parent c9de522 commit ecddbd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Wrapping an array-like object (typically an on-disk object) in
also works on in-memory array-like objects like DataFrame objects
(typically with Rle columns), Matrix objects, and ordinary arrays and
data frames.
Version: 0.7.28
Version: 0.7.29
Encoding: UTF-8
Author: Hervé Pagès <hpages@fredhutch.org>, with contributions from
Peter Hickey <peter.hickey@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion R/RealizationSink-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### of DelayedArray backends. Concrete subclasses must implement:
### 1) A constructor function that takes argument 'dim', 'dimnames', and
### 'type'.
### 2) "dim" and "dimnames" methods.
### 2) "dim", "dimnames", and "type" methods.
### 3) A "write_block" method.
### 4) A "close" method (optional).
### 5) Coercion to DelayedArray.
Expand Down
15 changes: 12 additions & 3 deletions R/blockGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ setDefaultBlockSize <- function(size=1e8)
### getDefaultBlockLength()
###

### The elements of a character vector or a list have a variable size.
### For a character vector: the minimum size of an element is 8 bytes which
### is the overhead of a CHARSXP object. This doesn't account for the string
### data itself.
### For a list: the minimum size of a list element is 8 bytes and is obtained
### when the element is a NULL. However, assuming that a list will typically
### contain more non-NULL than NULL elements and that the non-NULL elements
### will typically be atomic vectors, the average element size is more likely
### to be >= the overhead of an atomic vector which is 56 bytes.
get_type_size <- function(type)
{
### Atomic type sizes in bytes.
Expand All @@ -50,9 +59,9 @@ get_type_size <- function(type)
numeric=8L,
double=8L,
complex=16L,
character=8L, # just the overhead of a CHARSXP; doesn't account for
# the string data itself
raw=1L
character=8L, # overhead of a CHARSXP object
raw=1L,
list=56L # overhead of an atomic vector
)
if (missing(type))
return(TYPE_SIZES)
Expand Down

0 comments on commit ecddbd7

Please sign in to comment.