├── tests └── runTests.R ├── src ├── XZ │ ├── xz-5.2.9-win.zip │ ├── xz-5.2.9.tar.gz │ └── api │ │ └── lzma │ │ ├── delta.h │ │ ├── hardware.h │ │ ├── bcj.h │ │ ├── version.h │ │ ├── index_hash.h │ │ └── check.h ├── ZLIB │ ├── inffast.h │ ├── compress.c │ ├── inftrees.h │ ├── uncompr.c │ ├── LICENSE │ ├── adler32.c │ └── inffixed.h ├── LZ4 │ ├── LICENSE │ └── lz4frame_static.h ├── CoreArray │ ├── dParallel_Ext.c │ ├── CoreArray.h │ ├── dRealGDS.cpp │ ├── dStrGDS.cpp │ ├── CoreArray.cpp │ └── dEndian.cpp ├── Makevars.win └── Makevars ├── vignettes └── crayon_show.jpg ├── inst ├── unitTests │ ├── valid │ │ └── standard.RData │ ├── test_examples.R │ ├── include.r │ ├── test_05_attribute.R │ ├── test_01_datatype.R │ ├── test_02_dataconvert.R │ ├── test_03_dimension.R │ ├── test_04_datareadwrite.R │ └── test_08_miscellaneous.R ├── CITATION ├── COPYRIGHTS └── include │ └── R_GDS_CPP.h ├── .gitattributes ├── .gitignore ├── man ├── gdsn.class.Rd ├── lasterr.gds.Rd ├── gds.class.Rd ├── get.attr.gdsn.Rd ├── showfile.gds.Rd ├── unload.gdsn.Rd ├── rename.gdsn.Rd ├── exist.gdsn.Rd ├── delete.gdsn.Rd ├── is.sparse.gdsn.Rd ├── system.gds.Rd ├── delete.attr.gdsn.Rd ├── name.gdsn.Rd ├── closefn.gds.Rd ├── cnt.gdsn.Rd ├── getfolder.gdsn.Rd ├── summarize.gdsn.Rd ├── sync.gds.Rd ├── getfile.gdsn.Rd ├── is.element.gdsn.Rd ├── cleanup.gds.Rd ├── copyto.gdsn.Rd ├── cache.gdsn.Rd ├── ls.gdsn.Rd ├── readmode.gdsn.Rd ├── createfn.gds.Rd ├── put.attr.gdsn.Rd ├── permdim.gdsn.Rd ├── setdim.gdsn.Rd ├── index.gdsn.Rd ├── append.gdsn.Rd ├── write.gdsn.Rd ├── diagnosis.gds.Rd ├── moveto.gdsn.Rd ├── print.gds.class.Rd ├── objdesp.gdsn.Rd ├── assign.gdsn.Rd ├── digest.gdsn.Rd ├── read.gdsn.Rd ├── addfolder.gdsn.Rd ├── openfn.gds.Rd ├── readex.gdsn.Rd ├── addfile.gdsn.Rd ├── gdsfmt-package.Rd ├── clusterApply.gdsn.Rd └── compression.gdsn.Rd ├── .github └── workflows │ └── r.yml ├── NAMESPACE ├── DESCRIPTION └── R └── methods.r /tests/runTests.R: -------------------------------------------------------------------------------- 1 | options(test.verbose=FALSE) 2 | BiocGenerics:::testPackage("gdsfmt") 3 | -------------------------------------------------------------------------------- /src/XZ/xz-5.2.9-win.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengxwen/gdsfmt/HEAD/src/XZ/xz-5.2.9-win.zip -------------------------------------------------------------------------------- /src/XZ/xz-5.2.9.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengxwen/gdsfmt/HEAD/src/XZ/xz-5.2.9.tar.gz -------------------------------------------------------------------------------- /vignettes/crayon_show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengxwen/gdsfmt/HEAD/vignettes/crayon_show.jpg -------------------------------------------------------------------------------- /inst/unitTests/valid/standard.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengxwen/gdsfmt/HEAD/inst/unitTests/valid/standard.RData -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | data/* binary 3 | src/* text=lf 4 | R/* text=lf 5 | vignettes/* text=lf 6 | man/* text=lf 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .Rproj.user 3 | .Rhistory 4 | .Rprofile 5 | src/XZ/xz-5.2.3 6 | *.o 7 | *.so 8 | *.a 9 | *.lo 10 | *.la 11 | -------------------------------------------------------------------------------- /man/gdsn.class.Rd: -------------------------------------------------------------------------------- 1 | \name{gdsn.class} 2 | \docType{class} 3 | \alias{gdsn.class} 4 | 5 | \title{the class of variable node in the GDS file} 6 | \description{ 7 | The class of variable node in the GDS file. 8 | } 9 | 10 | \author{Xiuwen Zheng} 11 | \seealso{ 12 | \code{\link{add.gdsn}}, \code{\link{read.gdsn}}, 13 | \code{\link{write.gdsn}} 14 | } 15 | 16 | \keyword{GDS} 17 | \keyword{utilities} 18 | -------------------------------------------------------------------------------- /man/lasterr.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{lasterr.gds} 2 | \alias{lasterr.gds} 3 | \title{Return the last error message} 4 | \description{ 5 | Get the last error message and clear the error message(s) in the 6 | gdsfmt package. 7 | } 8 | 9 | \usage{ 10 | lasterr.gds() 11 | } 12 | \value{ 13 | Character. 14 | } 15 | 16 | \author{Xiuwen Zheng} 17 | \examples{ 18 | lasterr.gds() 19 | } 20 | 21 | \keyword{GDS} 22 | \keyword{utilities} 23 | -------------------------------------------------------------------------------- /src/ZLIB/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /man/gds.class.Rd: -------------------------------------------------------------------------------- 1 | \name{gds.class} 2 | \docType{class} 3 | \alias{gds.class} 4 | 5 | \title{the class of GDS file} 6 | \description{ 7 | The class of a CoreArray Genomic Data Structure (GDS) file. 8 | } 9 | 10 | \value{ 11 | There are three components: 12 | \item{filename}{the file name to be created} 13 | \item{id}{internal file id, an integer} 14 | \item{root}{an object of class \code{\link{gdsn.class}}, 15 | the root of hierachical structure} 16 | \item{readonly}{whether it is read-only or not} 17 | } 18 | 19 | \author{Xiuwen Zheng} 20 | \seealso{ 21 | \code{\link{createfn.gds}}, \code{\link{openfn.gds}}, 22 | \code{\link{closefn.gds}} 23 | } 24 | 25 | \keyword{GDS} 26 | \keyword{utilities} 27 | -------------------------------------------------------------------------------- /inst/unitTests/test_examples.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: run all examples in gdsfmt 4 | # 5 | 6 | library(gdsfmt) 7 | 8 | 9 | ############################################################# 10 | # 11 | # test functions 12 | # 13 | 14 | notest.examples <- function() 15 | { 16 | function.list <- readRDS( 17 | system.file("Meta", "Rd.rds", package="gdsfmt"))$Name 18 | 19 | sapply(function.list, FUN = function(func.name) 20 | { 21 | args <- list( 22 | topic=func.name, 23 | package="gdsfmt", 24 | echo=FALSE, verbose=FALSE, ask=FALSE 25 | ) 26 | cat("FUNCTION: ", func.name, "\n", sep="") 27 | suppressWarnings(do.call(example, args)) 28 | NULL 29 | }) 30 | 31 | invisible() 32 | } 33 | -------------------------------------------------------------------------------- /inst/unitTests/include.r: -------------------------------------------------------------------------------- 1 | library(RUnit) 2 | library(gdsfmt) 3 | 4 | # a list of data types 5 | type.list <- c("int8", "int16", "int24", "int32", "int64", 6 | paste("sbit", 2:16, sep=""), "sbit64", 7 | "uint8", "uint16", "uint24", "uint32", "uint64", 8 | paste("bit", 1:16, sep=""), "bit64", 9 | "vl_uint", "vl_int", 10 | "float32", "float64", 11 | "packedreal8", "packedreal16", "packedreal24", "packedreal32", 12 | "packedreal8u", "packedreal16u", "packedreal24u", "packedreal32u", 13 | "string", "string16", "string32", 14 | "cstring", "cstring16", "cstring32", 15 | "fstring", "fstring16", "fstring32") 16 | 17 | # a list of compression algorithms 18 | compress.list <- c("ZIP", "ZIP_RA:16K", "LZ4", "LZ4.fast", 19 | "LZ4_RA:16K", "LZ4_RA.fast:16K", "LZMA", "LZMA_RA:32K") 20 | 21 | # unittest.gdsfmt path 22 | base.path <- system.file("unitTests", package="gdsfmt") 23 | -------------------------------------------------------------------------------- /man/get.attr.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{get.attr.gdsn} 2 | \alias{get.attr.gdsn} 3 | \title{Get attributes} 4 | \description{ 5 | Get the attributes of a GDS node. 6 | } 7 | 8 | \usage{ 9 | get.attr.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | } 14 | \value{ 15 | A list of attributes. 16 | } 17 | 18 | \author{Xiuwen Zheng} 19 | \seealso{ 20 | \code{\link{put.attr.gdsn}}, \code{\link{delete.attr.gdsn}} 21 | } 22 | 23 | \examples{ 24 | # cteate a GDS file 25 | f <- createfn.gds("test.gds") 26 | 27 | node <- add.gdsn(f, "int", val=1:10000) 28 | put.attr.gdsn(node, "missing.value", 10000) 29 | 30 | f 31 | get.attr.gdsn(node) 32 | 33 | # close the GDS file 34 | closefn.gds(f) 35 | 36 | 37 | # delete the temporary file 38 | unlink("test.gds", force=TRUE) 39 | } 40 | 41 | \keyword{GDS} 42 | \keyword{utilities} 43 | -------------------------------------------------------------------------------- /man/showfile.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{showfile.gds} 2 | \alias{showfile.gds} 3 | \title{Enumerate opened GDS files} 4 | \description{ 5 | Enumerate all opened GDS files 6 | } 7 | 8 | \usage{ 9 | showfile.gds(closeall=FALSE, verbose=TRUE) 10 | } 11 | \arguments{ 12 | \item{closeall}{if \code{TRUE}, close all GDS files} 13 | \item{verbose}{if \code{TRUE}, show information} 14 | } 15 | \value{ 16 | A \code{data.frame} with the columns "FileName", "ReadOnly" and "State", 17 | or \code{NULL} if there is no opened gds file. 18 | } 19 | 20 | \author{Xiuwen Zheng} 21 | 22 | \examples{ 23 | # cteate a GDS file 24 | f <- createfn.gds("test.gds") 25 | 26 | add.gdsn(f, "int", val=1:10000) 27 | 28 | showfile.gds() 29 | 30 | showfile.gds(closeall=TRUE) 31 | 32 | 33 | # delete the temporary file 34 | unlink("test.gds", force=TRUE) 35 | } 36 | 37 | \keyword{GDS} 38 | \keyword{utilities} 39 | -------------------------------------------------------------------------------- /man/unload.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{unload.gdsn} 2 | \alias{unload.gdsn} 3 | \title{Unload a GDS node} 4 | \description{ 5 | Unload a specified GDS node. 6 | } 7 | 8 | \usage{ 9 | unload.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | } 14 | \value{ 15 | None. 16 | } 17 | 18 | \author{Xiuwen Zheng} 19 | \seealso{ 20 | \code{\link{delete.gdsn}} 21 | } 22 | 23 | \examples{ 24 | # cteate a GDS file 25 | f <- createfn.gds("test.gds") 26 | 27 | # add a list to "test.gds" 28 | node <- add.gdsn(f, "val", 1:1000) 29 | node 30 | 31 | \dontrun{ 32 | unload.gdsn(node) 33 | node # Error: Invalid GDS node object (it was unloaded or deleted). 34 | } 35 | 36 | index.gdsn(f, "val") 37 | 38 | # close the GDS file 39 | closefn.gds(f) 40 | 41 | # delete the temporary file 42 | unlink("test.gds", force=TRUE) 43 | } 44 | 45 | \keyword{GDS} 46 | \keyword{utilities} 47 | -------------------------------------------------------------------------------- /man/rename.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{rename.gdsn} 2 | \alias{rename.gdsn} 3 | \title{Rename a GDS node} 4 | \description{ 5 | Rename a GDS node. 6 | } 7 | 8 | \usage{ 9 | rename.gdsn(node, newname) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{newname}{the new name of a specified node} 14 | } 15 | \details{ 16 | CoreArray hierarchical structure does not allow duplicate names in the 17 | same folder. 18 | } 19 | \value{ 20 | None. 21 | } 22 | 23 | \author{Xiuwen Zheng} 24 | \seealso{ 25 | \code{\link{name.gdsn}}, \code{\link{ls.gdsn}}, 26 | \code{\link[gdsfmt]{index.gdsn}} 27 | } 28 | 29 | \examples{ 30 | # cteate a GDS file 31 | f <- createfn.gds("test.gds") 32 | n <- add.gdsn(f, "old.name", val=1:10) 33 | f 34 | 35 | rename.gdsn(n, "new.name") 36 | f 37 | 38 | # close the GDS file 39 | closefn.gds(f) 40 | 41 | 42 | # delete the temporary file 43 | unlink("test.gds", force=TRUE) 44 | } 45 | 46 | \keyword{GDS} 47 | \keyword{utilities} 48 | -------------------------------------------------------------------------------- /inst/unitTests/test_05_attribute.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: test data dimension 4 | # 5 | 6 | library(RUnit) 7 | library(gdsfmt) 8 | 9 | 10 | ############################################################# 11 | # 12 | # test functions 13 | # 14 | 15 | test.data.attribute <- function() 16 | { 17 | on.exit({ 18 | showfile.gds(closeall=TRUE, verbose=FALSE) 19 | unlink("tmp.gds", force=TRUE) 20 | }) 21 | 22 | # create a new gds file 23 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 24 | 25 | # add a NULL node 26 | node <- add.gdsn(gfile, "data", val=NULL) 27 | 28 | # attribute list 29 | put.attr.gdsn(node, "a") 30 | put.attr.gdsn(node, "x", "string") 31 | put.attr.gdsn(node, "y", 1L) 32 | put.attr.gdsn(node, "z", 1.5) 33 | 34 | # get its attributes 35 | # check 36 | val <- list(a=NULL, x="string", y=as.integer(1), z=as.double(1.5)) 37 | 38 | checkEquals(get.attr.gdsn(node), val, "data.attribute") 39 | 40 | # close the gds file 41 | closefn.gds(gfile) 42 | } 43 | -------------------------------------------------------------------------------- /man/exist.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{exist.gdsn} 2 | \alias{exist.gdsn} 3 | \title{Return whether the path exists or not} 4 | \description{ 5 | Get a logical vector to show whether the path exists or not. 6 | } 7 | 8 | \usage{ 9 | exist.gdsn(node, path) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{path}{the path(s) specifying a GDS node with '/' as a separator} 14 | } 15 | \value{ 16 | A logical vector. 17 | } 18 | 19 | \author{Xiuwen Zheng} 20 | \seealso{ 21 | \code{\link{ls.gdsn}}, \code{\link{index.gdsn}} 22 | } 23 | 24 | \examples{ 25 | # cteate a GDS file 26 | f <- createfn.gds("test.gds") 27 | 28 | # add a list to "test.gds" 29 | node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE)) 30 | ls.gdsn(node) 31 | # "x" "y" "z" 32 | 33 | exist.gdsn(f, c("list", "list/z", "wuw/dj")) 34 | 35 | # close the GDS file 36 | closefn.gds(f) 37 | 38 | 39 | # delete the temporary file 40 | unlink("test.gds", force=TRUE) 41 | } 42 | 43 | \keyword{GDS} 44 | \keyword{utilities} 45 | -------------------------------------------------------------------------------- /man/delete.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{delete.gdsn} 2 | \alias{delete.gdsn} 3 | \title{Delete a GDS node} 4 | \description{ 5 | Delete a specified GDS node. 6 | } 7 | 8 | \usage{ 9 | delete.gdsn(node, force=FALSE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{force}{if \code{FALSE}, it is not allowed to delete a non-empty 14 | folder} 15 | } 16 | \value{ 17 | None. 18 | } 19 | 20 | \author{Xiuwen Zheng} 21 | \seealso{ 22 | \code{\link{add.gdsn}} 23 | } 24 | 25 | \examples{ 26 | # cteate a GDS file 27 | f <- createfn.gds("test.gds") 28 | 29 | # add a list to "test.gds" 30 | node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE)) 31 | f 32 | 33 | \dontrun{ 34 | # delete "node", but an error occurs 35 | delete.gdsn(node) 36 | } 37 | 38 | # delete "node" 39 | delete.gdsn(node, TRUE) 40 | 41 | # close the GDS file 42 | closefn.gds(f) 43 | 44 | 45 | # delete the temporary file 46 | unlink("test.gds", force=TRUE) 47 | } 48 | 49 | \keyword{GDS} 50 | \keyword{utilities} 51 | -------------------------------------------------------------------------------- /man/is.sparse.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{is.sparse.gdsn} 2 | \alias{is.sparse.gdsn} 3 | \title{whether a sparse array or not} 4 | \description{ 5 | Determine whether the node is a sparse array or not. 6 | } 7 | 8 | \usage{ 9 | is.sparse.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}} (a GDS node)} 13 | } 14 | \value{ 15 | TRUE / FALSE. 16 | } 17 | 18 | \author{Xiuwen Zheng} 19 | \seealso{ 20 | \code{\link{add.gdsn}} 21 | } 22 | 23 | \examples{ 24 | # cteate a GDS file 25 | f <- createfn.gds("test.gds") 26 | 27 | cnt <- matrix(0, nrow=4, ncol=8) 28 | set.seed(100) 29 | cnt[sample.int(length(cnt), 8)] <- rpois(8, 4) 30 | cnt 31 | 32 | add.gdsn(f, "mat", val=cnt) 33 | add.gdsn(f, "sp.mat", val=cnt, storage="sp.real") 34 | f 35 | 36 | is.sparse.gdsn(index.gdsn(f, "mat")) 37 | is.sparse.gdsn(index.gdsn(f, "sp.mat")) 38 | 39 | read.gdsn(index.gdsn(f, "sp.mat")) 40 | 41 | # close the GDS file 42 | closefn.gds(f) 43 | 44 | 45 | # delete the temporary file 46 | unlink("test.gds", force=TRUE) 47 | } 48 | 49 | \keyword{GDS} 50 | \keyword{utilities} 51 | -------------------------------------------------------------------------------- /man/system.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{system.gds} 2 | \alias{system.gds} 3 | \title{Get the parameters in the GDS system} 4 | \description{ 5 | Get a list of parameters in the GDS system 6 | } 7 | 8 | \usage{ 9 | system.gds() 10 | } 11 | \value{ 12 | A list including 13 | \item{num.logical.core}{the number of logical cores} 14 | \item{l1i.cache.size}{L1 instruction cache} 15 | \item{l1d.cache.size}{L1 data cache} 16 | \item{l2.cache.size}{L2 data cache} 17 | \item{l3.cache.size}{L3 data cache} 18 | \item{l4.cache.size}{L4 data cache if applicable} 19 | \item{compression.encoder}{compression/decompression algorithms} 20 | \item{compiler}{information of compiler} 21 | \item{compiler.flag}{SIMD instructions supported by the compiler} 22 | \item{class.list}{class list in the GDS system} 23 | \item{options}{list all options associated with GDS format or package, 24 | including gds.crayon(FALSE for no stylish terminal output), 25 | gds.parallel and gds.verbose} 26 | } 27 | 28 | \author{Xiuwen Zheng} 29 | \examples{ 30 | system.gds() 31 | } 32 | 33 | \keyword{GDS} 34 | \keyword{utilities} 35 | -------------------------------------------------------------------------------- /man/delete.attr.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{delete.attr.gdsn} 2 | \alias{delete.attr.gdsn} 3 | \title{Delete attribute(s)} 4 | \description{ 5 | Remove the attribute(s) of a GDS node. 6 | } 7 | 8 | \usage{ 9 | delete.attr.gdsn(node, name) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{name}{the name(s) of an attribute} 14 | } 15 | \value{ 16 | None. 17 | } 18 | 19 | \author{Xiuwen Zheng} 20 | \seealso{ 21 | \code{\link{put.attr.gdsn}}, \code{\link{get.attr.gdsn}} 22 | } 23 | 24 | \examples{ 25 | # cteate a GDS file 26 | f <- createfn.gds("test.gds") 27 | 28 | node <- add.gdsn(f, "int", val=1:10000) 29 | put.attr.gdsn(node, "missing.value", 10000) 30 | put.attr.gdsn(node, "one.value", 1L) 31 | put.attr.gdsn(node, "string", c("ABCDEF", "THIS")) 32 | put.attr.gdsn(node, "bool", c(TRUE, TRUE, FALSE)) 33 | 34 | f 35 | get.attr.gdsn(node) 36 | 37 | delete.attr.gdsn(node, c("one.value", "bool")) 38 | get.attr.gdsn(node) 39 | 40 | # close the GDS file 41 | closefn.gds(f) 42 | 43 | 44 | # delete the temporary file 45 | unlink("test.gds", force=TRUE) 46 | } 47 | 48 | \keyword{GDS} 49 | \keyword{utilities} 50 | -------------------------------------------------------------------------------- /man/name.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{name.gdsn} 2 | \alias{name.gdsn} 3 | \title{Return the variable name of a node} 4 | \description{ 5 | Get the variable name of a GDS node. 6 | } 7 | 8 | \usage{ 9 | name.gdsn(node, fullname=FALSE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{fullname}{if \code{FALSE}, return the node name (by default); 14 | otherwise the name with a full path} 15 | } 16 | \value{ 17 | Characters. 18 | } 19 | 20 | \author{Xiuwen Zheng} 21 | \seealso{ 22 | \code{\link{cnt.gdsn}}, \code{\link{objdesp.gdsn}}, 23 | \code{\link{ls.gdsn}}, \code{\link{rename.gdsn}} 24 | } 25 | 26 | \examples{ 27 | # cteate a GDS file 28 | f <- createfn.gds("test.gds") 29 | 30 | # add a list to "test.gds" 31 | add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE)) 32 | node <- index.gdsn(f, "list/x") 33 | 34 | name.gdsn(node) 35 | # "x" 36 | 37 | name.gdsn(node, fullname=TRUE) 38 | # "list/x" 39 | 40 | # close the GDS file 41 | closefn.gds(f) 42 | 43 | 44 | # delete the temporary file 45 | unlink("test.gds", force=TRUE) 46 | } 47 | 48 | \keyword{GDS} 49 | \keyword{utilities} 50 | -------------------------------------------------------------------------------- /man/closefn.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{closefn.gds} 2 | \alias{closefn.gds} 3 | \title{Close a GDS file} 4 | \description{ 5 | Close a CoreArray Genomic Data Structure (GDS) file. 6 | } 7 | 8 | \usage{ 9 | closefn.gds(gdsfile) 10 | } 11 | \arguments{ 12 | \item{gdsfile}{an object of class \code{\link{gds.class}}, a GDS file} 13 | } 14 | \details{ 15 | For better performance, data in a GDS file are usually cached in memory. 16 | Keep in mind that the new file may not actually be written to disk, until 17 | \code{\link{closefn.gds}} or \code{\link{sync.gds}} is called. Anyway, when 18 | R shuts down, all GDS files created or opened would be automatically closed. 19 | } 20 | \value{ 21 | None. 22 | } 23 | 24 | \author{Xiuwen Zheng} 25 | \seealso{ 26 | \code{\link{createfn.gds}}, \code{\link{openfn.gds}}, 27 | \code{\link{sync.gds}} 28 | } 29 | 30 | \examples{ 31 | # cteate a GDS file 32 | f <- createfn.gds("test.gds") 33 | 34 | add.gdsn(f, "int.matrix", matrix(1:50*100, nrow=100, ncol=50)) 35 | 36 | # close the GDS file 37 | closefn.gds(f) 38 | 39 | # delete the temporary file 40 | unlink("test.gds", force=TRUE) 41 | } 42 | 43 | \keyword{GDS} 44 | \keyword{utilities} 45 | -------------------------------------------------------------------------------- /man/cnt.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{cnt.gdsn} 2 | \alias{cnt.gdsn} 3 | \title{Return the number of child nodes} 4 | \description{ 5 | Return the number of child nodes for a GDS node. 6 | } 7 | 8 | \usage{ 9 | cnt.gdsn(node, include.hidden=FALSE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{include.hidden}{whether including hidden variables or folders} 14 | } 15 | \value{ 16 | If \code{node} is a folder, return the numbers of variables in the folder 17 | including child folders. Otherwise, return 0. 18 | } 19 | 20 | \author{Xiuwen Zheng} 21 | \seealso{ 22 | \code{\link{objdesp.gdsn}}, \code{\link{ls.gdsn}}, 23 | \code{\link{index.gdsn}}, \code{\link{delete.gdsn}}, 24 | \code{\link{add.gdsn}} 25 | } 26 | 27 | \examples{ 28 | # cteate a GDS file 29 | f <- createfn.gds("test.gds") 30 | 31 | # add a list to "test.gds" 32 | node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE)) 33 | cnt.gdsn(node) 34 | # 3 35 | 36 | # close the GDS file 37 | closefn.gds(f) 38 | 39 | 40 | # delete the temporary file 41 | unlink("test.gds", force=TRUE) 42 | } 43 | 44 | \keyword{GDS} 45 | \keyword{utilities} 46 | -------------------------------------------------------------------------------- /man/getfolder.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{getfolder.gdsn} 2 | \alias{getfolder.gdsn} 3 | \title{Get the folder} 4 | \description{ 5 | Get the folder which contains the specified GDS node. 6 | } 7 | 8 | \usage{ 9 | getfolder.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}} 13 | } 14 | \value{ 15 | An object of class \code{\link{gdsn.class}}. 16 | } 17 | 18 | \author{Xiuwen Zheng} 19 | \seealso{ 20 | \code{\link{index.gdsn}} 21 | } 22 | 23 | \examples{ 24 | # cteate a GDS file 25 | f <- createfn.gds("test.gds") 26 | 27 | add.gdsn(f, "label", NULL) 28 | add.gdsn(f, "double", seq(1, 1000, 0.4)) 29 | add.gdsn(f, "list", list(X=1:10, Y=seq(1, 10, 0.25))) 30 | add.gdsn(f, "data.frame", data.frame(X=1:19, Y=seq(1, 10, 0.5))) 31 | 32 | f 33 | 34 | getfolder.gdsn(index.gdsn(f, "label")) 35 | getfolder.gdsn(index.gdsn(f, "double")) 36 | getfolder.gdsn(index.gdsn(f, "list/X")) 37 | getfolder.gdsn(index.gdsn(f, "data.frame/Y")) 38 | 39 | getfolder.gdsn(f$root) 40 | 41 | 42 | # close the GDS file 43 | closefn.gds(f) 44 | 45 | 46 | # delete the temporary file 47 | unlink("test.gds", force=TRUE) 48 | } 49 | 50 | \keyword{GDS} 51 | \keyword{utilities} 52 | -------------------------------------------------------------------------------- /man/summarize.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{summarize.gdsn} 2 | \alias{summarize.gdsn} 3 | \title{GDS object Summaries} 4 | \description{ 5 | Get the summaries of a GDS node. 6 | } 7 | 8 | \usage{ 9 | summarize.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | } 14 | \value{ 15 | A list including 16 | \item{min}{the minimum value} 17 | \item{max}{the maximum value} 18 | \item{num_na}{the number of invalid numbers or NA} 19 | \item{decimal}{the count of each decimal (integer, 0.1, 0.01, ..., or 20 | other)} 21 | } 22 | 23 | \author{Xiuwen Zheng} 24 | 25 | \examples{ 26 | # cteate a GDS file 27 | f <- createfn.gds("test.gds") 28 | 29 | n1 <- add.gdsn(f, "x", seq(1, 10, 0.1), storage="float") 30 | n2 <- add.gdsn(f, "y", seq(1, 10, 0.1), storage="double") 31 | n3 <- add.gdsn(f, "int", c(1:100, NA, 112, NA), storage="int") 32 | n4 <- add.gdsn(f, "int8", c(1:100, NA, 112, NA), storage="int8") 33 | 34 | summarize.gdsn(n1) 35 | summarize.gdsn(n2) 36 | summarize.gdsn(n3) 37 | summarize.gdsn(n4) 38 | 39 | # close the file 40 | closefn.gds(f) 41 | 42 | # delete the temporary file 43 | unlink("test.gds", force=TRUE) 44 | } 45 | 46 | \keyword{GDS} 47 | \keyword{utilities} 48 | -------------------------------------------------------------------------------- /man/sync.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{sync.gds} 2 | \alias{sync.gds} 3 | \title{Synchronize a GDS file} 4 | \description{ 5 | Write the data cached in memory to disk. 6 | } 7 | 8 | \usage{ 9 | sync.gds(gdsfile) 10 | } 11 | \arguments{ 12 | \item{gdsfile}{An object of class \code{\link{gds.class}}, a GDS file} 13 | } 14 | \details{ 15 | For better performance, Data in a GDS file are usually cached in memory. 16 | Keep in mind that the new file may not actually be written to disk, until 17 | \code{\link{closefn.gds}} or \code{\link{sync.gds}} is called. Anyway, when 18 | R shuts down, all GDS files created or opened would be automatically closed. 19 | } 20 | \value{ 21 | None. 22 | } 23 | 24 | \author{Xiuwen Zheng} 25 | \seealso{ 26 | \code{\link{createfn.gds}}, \code{\link{openfn.gds}} 27 | } 28 | 29 | \examples{ 30 | options(gds.verbose=TRUE) 31 | 32 | # cteate a GDS file 33 | f <- createfn.gds("test.gds") 34 | 35 | node <- add.gdsn(f, "int", val=1:10000) 36 | put.attr.gdsn(node, "missing.value", 10000) 37 | f 38 | 39 | sync.gds(f) 40 | 41 | get.attr.gdsn(node) 42 | 43 | # close the GDS file 44 | closefn.gds(f) 45 | 46 | 47 | # delete the temporary file 48 | unlink("test.gds", force=TRUE) 49 | } 50 | 51 | \keyword{GDS} 52 | \keyword{utilities} 53 | -------------------------------------------------------------------------------- /man/getfile.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{getfile.gdsn} 2 | \alias{getfile.gdsn} 3 | \title{Output a file from a stream container} 4 | \description{ 5 | Get a file from a GDS node of stream container. 6 | } 7 | 8 | \usage{ 9 | getfile.gdsn(node, out.filename) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{out.filename}{the file name of output stream} 14 | } 15 | \value{ 16 | None. 17 | } 18 | 19 | \author{Xiuwen Zheng} 20 | \seealso{ 21 | \code{\link{addfile.gdsn}} 22 | } 23 | 24 | \examples{ 25 | # save a .RData object 26 | obj <- list(X=1:10, Y=seq(1, 10, 0.1)) 27 | save(obj, file="tmp.RData") 28 | 29 | # cteate a GDS file 30 | f <- createfn.gds("test.gds") 31 | 32 | add.gdsn(f, "double", val=seq(1, 1000, 0.4)) 33 | addfile.gdsn(f, "tmp.RData", "tmp.RData") 34 | 35 | # open the GDS file 36 | closefn.gds(f) 37 | 38 | 39 | # open the existing file 40 | (f <- openfn.gds("test.gds")) 41 | 42 | getfile.gdsn(index.gdsn(f, "tmp.RData"), "tmp1.RData") 43 | (obj <- get(load("tmp1.RData"))) 44 | 45 | # open the GDS file 46 | closefn.gds(f) 47 | 48 | 49 | # delete the temporary files 50 | unlink(c("test.gds", "tmp.RData", "tmp1.RData"), force=TRUE) 51 | } 52 | 53 | \keyword{GDS} 54 | \keyword{utilities} 55 | -------------------------------------------------------------------------------- /man/is.element.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{is.element.gdsn} 2 | \alias{is.element.gdsn} 3 | \title{whether the elements are in a set} 4 | \description{ 5 | Determine whether the elements are in a specified set. 6 | } 7 | 8 | \usage{ 9 | is.element.gdsn(node, set) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}} (a GDS node)} 13 | \item{set}{the specified set of elements} 14 | } 15 | \value{ 16 | A logical vector or array. 17 | } 18 | 19 | \author{Xiuwen Zheng} 20 | \seealso{ 21 | \code{\link{read.gdsn}} 22 | } 23 | 24 | \examples{ 25 | # cteate a GDS file 26 | f <- createfn.gds("test.gds") 27 | 28 | add.gdsn(f, "int", val=1:100) 29 | add.gdsn(f, "mat", val=matrix(1:12, nrow=4, ncol=3)) 30 | add.gdsn(f, "double", val=seq(1, 10, 0.1)) 31 | add.gdsn(f, "character", val=c("int", "double", "logical", "factor")) 32 | 33 | is.element.gdsn(index.gdsn(f, "int"), c(1, 10, 20)) 34 | is.element.gdsn(index.gdsn(f, "mat"), c(2, 8, 12)) 35 | is.element.gdsn(index.gdsn(f, "double"), c(1.1, 1.3, 1.5)) 36 | is.element.gdsn(index.gdsn(f, "character"), c("int", "factor")) 37 | 38 | # close the GDS file 39 | closefn.gds(f) 40 | 41 | 42 | # delete the temporary file 43 | unlink("test.gds", force=TRUE) 44 | } 45 | 46 | \keyword{GDS} 47 | \keyword{utilities} 48 | -------------------------------------------------------------------------------- /man/cleanup.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{cleanup.gds} 2 | \alias{cleanup.gds} 3 | \title{Clean up fragments} 4 | \description{ 5 | Clean up the fragments of a CoreArray Genomic Data Structure (GDS) file. 6 | } 7 | 8 | \usage{ 9 | cleanup.gds(filename, verbose=TRUE) 10 | } 11 | \arguments{ 12 | \item{filename}{the file name of a GDS file to be opened} 13 | \item{verbose}{if \code{TRUE}, show information} 14 | } 15 | \value{ 16 | None. 17 | } 18 | 19 | \author{Xiuwen Zheng} 20 | \seealso{ 21 | \code{\link{openfn.gds}}, \code{\link{createfn.gds}}, 22 | \code{\link{closefn.gds}} 23 | } 24 | 25 | \examples{ 26 | # cteate a GDS file 27 | f <- createfn.gds("test.gds") 28 | 29 | # commom types 30 | add.gdsn(f, "int", val=1:10000) 31 | L <- -2500:2499 32 | add.gdsn(f, "int.matrix", val=matrix(L, nrow=100, ncol=50)) 33 | 34 | # save a .RData object 35 | obj <- list(X=1:10, Y=seq(1, 10, 0.1)) 36 | save(obj, file="tmp.RData") 37 | addfile.gdsn(f, "tmp.RData", filename="tmp.RData") 38 | 39 | f 40 | 41 | # close the GDS file 42 | closefn.gds(f) 43 | 44 | 45 | # clean up fragments 46 | cleanup.gds("test.gds") 47 | 48 | 49 | # open ... 50 | (f <- openfn.gds("test.gds")) 51 | closefn.gds(f) 52 | 53 | 54 | # delete the temporary file 55 | unlink("test.gds", force=TRUE) 56 | } 57 | 58 | \keyword{GDS} 59 | \keyword{utilities} 60 | -------------------------------------------------------------------------------- /man/copyto.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{copyto.gdsn} 2 | \alias{copyto.gdsn} 3 | \title{Copy GDS nodes} 4 | \description{ 5 | Copy GDS node(s) to a folder with a new name 6 | } 7 | 8 | \usage{ 9 | copyto.gdsn(node, source, name=NULL) 10 | } 11 | \arguments{ 12 | \item{node}{a folder of class \code{\link{gdsn.class}} or 13 | \code{\link{gds.class}}} 14 | \item{source}{an object of class \code{\link{gdsn.class}} or 15 | \code{\link{gds.class}}} 16 | \item{name}{a specified name; if \code{NULL}, it is determined by 17 | \code{source}} 18 | } 19 | \value{ 20 | None. 21 | } 22 | 23 | \author{Xiuwen Zheng} 24 | \seealso{ 25 | \code{\link{moveto.gdsn}} 26 | } 27 | \examples{ 28 | # cteate a GDS file 29 | f <- createfn.gds("test.gds") 30 | 31 | add.gdsn(f, "label", NULL) 32 | add.gdsn(f, "int", 1:100, compress="ZIP", closezip=TRUE) 33 | add.gdsn(f, "int.matrix", matrix(1:100, nrow=20)) 34 | addfolder.gdsn(f, "folder1") 35 | addfolder.gdsn(f, "folder2") 36 | 37 | 38 | for (nm in c("label", "int", "int.matrix")) 39 | copyto.gdsn(index.gdsn(f, "folder1"), index.gdsn(f, nm)) 40 | f 41 | 42 | copyto.gdsn(index.gdsn(f, "folder2"), index.gdsn(f, "folder1")) 43 | f 44 | 45 | # close the GDS file 46 | closefn.gds(f) 47 | 48 | 49 | # delete the temporary file 50 | unlink("test.gds", force=TRUE) 51 | } 52 | 53 | \keyword{GDS} 54 | \keyword{utilities} 55 | -------------------------------------------------------------------------------- /src/LZ4/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | LZ4 Library 3 | Copyright (c) 2011-2016, Yann Collet 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, this 13 | list of conditions and the following disclaimer in the documentation and/or 14 | other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /man/cache.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{cache.gdsn} 2 | \alias{cache.gdsn} 3 | \title{Caching variable data} 4 | \description{ 5 | Caching the data associated with a GDS variable 6 | } 7 | 8 | \usage{ 9 | cache.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | } 14 | \details{ 15 | If random access of array-based data is required, it is possible to 16 | speed up the access time by caching data in memory. This function tries to 17 | force the operating system to cache the data associated with the GDS node, 18 | however how to cache data depends on the configuration of operating system, 19 | including system memory and caching strategy. Note that this function does 20 | not explicitly allocate memory for the data. 21 | 22 | If the data has been compressed, caching strategy almost has no effect 23 | on random access, since the data has to be decompressed serially. 24 | } 25 | \value{ 26 | None. 27 | } 28 | 29 | \author{Xiuwen Zheng} 30 | \seealso{ 31 | \code{\link{read.gdsn}} 32 | } 33 | 34 | \examples{ 35 | # cteate a GDS file 36 | f <- createfn.gds("test.gds") 37 | 38 | n <- add.gdsn(f, "int.matrix", matrix(1:50*100, nrow=100, ncol=50)) 39 | n 40 | 41 | cache.gdsn(n) 42 | 43 | # close the GDS file 44 | closefn.gds(f) 45 | 46 | # delete the temporary file 47 | unlink("test.gds", force=TRUE) 48 | } 49 | 50 | \keyword{GDS} 51 | \keyword{utilities} 52 | -------------------------------------------------------------------------------- /.github/workflows/r.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # 6 | # See https://github.com/r-lib/actions/tree/master/examples#readme for 7 | # additional example workflows available for the R community. 8 | 9 | name: R 10 | 11 | on: 12 | push: 13 | branches: [ "master" ] 14 | pull_request: 15 | branches: [ "master" ] 16 | 17 | permissions: 18 | contents: read 19 | 20 | jobs: 21 | build: 22 | runs-on: ${{ matrix.config.os }} 23 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 24 | strategy: 25 | matrix: 26 | config: 27 | - {os: macOS-latest, r: 'release'} 28 | - {os: windows-latest, r: 'release'} 29 | 30 | steps: 31 | - uses: actions/checkout@v3 32 | - name: Set up R ${{ matrix.config.r }} 33 | uses: r-lib/actions/setup-r@f57f1301a053485946083d7a45022b278929a78a 34 | with: 35 | r-version: ${{ matrix.config.r }} 36 | - name: Install dependencies 37 | run: | 38 | install.packages(c("remotes", "rcmdcheck")) 39 | remotes::install_deps(dependencies = TRUE) 40 | shell: Rscript {0} 41 | - name: Check 42 | run: rcmdcheck::rcmdcheck(args=c("--no-manual", "--no-build-vignettes"), build_args=c("--no-manual", "--no-build-vignettes"), error_on="error") 43 | shell: Rscript {0} 44 | -------------------------------------------------------------------------------- /man/ls.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{ls.gdsn} 2 | \alias{ls.gdsn} 3 | \title{Return the names of child nodes} 4 | \description{ 5 | Get a list of names for its child nodes. 6 | } 7 | 8 | \usage{ 9 | ls.gdsn(node, include.hidden=FALSE, recursive=FALSE, include.dirs=TRUE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{include.hidden}{whether including hidden variables or folders} 14 | \item{recursive}{whether the listing recurses into directories or not} 15 | \item{include.dirs}{whether subdirectory names should be included in 16 | recursive listings} 17 | } 18 | \value{ 19 | A vector of characters, or \code{character(0)} if \code{node} is not a 20 | folder. 21 | } 22 | 23 | \author{Xiuwen Zheng} 24 | \seealso{ 25 | \code{\link{cnt.gdsn}}, \code{\link{objdesp.gdsn}}, 26 | \code{\link{ls.gdsn}}, \code{\link{index.gdsn}} 27 | } 28 | 29 | \examples{ 30 | # cteate a GDS file 31 | f <- createfn.gds("test.gds") 32 | 33 | # add a list to "test.gds" 34 | node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE)) 35 | ls.gdsn(node) 36 | # "x" "y" "z" 37 | 38 | ls.gdsn(f$root) 39 | # "list" 40 | 41 | ls.gdsn(f$root, recursive=TRUE) 42 | # "list" "list/x" "list/y" "list/z" 43 | 44 | ls.gdsn(f$root, recursive=TRUE, include.dirs=FALSE) 45 | # "list/x" "list/y" "list/z" 46 | 47 | # close the GDS file 48 | closefn.gds(f) 49 | 50 | 51 | # delete the temporary file 52 | unlink("test.gds", force=TRUE) 53 | } 54 | 55 | \keyword{GDS} 56 | \keyword{utilities} 57 | -------------------------------------------------------------------------------- /src/CoreArray/dParallel_Ext.c: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // dParallel_Ext.c: Call the user-defined function 10 | // 11 | // Copyright (C) 2014-2017 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | 29 | #include "CoreDEF.h" 30 | 31 | 32 | // to avoid UBSAN fails (-fsanitize=function) 33 | COREARRAY_DLL_LOCAL void COREARRAY_Parallel_Call( 34 | void (*Proc)(void*, int, void*), void *thread, int i_thread, void *param) 35 | { 36 | (*Proc)(thread, i_thread, param); 37 | } 38 | -------------------------------------------------------------------------------- /man/readmode.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{readmode.gdsn} 2 | \alias{readmode.gdsn} 3 | \title{Switch to read mode in the compression settings} 4 | \description{ 5 | Switch to read mode for a GDS node with respect to its compression 6 | settings. 7 | } 8 | 9 | \usage{ 10 | readmode.gdsn(node) 11 | } 12 | \arguments{ 13 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 14 | } 15 | \details{ 16 | After the compressed data field is created, it is in writing mode. 17 | Users can add new data to the compressed data field, but can not read data 18 | from the data field. Users have to call \code{readmode.gdsn} to finish 19 | writing, before reading any data from the compressed data field. 20 | 21 | Once switch to the read mode, users can not add more data to the data 22 | field. If users would like to append more data or modify the data field, 23 | please call \code{compression.gdsn(node, compress="")} to decompress data 24 | first. 25 | } 26 | \value{ 27 | Return \code{node}. 28 | } 29 | 30 | \author{Xiuwen Zheng} 31 | \seealso{ 32 | \code{\link{compression.gdsn}}, \code{\link{add.gdsn}} 33 | } 34 | 35 | \examples{ 36 | # cteate a GDS file 37 | f <- createfn.gds("test.gds") 38 | 39 | # commom types 40 | n <- add.gdsn(f, "int", val=1:100, compress="ZIP") 41 | 42 | # you can not read the variable "int" because of writing mode 43 | # read.gdsn(n) 44 | 45 | readmode.gdsn(n) 46 | 47 | # now you can read "int" 48 | read.gdsn(n) 49 | 50 | # close the GDS file 51 | closefn.gds(f) 52 | 53 | 54 | # delete the temporary file 55 | unlink("test.gds", force=TRUE) 56 | } 57 | 58 | \keyword{GDS} 59 | \keyword{utilities} 60 | -------------------------------------------------------------------------------- /man/createfn.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{createfn.gds} 2 | \alias{createfn.gds} 3 | \title{Create a GDS file} 4 | \description{ 5 | Create a new CoreArray Genomic Data Structure (GDS) file. 6 | } 7 | 8 | \usage{ 9 | createfn.gds(filename, allow.duplicate=FALSE, use.abspath=TRUE) 10 | } 11 | \arguments{ 12 | \item{filename}{the file name of a new GDS file to be created} 13 | \item{allow.duplicate}{if \code{TRUE}, it is allowed to open a GDS file 14 | with read-only mode when it has been opened in the same R session} 15 | \item{use.abspath}{if \code{TRUE}, 'filename' of the gds.class object is 16 | set to be the absolute path} 17 | } 18 | \details{ 19 | Keep in mind that the new file may not actually be written to disk until 20 | \code{\link{closefn.gds}} or \code{\link{sync.gds}} is called. 21 | } 22 | \value{ 23 | Return an object of class \code{\link{gds.class}}: 24 | \item{filename}{the file name to be created} 25 | \item{id}{internal file id} 26 | \item{root}{an object of class \code{\link{gdsn.class}}, 27 | the root of hierachical structure} 28 | \item{readonly}{whether it is read-only or not} 29 | } 30 | 31 | \author{Xiuwen Zheng} 32 | \seealso{ 33 | \code{\link{openfn.gds}}, \code{\link{closefn.gds}} 34 | } 35 | 36 | \examples{ 37 | # cteate a GDS file 38 | f <- createfn.gds("test.gds") 39 | 40 | # add a list to "test.gds" 41 | node <- add.gdsn(f, val=list(x=c(1,2), y=c("T", "B", "C"), z=TRUE)) 42 | 43 | f 44 | 45 | # close the GDS file 46 | closefn.gds(f) 47 | 48 | 49 | # delete the temporary file 50 | unlink("test.gds", force=TRUE) 51 | } 52 | 53 | \keyword{GDS} 54 | \keyword{utilities} 55 | -------------------------------------------------------------------------------- /man/put.attr.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{put.attr.gdsn} 2 | \alias{put.attr.gdsn} 3 | \title{Add an attribute into a GDS node} 4 | \description{ 5 | Add an attribute to a GDS node. 6 | } 7 | 8 | \usage{ 9 | put.attr.gdsn(node, name, val=NULL) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{name}{the name of an attribute} 14 | \item{val}{the value of an attribute, or a \code{\link{gdsn.class}} object} 15 | } 16 | 17 | \details{ 18 | Missing values are allowed in a numerical attribute, but not allowed for 19 | characters or logical values. Missing characters are converted to \code{"NA"}, 20 | and missing logical values are converted to \code{FALSE}. 21 | 22 | If \code{val} is a \code{\link{gdsn.class}} object, copy all attributes 23 | to \code{node}. 24 | } 25 | 26 | \value{ 27 | None. 28 | } 29 | 30 | \author{Xiuwen Zheng} 31 | \seealso{ 32 | \code{\link{get.attr.gdsn}}, \code{\link{delete.attr.gdsn}} 33 | } 34 | 35 | \examples{ 36 | # cteate a GDS file 37 | f <- createfn.gds("test.gds") 38 | 39 | node <- add.gdsn(f, "int", val=1:10000) 40 | put.attr.gdsn(node, "missing.value", 10000) 41 | put.attr.gdsn(node, "one.value", 1L) 42 | put.attr.gdsn(node, "string", c("ABCDEF", "THIS", paste(letters, collapse=""))) 43 | put.attr.gdsn(node, "bool", c(TRUE, TRUE, FALSE)) 44 | 45 | f 46 | get.attr.gdsn(node) 47 | 48 | delete.attr.gdsn(node, "one.value") 49 | get.attr.gdsn(node) 50 | 51 | 52 | node2 <- add.gdsn(f, "char", val=letters) 53 | get.attr.gdsn(node2) 54 | put.attr.gdsn(node2, val=node) 55 | get.attr.gdsn(node2) 56 | 57 | 58 | # close the GDS file 59 | closefn.gds(f) 60 | 61 | # delete the temporary file 62 | unlink("test.gds", force=TRUE) 63 | } 64 | 65 | \keyword{GDS} 66 | \keyword{utilities} 67 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite gdsfmt in publications use:") 2 | 3 | citEntry(entry="Article", 4 | title = "A High-performance Computing Toolset for Relatedness and Principal Component Analysis of SNP Data", 5 | author = personList(person("Xiuwen", "Zheng"), person("David", "Levine"), 6 | person("Jess", "Shen"), person("Stephanie", "Gogarten"), 7 | person("Cathy", "Laurie"), person("Bruce", "Weir")), 8 | journal = "Bioinformatics", 9 | year = "2012", 10 | doi = "10.1093/bioinformatics/bts606", 11 | volume = "28", 12 | number = "24", 13 | pages = "3326-3328", 14 | textVersion = 15 | paste("Xiuwen Zheng, David Levine, Jess Shen, Stephanie M. Gogarten, Cathy Laurie, Bruce S. Weir.", 16 | "A High-performance Computing Toolset for Relatedness and Principal Component Analysis of SNP Data.", 17 | "Bioinformatics 2012; doi: 10.1093/bioinformatics/bts606") 18 | ) 19 | 20 | citEntry(entry="Article", 21 | title = "SeqArray -- A storage-efficient high-performance data format for WGS variant calls", 22 | author = personList(person("Xiuwen", "Zheng"), person("Stephanie", "Gogarten"), 23 | person("Michael", "Lawrence"), person("Adrienne", "Stilp"), person("Matthew", "Conomos"), 24 | person("Bruce", "Weir"), person("Cathy", "Laurie"), person("David", "Levine")), 25 | journal = "Bioinformatics", 26 | year = "2017", 27 | doi = "10.1093/bioinformatics/btx145", 28 | textVersion = 29 | paste("Xiuwen Zheng, Stephanie M. Gogarten, Michael Lawrence, Adrienne Stilp, Matthew P. Conomos, Bruce S. Weir, Cathy Laurie, David Levine.", 30 | "SeqArray -- A storage-efficient high-performance data format for WGS variant calls.", 31 | "Bioinformatics 2017; doi: 10.1093/bioinformatics/btx145") 32 | ) 33 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Load the shared object 2 | useDynLib(gdsfmt, 3 | gdsCreateGDS, gdsOpenGDS, gdsCloseGDS, gdsSyncGDS, gdsTidyUp, 4 | gdsShowFile, gdsDiagInfo, gdsDiagInfo2, gdsNodeChildCnt, gdsNodeName, 5 | gdsRenameNode, gdsNodeEnumName, gdsNodeIndex, gdsNodeObjDesp, 6 | gdsAddNode, gdsAddFolder, gdsAddFile, gdsGetFile, gdsDeleteNode, 7 | gdsPutAttr, gdsPutAttr2, gdsGetAttr, gdsDeleteAttr, gdsObjCompress, 8 | gdsObjCompressClose, gdsObjSetDim, gdsObjAppend, gdsObjAppend2, 9 | gdsObjReadData, gdsObjReadExData, gdsDataFmt, gdsApplySetStart, 10 | gdsApplyCall, gdsApplyCreateSelection, gdsObjWriteAll, gdsObjWriteData, 11 | gdsAssign, gdsCache, gdsMoveTo, gdsCopyTo, gdsIsElement, gdsIsSparse, 12 | gdsLastErrGDS, gdsFileSize, gdsNodeValid, gdsSystem, gdsGetFolder, 13 | gdsDigest, gdsFmtSize, gdsSummary, gdsUnloadNode, gdsReopenGDS, 14 | gdsExistPath, gdsInitPkg 15 | ) 16 | 17 | # Export the following names 18 | export( 19 | add.gdsn, addfile.gdsn, addfolder.gdsn, append.gdsn, apply.gdsn, 20 | assign.gdsn, cache.gdsn, cleanup.gds, closefn.gds, clusterApply.gdsn, 21 | cnt.gdsn, compression.gdsn, copyto.gdsn, createfn.gds, delete.attr.gdsn, 22 | delete.gdsn, diagnosis.gds, digest.gdsn, get.attr.gdsn, getfile.gdsn, 23 | getfolder.gdsn, index.gdsn, is.element.gdsn, is.sparse.gdsn, lasterr.gds, 24 | ls.gdsn, moveto.gdsn, name.gdsn, objdesp.gdsn, openfn.gds, permdim.gdsn, 25 | print.gds.class, print.gdsn.class, put.attr.gdsn, read.gdsn, readex.gdsn, 26 | readmode.gdsn, rename.gdsn, setdim.gdsn, showfile.gds, summarize.gdsn, 27 | sync.gds, system.gds, write.gdsn, unload.gdsn, exist.gdsn 28 | ) 29 | exportMethods(show) 30 | 31 | # Import 32 | import(methods) 33 | importFrom("stats", "runif") 34 | importFrom("utils", "memory.size", "write.table") 35 | 36 | # Registering S3 methods 37 | S3method(print, gds.class) 38 | S3method(print, gdsn.class) 39 | -------------------------------------------------------------------------------- /man/permdim.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{permdim.gdsn} 2 | \alias{permdim.gdsn} 3 | \title{Array Transposition} 4 | \description{ 5 | Transpose an array by permuting its dimensions. 6 | } 7 | 8 | \usage{ 9 | permdim.gdsn(node, dimidx, target=NULL) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{dimidx}{the subscript permutation vector, and it should be a 14 | permutation of the integers '1:n', where 'n' is the number of 15 | dimensions} 16 | \item{target}{if it is not \code{NULL}, the transposed data are saved to 17 | \code{target}} 18 | } 19 | \value{ 20 | None. 21 | } 22 | 23 | \author{Xiuwen Zheng} 24 | \seealso{ 25 | \code{\link{setdim.gdsn}} 26 | } 27 | 28 | \examples{ 29 | # cteate a GDS file 30 | f <- createfn.gds("test.gds") 31 | 32 | (node <- add.gdsn(f, "matrix", val=matrix(1:48, nrow=6), 33 | compress="ZIP", closezip=TRUE)) 34 | read.gdsn(node) 35 | 36 | permdim.gdsn(node, c(2,1)) 37 | read.gdsn(node) 38 | 39 | 40 | (node <- add.gdsn(f, "array", val=array(1:120, dim=c(5,4,3,2)), 41 | compress="ZIP", closezip=TRUE)) 42 | read.gdsn(node) 43 | 44 | mat <- read.gdsn(node) 45 | permdim.gdsn(node, c(1,2,3,4)) 46 | stopifnot(identical(mat, read.gdsn(node))) 47 | 48 | mat <- read.gdsn(node) 49 | permdim.gdsn(node, c(4,2,1,3)) 50 | stopifnot(identical(aperm(mat, c(4,2,1,3)), read.gdsn(node))) 51 | 52 | mat <- read.gdsn(node) 53 | permdim.gdsn(node, c(3,2,4,1)) 54 | stopifnot(identical(aperm(mat, c(3,2,4,1)), read.gdsn(node))) 55 | 56 | mat <- read.gdsn(node) 57 | permdim.gdsn(node, c(2,3,1,4)) 58 | stopifnot(identical(aperm(mat, c(2,3,1,4)), read.gdsn(node))) 59 | 60 | 61 | # close the GDS file 62 | closefn.gds(f) 63 | 64 | # remove unused space after permuting dimensions 65 | cleanup.gds("test.gds") 66 | 67 | 68 | # delete the temporary file 69 | unlink("test.gds", force=TRUE) 70 | } 71 | 72 | \keyword{GDS} 73 | \keyword{utilities} 74 | -------------------------------------------------------------------------------- /man/setdim.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{setdim.gdsn} 2 | \alias{setdim.gdsn} 3 | \title{Set the dimension of data field} 4 | \description{ 5 | Assign new dimensions to the data field of a GDS node. 6 | } 7 | 8 | \usage{ 9 | setdim.gdsn(node, valdim, permute=FALSE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{valdim}{the new dimension(s) for the array to be created, which 14 | is a vector of length one or more giving the maximal indices in 15 | each dimension. The values in data are taken to be those in the array 16 | with the leftmost subscript moving fastest. The last entry could be 17 | ZERO. If the total number of elements is zero, gdsfmt does not allocate 18 | storage space. \code{NA} is treated as 0.} 19 | \item{permute}{if \code{TRUE}, the elements are rearranged to preserve 20 | their relative positions in each dimension of the array} 21 | } 22 | \value{ 23 | Returns \code{node}. 24 | } 25 | 26 | \author{Xiuwen Zheng} 27 | \seealso{ 28 | \code{\link{read.gdsn}}, \code{\link{write.gdsn}}, 29 | \code{\link{add.gdsn}}, \code{\link{append.gdsn}} 30 | } 31 | 32 | \examples{ 33 | # cteate a GDS file 34 | f <- createfn.gds("test.gds") 35 | 36 | n <- add.gdsn(f, "int", val=1:24) 37 | read.gdsn(n) 38 | 39 | setdim.gdsn(n, c(6, 4)) 40 | read.gdsn(n) 41 | 42 | setdim.gdsn(n, c(8, 5), permute=TRUE) 43 | read.gdsn(n) 44 | 45 | setdim.gdsn(n, c(3, 4), permute=TRUE) 46 | read.gdsn(n) 47 | 48 | 49 | n <- add.gdsn(f, "bit3", val=1:24, storage="bit3") 50 | read.gdsn(n) 51 | 52 | setdim.gdsn(n, c(6, 4)) 53 | read.gdsn(n) 54 | 55 | setdim.gdsn(n, c(8, 5), permute=TRUE) 56 | read.gdsn(n) 57 | 58 | setdim.gdsn(n, c(3, 4), permute=TRUE) 59 | read.gdsn(n) 60 | 61 | 62 | # close the GDS file 63 | closefn.gds(f) 64 | 65 | 66 | # delete the temporary file 67 | unlink("test.gds", force=TRUE) 68 | } 69 | 70 | \keyword{GDS} 71 | \keyword{utilities} 72 | -------------------------------------------------------------------------------- /man/index.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{index.gdsn} 2 | \alias{index.gdsn} 3 | \title{Get the specified node} 4 | \description{ 5 | Get a specified GDS node. 6 | } 7 | 8 | \usage{ 9 | index.gdsn(node, path=NULL, index=NULL, silent=FALSE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}} (a GDS node), 13 | or \code{\link{gds.class}} (a GDS file)} 14 | \item{path}{the path specifying a GDS node with '/' as a separator} 15 | \item{index}{a numeric vector or characters, specifying the path; it is 16 | applicable if \code{path=NULL}} 17 | \item{silent}{if \code{TRUE}, return NULL if the specified node 18 | does not exist} 19 | } 20 | \details{ 21 | If \code{index} is a numeric vector, e.g., \code{c(1, 2)}, the result is 22 | the second child node of the first child of \code{node}. If \code{index} is 23 | a vector of characters, e.g., \code{c("list", "x")}, the result is the child 24 | node with name \code{"x"} of the \code{"list"} child node. 25 | } 26 | \value{ 27 | An object of class \code{\link{gdsn.class}} for the specified node. 28 | } 29 | 30 | \author{Xiuwen Zheng} 31 | \seealso{ 32 | \code{\link{cnt.gdsn}}, \code{\link{ls.gdsn}}, \code{\link{name.gdsn}}, 33 | \code{\link{add.gdsn}}, \code{\link{delete.gdsn}} 34 | } 35 | 36 | \examples{ 37 | # cteate a GDS file 38 | f <- createfn.gds("test.gds") 39 | 40 | # add a list to "test.gds" 41 | node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE)) 42 | f 43 | 44 | index.gdsn(f, "list/x") 45 | index.gdsn(f, index=c("list", "x")) 46 | index.gdsn(f, index=c(1, 1)) 47 | index.gdsn(f, index=c("list", "z")) 48 | 49 | \dontrun{ 50 | index.gdsn(f, "list/x/z") 51 | # Error in index.gdsn(f, "list/x/z") : Invalid path "list/x/z"! 52 | } 53 | 54 | # return NULL 55 | index.gdsn(f, "list/x/z", silent=TRUE) 56 | 57 | # close the GDS file 58 | closefn.gds(f) 59 | 60 | 61 | # delete the temporary file 62 | unlink("test.gds", force=TRUE) 63 | } 64 | 65 | \keyword{GDS} 66 | \keyword{utilities} 67 | -------------------------------------------------------------------------------- /man/append.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{append.gdsn} 2 | \alias{append.gdsn} 3 | \title{Append data to a specified variable} 4 | \description{ 5 | Append new data to the data field of a GDS node. 6 | } 7 | 8 | \usage{ 9 | append.gdsn(node, val, check=TRUE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link[gdsfmt]{gdsn.class}}} 13 | \item{val}{R primitive data, like integer; or an object of class 14 | \code{\link[gdsfmt]{gdsn.class}}} 15 | \item{check}{whether a warning is given, when appended data can not 16 | match the capability of data field; if \code{val} is character-type, 17 | a warning will be shown if there is any \code{NA} in \code{val}} 18 | } 19 | \details{ 20 | \code{storage.mode(val)} should be "integer", "double", "character" 21 | or "logical". GDS format does not support missing characters \code{NA}, 22 | and any \code{NA} will be converted to a blank string \code{""}. 23 | } 24 | \value{ 25 | None. 26 | } 27 | 28 | \author{Xiuwen Zheng} 29 | \seealso{ 30 | \code{\link{read.gdsn}}, \code{\link{write.gdsn}}, 31 | \code{\link{add.gdsn}} 32 | } 33 | 34 | \examples{ 35 | # cteate a GDS file 36 | f <- createfn.gds("test.gds") 37 | 38 | # commom types 39 | n <- add.gdsn(f, "int", val=matrix(1:10000, nrow=100, ncol=100), 40 | compress="ZIP") 41 | 42 | # no warning, and add a new column 43 | append.gdsn(n, -1:-100) 44 | f 45 | 46 | # a warning 47 | append.gdsn(n, -1:-50) 48 | f 49 | 50 | # no warning here, and add a new column 51 | append.gdsn(n, -51:-100) 52 | f 53 | 54 | # you should call "readmode.gdsn" before reading, since compress="ZIP" 55 | readmode.gdsn(n) 56 | 57 | # check the last column 58 | read.gdsn(n, start=c(1, 102), count=c(-1, 1)) 59 | 60 | 61 | # characters 62 | n <- add.gdsn(f, "string", val=as.character(1:100)) 63 | append.gdsn(n, as.character(rep(NA, 25))) 64 | 65 | read.gdsn(n) 66 | 67 | 68 | # close the GDS file 69 | closefn.gds(f) 70 | 71 | 72 | # delete the temporary file 73 | unlink("test.gds", force=TRUE) 74 | } 75 | 76 | \keyword{GDS} 77 | \keyword{utilities} 78 | -------------------------------------------------------------------------------- /man/write.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{write.gdsn} 2 | \alias{write.gdsn} 3 | \title{Write data to a GDS node} 4 | \description{ 5 | Write data to a GDS node. 6 | } 7 | 8 | \usage{ 9 | write.gdsn(node, val, start=NULL, count=NULL, check=TRUE) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | \item{val}{the data to be written} 14 | \item{start}{a vector of integers, starting from 1 for each dimension} 15 | \item{count}{a vector of integers, the length of each dimnension} 16 | \item{check}{if \code{TRUE}, a warning will be given when \code{val} is 17 | character and there are missing values in \code{val}} 18 | } 19 | \details{ 20 | \code{start}, \code{count}: The values in data are taken to be those in 21 | the array with the leftmost subscript moving fastest. 22 | 23 | \code{start} and \code{count} should both exist or be missing. 24 | If \code{start} and \code{count} are both missing, the dimensions and values 25 | of \code{val} will be assigned to the data field. 26 | 27 | GDS format does not support missing characters \code{NA}, and any 28 | \code{NA} will be converted to a blank string \code{""}. 29 | } 30 | \value{ 31 | None. 32 | } 33 | 34 | \author{Xiuwen Zheng} 35 | \seealso{ 36 | \code{\link{append.gdsn}}, \code{\link{read.gdsn}}, 37 | \code{\link{add.gdsn}} 38 | } 39 | 40 | \examples{ 41 | # cteate a GDS file 42 | f <- createfn.gds("test.gds") 43 | 44 | ################################################### 45 | 46 | n <- add.gdsn(f, "matrix", matrix(1:20, ncol=5)) 47 | read.gdsn(n) 48 | 49 | write.gdsn(n, val=c(NA, NA), start=c(2, 2), count=c(2, 1)) 50 | read.gdsn(n) 51 | 52 | 53 | ################################################### 54 | 55 | n <- add.gdsn(f, "n", val=1:12) 56 | read.gdsn(n) 57 | 58 | write.gdsn(n, matrix(1:24, ncol=6)) 59 | read.gdsn(n) 60 | 61 | write.gdsn(n, array(1:24, c(4,3,2))) 62 | read.gdsn(n) 63 | 64 | 65 | # close the GDS file 66 | closefn.gds(f) 67 | 68 | 69 | # delete the temporary file 70 | unlink("test.gds", force=TRUE) 71 | } 72 | 73 | \keyword{GDS} 74 | \keyword{utilities} 75 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: gdsfmt 2 | Type: Package 3 | Title: R Interface to CoreArray Genomic Data Structure (GDS) Files 4 | Version: 1.46.0 5 | Date: 2025-10-26 6 | Depends: R (>= 2.15.0), methods 7 | Suggests: parallel, digest, Matrix, crayon, RUnit, knitr, markdown, rmarkdown, 8 | BiocGenerics 9 | Author: Xiuwen Zheng [aut, cre] (), 10 | Stephanie Gogarten [ctb], 11 | Jean-loup Gailly and Mark Adler [ctb] (for the included zlib sources), 12 | Yann Collet [ctb] (for the included LZ4 sources), 13 | xz contributors [ctb] (for the included liblzma sources) 14 | Maintainer: Xiuwen Zheng 15 | Description: Provides a high-level R interface to CoreArray Genomic Data 16 | Structure (GDS) data files. GDS is portable across platforms with 17 | hierarchical structure to store multiple scalable array-oriented data 18 | sets with metadata information. It is suited for large-scale datasets, 19 | especially for data which are much larger than the available 20 | random-access memory. The gdsfmt package offers the efficient operations 21 | specifically designed for integers of less than 8 bits, since a diploid 22 | genotype, like single-nucleotide polymorphism (SNP), usually occupies 23 | fewer bits than a byte. Data compression and decompression are available 24 | with relatively efficient random access. It is also allowed to read a 25 | GDS file in parallel with multiple R processes supported by the package 26 | parallel. 27 | License: LGPL-3 28 | Copyright: This package includes the sources of CoreArray C++ library 29 | written by Xiuwen Zheng (LGPL-3), zlib written by Jean-loup 30 | Gailly and Mark Adler (zlib license), LZ4 written by Yann 31 | Collet (simplified BSD), and liblzma written by Lasse Collin and 32 | other xz contributors (public domain). 33 | VignetteBuilder: knitr 34 | ByteCompile: TRUE 35 | BugReports: https://github.com/zhengxwen/gdsfmt/issues 36 | URL: https://github.com/zhengxwen/gdsfmt 37 | biocViews: Infrastructure, DataImport 38 | -------------------------------------------------------------------------------- /src/CoreArray/CoreArray.h: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // CoreArray.h: CoreArray interface 10 | // 11 | // Copyright (C) 2007-2018 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | /** 29 | * \file CoreArray.h 30 | * \author Xiuwen Zheng [zhengxwen@gmail.com] 31 | * \version 1.0 32 | * \date 2007 - 2018 33 | * \brief CoreArray interface 34 | * \details 35 | **/ 36 | 37 | 38 | #ifndef _HEADER_COREARRAY_ 39 | #define _HEADER_COREARRAY_ 40 | 41 | #include "CoreDEF.h" 42 | #include "dType.h" 43 | #include "dTrait.h" 44 | #include "dBit.h" 45 | #include "dPlatform.h" 46 | #include "dParallel.h" 47 | #include "dStream.h" 48 | #include "dEndian.h" 49 | #include "dSerial.h" 50 | #include "dBase.h" 51 | #include "dFile.h" 52 | #include "dStruct.h" 53 | #include "dRealGDS.h" 54 | #include "dBitGDS.h" 55 | #include "dStrGDS.h" 56 | #include "dVLIntGDS.h" 57 | #include "dSparse.h" 58 | 59 | 60 | namespace CoreArray 61 | { 62 | /// Register CoreArray classes 63 | COREARRAY_DLL_DEFAULT void RegisterClass(); 64 | } 65 | 66 | #endif /* _HEADER_COREARRAY_ */ 67 | -------------------------------------------------------------------------------- /man/diagnosis.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{diagnosis.gds} 2 | \alias{diagnosis.gds} 3 | \title{Diagnose the GDS file} 4 | \description{ 5 | Diagnose the GDS file and data information. 6 | } 7 | 8 | \usage{ 9 | diagnosis.gds(gds, log.only=FALSE) 10 | } 11 | \arguments{ 12 | \item{gds}{an object of class \code{\link{gdsn.class}} or 13 | \code{\link{gds.class}}} 14 | \item{log.only}{if \code{TRUE}, return a character vector of log only} 15 | } 16 | \value{ 17 | A list with stream and chunk information. 18 | 19 | If \code{gds} is a \code{"gds.class"} object (i.e., a GDS file), the 20 | function returns a list with components, like: 21 | \item{stream}{summary of byte stream} 22 | \item{log}{event log records} 23 | 24 | If \code{gds} is a \code{"gdsn.class"} object, the function returns a list 25 | with components, like: 26 | \item{head}{total_size, chunk_offset, chunk_size} 27 | \item{data}{total_size, chunk_offset, chunk_size} 28 | \item{...}{} 29 | } 30 | 31 | \author{Xiuwen Zheng} 32 | 33 | \examples{ 34 | # cteate a GDS file 35 | f <- createfn.gds("test.gds") 36 | 37 | set.seed(1000) 38 | rawval <- as.raw(rep(0:99, 50)) 39 | 40 | add.gdsn(f, "label", NULL) 41 | add.gdsn(f, "raw", rawval) 42 | 43 | closefn.gds(f) 44 | 45 | ## 46 | 47 | f <- openfn.gds("test.gds") 48 | 49 | diagnosis.gds(f) 50 | diagnosis.gds(f$root) 51 | diagnosis.gds(index.gdsn(f, "label")) 52 | diagnosis.gds(index.gdsn(f, "raw")) 53 | 54 | closefn.gds(f) 55 | 56 | ## remove fragments 57 | 58 | cleanup.gds("test.gds") 59 | 60 | ## 61 | 62 | f <- openfn.gds("test.gds") 63 | 64 | diagnosis.gds(f$root) 65 | diagnosis.gds(index.gdsn(f, "label")) 66 | (adr <- diagnosis.gds(index.gdsn(f, "raw"))) 67 | 68 | closefn.gds(f) 69 | 70 | 71 | ## read binary data directly 72 | 73 | f <- file("test.gds", "rb") 74 | 75 | dat <- NULL 76 | for (i in seq_len(length(adr$data$chunk_offset))) 77 | { 78 | seek(f, adr$data$chunk_offset[i]) 79 | dat <- c(dat, readBin(f, "raw", adr$data$chunk_size[i])) 80 | } 81 | 82 | identical(dat, rawval) # should be TRUE 83 | 84 | close(f) 85 | 86 | 87 | # delete the temporary file 88 | unlink("test.gds", force=TRUE) 89 | } 90 | 91 | \keyword{GDS} 92 | \keyword{utilities} 93 | -------------------------------------------------------------------------------- /man/moveto.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{moveto.gdsn} 2 | \alias{moveto.gdsn} 3 | \title{Relocate a GDS node} 4 | \description{ 5 | Move a GDS node to a new place in the same file 6 | } 7 | 8 | \usage{ 9 | moveto.gdsn(node, loc.node, 10 | relpos = c("after", "before", "replace", "replace+rename")) 11 | } 12 | \arguments{ 13 | \item{node}{an object of class \code{\link{gdsn.class}} (a GDS node)} 14 | \item{loc.node}{an object of class \code{\link{gdsn.class}} 15 | (a GDS node), indicates the new location} 16 | \item{relpos}{\code{"after"}: after \code{loc.node}, 17 | \code{"before"}: before \code{loc.node}, 18 | \code{"replace"}: replace \code{loc.node} (\code{loc.node} 19 | will be deleted); 20 | \code{"replace+rename"}: replace \code{loc.node} (\code{loc.node} 21 | will be deleted and \code{node} has a new name as \code{loc.node})} 22 | } 23 | \value{ 24 | None. 25 | } 26 | 27 | \author{Xiuwen Zheng} 28 | \seealso{ 29 | \code{\link{createfn.gds}}, \code{\link{openfn.gds}}, 30 | \code{\link{index.gdsn}}, \code{\link{add.gdsn}} 31 | } 32 | \examples{ 33 | # cteate a GDS file 34 | f <- createfn.gds("test.gds") 35 | L <- -2500:2499 36 | 37 | # commom types 38 | 39 | add.gdsn(f, "label", NULL) 40 | add.gdsn(f, "int", 1:10000, compress="ZIP", closezip=TRUE) 41 | add.gdsn(f, "int.matrix", matrix(L, nrow=100, ncol=50)) 42 | add.gdsn(f, "double", seq(1, 1000, 0.4)) 43 | add.gdsn(f, "character", c("int", "double", "logical", "factor")) 44 | 45 | f 46 | # + [ ] 47 | # |--+ label 48 | # |--+ int { Int32 10000 ZIP(34.74%) } 49 | # |--+ int.matrix { Int32 100x50 } 50 | # |--+ double { Float64 2498 } 51 | # |--+ character { VStr8 4 } 52 | 53 | n1 <- index.gdsn(f, "label") 54 | n2 <- index.gdsn(f, "double") 55 | 56 | moveto.gdsn(n1, n2, relpos="after") 57 | f 58 | 59 | moveto.gdsn(n1, n2, relpos="before") 60 | f 61 | 62 | moveto.gdsn(n1, n2, relpos="replace") 63 | f 64 | 65 | n2 <- index.gdsn(f, "int") 66 | moveto.gdsn(n1, n2, relpos="replace+rename") 67 | f 68 | 69 | # close the GDS file 70 | closefn.gds(f) 71 | 72 | 73 | # delete the temporary file 74 | unlink("test.gds", force=TRUE) 75 | } 76 | 77 | \keyword{GDS} 78 | \keyword{utilities} 79 | -------------------------------------------------------------------------------- /src/XZ/api/lzma/delta.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/delta.h 3 | * \brief Delta filter 4 | */ 5 | 6 | /* 7 | * Author: Lasse Collin 8 | * 9 | * This file has been put into the public domain. 10 | * You can do whatever you want with this file. 11 | * 12 | * See ../lzma.h for information about liblzma as a whole. 13 | */ 14 | 15 | #ifndef LZMA_H_INTERNAL 16 | # error Never include this file directly. Use instead. 17 | #endif 18 | 19 | 20 | /** 21 | * \brief Filter ID 22 | * 23 | * Filter ID of the Delta filter. This is used as lzma_filter.id. 24 | */ 25 | #define LZMA_FILTER_DELTA LZMA_VLI_C(0x03) 26 | 27 | 28 | /** 29 | * \brief Type of the delta calculation 30 | * 31 | * Currently only byte-wise delta is supported. Other possible types could 32 | * be, for example, delta of 16/32/64-bit little/big endian integers, but 33 | * these are not currently planned since byte-wise delta is almost as good. 34 | */ 35 | typedef enum { 36 | LZMA_DELTA_TYPE_BYTE 37 | } lzma_delta_type; 38 | 39 | 40 | /** 41 | * \brief Options for the Delta filter 42 | * 43 | * These options are needed by both encoder and decoder. 44 | */ 45 | typedef struct { 46 | /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */ 47 | lzma_delta_type type; 48 | 49 | /** 50 | * \brief Delta distance 51 | * 52 | * With the only currently supported type, LZMA_DELTA_TYPE_BYTE, 53 | * the distance is as bytes. 54 | * 55 | * Examples: 56 | * - 16-bit stereo audio: distance = 4 bytes 57 | * - 24-bit RGB image data: distance = 3 bytes 58 | */ 59 | uint32_t dist; 60 | # define LZMA_DELTA_DIST_MIN 1 61 | # define LZMA_DELTA_DIST_MAX 256 62 | 63 | /* 64 | * Reserved space to allow possible future extensions without 65 | * breaking the ABI. You should not touch these, because the names 66 | * of these variables may change. These are and will never be used 67 | * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these 68 | * uninitialized. 69 | */ 70 | uint32_t reserved_int1; 71 | uint32_t reserved_int2; 72 | uint32_t reserved_int3; 73 | uint32_t reserved_int4; 74 | void *reserved_ptr1; 75 | void *reserved_ptr2; 76 | 77 | } lzma_options_delta; 78 | -------------------------------------------------------------------------------- /src/LZ4/lz4frame_static.h: -------------------------------------------------------------------------------- 1 | /* 2 | LZ4 auto-framing library 3 | Header File for static linking only 4 | Copyright (C) 2011-2020, Yann Collet. 5 | 6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | You can contact the author at : 32 | - LZ4 source repository : https://github.com/lz4/lz4 33 | - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c 34 | */ 35 | 36 | #ifndef LZ4FRAME_STATIC_H_0398209384 37 | #define LZ4FRAME_STATIC_H_0398209384 38 | 39 | /* The declarations that formerly were made here have been merged into 40 | * lz4frame.h, protected by the LZ4F_STATIC_LINKING_ONLY macro. Going forward, 41 | * it is recommended to simply include that header directly. 42 | */ 43 | 44 | #define LZ4F_STATIC_LINKING_ONLY 45 | #include "lz4frame.h" 46 | 47 | #endif /* LZ4FRAME_STATIC_H_0398209384 */ 48 | -------------------------------------------------------------------------------- /man/print.gds.class.Rd: -------------------------------------------------------------------------------- 1 | \name{print.gds.class} 2 | \alias{print.gds.class} 3 | \alias{print.gdsn.class} 4 | \alias{show,gdsn.class-method} 5 | \title{Show the information of class "gds.class" and "gdsn.class"} 6 | \description{ 7 | Displays the contents of "gds.class" (a GDS file) and "gdsn.class" 8 | (a GDS node). 9 | } 10 | \usage{ 11 | \method{print}{gds.class}(x, path="", show=TRUE, ...) 12 | \method{print}{gdsn.class}(x, expand=TRUE, all=FALSE, nmax=Inf, depth=Inf, 13 | attribute=FALSE, attribute.trim=FALSE, ...) 14 | \S4method{show}{gdsn.class}(object) 15 | } 16 | \arguments{ 17 | \item{x}{an object of class \code{\link{gds.class}}, a GDS file; or 18 | \code{\link{gdsn.class}}, a GDS node} 19 | \item{object}{an object of class \code{\link{gds.class}}, the number of 20 | elements in the preview can be specified via the option 21 | \code{getOption("gds.preview.num", 6L)}, while \code{6L} is the default 22 | value} 23 | \item{path}{the path specifying a GDS node with '/' as a separator} 24 | \item{show}{if TRUE, display the preview of array node} 25 | \item{expand}{whether enumerate all of child nodes} 26 | \item{all}{if FALSE, hide GDS nodes with an attribute "R.invisible"} 27 | \item{nmax}{display nodes within the maximum number \code{nmax}} 28 | \item{depth}{display nodes under maximum \code{depth}} 29 | \item{attribute}{if TRUE, show the attribute(s)} 30 | \item{attribute.trim}{if TRUE, trim the attribute information if it is too 31 | long} 32 | \item{...}{the arguments passed to or from other methods} 33 | } 34 | \value{ 35 | None. 36 | } 37 | 38 | \author{Xiuwen Zheng} 39 | 40 | \examples{ 41 | # cteate a GDS file 42 | f <- createfn.gds("test.gds") 43 | 44 | add.gdsn(f, "int", 1:100) 45 | add.gdsn(f, "int.matrix", matrix(1:(50*100), nrow=100, ncol=50)) 46 | put.attr.gdsn(index.gdsn(f, "int.matrix"), "int", 1:10) 47 | 48 | print(f, all=TRUE) 49 | print(f, all=TRUE, attribute=TRUE) 50 | print(f, all=TRUE, attribute=TRUE, attribute.trim=FALSE) 51 | 52 | show(index.gdsn(f, "int")) 53 | show(index.gdsn(f, "int.matrix")) 54 | 55 | # close the GDS file 56 | closefn.gds(f) 57 | 58 | # delete the temporary file 59 | unlink("test.gds", force=TRUE) 60 | } 61 | 62 | \keyword{GDS} 63 | \keyword{utilities} 64 | -------------------------------------------------------------------------------- /src/CoreArray/dRealGDS.cpp: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // dRealGDS.cpp: Packed real number in GDS format 10 | // 11 | // Copyright (C) 2018-2019 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | #ifndef COREARRAY_COMPILER_OPTIMIZE_FLAG 29 | # define COREARRAY_COMPILER_OPTIMIZE_FLAG 3 30 | #endif 31 | 32 | #include "dRealGDS.h" 33 | 34 | 35 | namespace CoreArray 36 | { 37 | template static CdObjRef *OnObjCreate() 38 | { 39 | return new TClass(); 40 | } 41 | 42 | COREARRAY_DLL_LOCAL void RegisterClass_PackedReal() 43 | { 44 | #define REG_CLASS(T, CLASS, CType, Desp) \ 45 | dObjManager().AddClass(TdTraits< T >::StreamName(), \ 46 | OnObjCreate< CLASS >, CdObjClassMgr::CType, Desp) 47 | 48 | // real numbers 49 | REG_CLASS(TReal8, CdPackedReal8, ctArray, "packed real number (signed 8 bits)"); 50 | REG_CLASS(TReal8u, CdPackedReal8U, ctArray, "packed real number (unsigned 8 bits)"); 51 | REG_CLASS(TReal16, CdPackedReal16, ctArray, "packed real number (signed 16 bits)"); 52 | REG_CLASS(TReal16u, CdPackedReal16U, ctArray, "packed real number (unsigned 16 bits)"); 53 | REG_CLASS(TReal24, CdPackedReal24, ctArray, "packed real number (signed 24 bits)"); 54 | REG_CLASS(TReal24u, CdPackedReal24U, ctArray, "packed real number (unsigned 24 bits)"); 55 | REG_CLASS(TReal32, CdPackedReal32, ctArray, "packed real number (signed 32 bits)"); 56 | REG_CLASS(TReal32u, CdPackedReal32U, ctArray, "packed real number (unsigned 32 bits)"); 57 | 58 | #undef REG_CLASS 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /inst/unitTests/test_01_datatype.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: test internal data types 4 | # 5 | 6 | library(RUnit) 7 | library(gdsfmt) 8 | 9 | 10 | # call internal C function 11 | class.nbit <- function(class.name) 12 | { 13 | .Call("gds_test_Class", class.name, PACKAGE="gdsfmt") 14 | } 15 | 16 | 17 | 18 | ############################################################# 19 | # 20 | # test functions 21 | # 22 | 23 | test.datatype <- function() 24 | { 25 | # integers 26 | checkEquals(class.nbit("integer"), 32, "integer type: int") 27 | checkEquals(class.nbit("int8"), 8, "integer type: int8") 28 | checkEquals(class.nbit("uint8"), 8, "integer type: uint8") 29 | checkEquals(class.nbit("int16"), 16, "integer type: int16") 30 | checkEquals(class.nbit("uint16"), 16, "integer type: uint16") 31 | checkEquals(class.nbit("int24"), 24, "integer type: int24") 32 | checkEquals(class.nbit("uint24"), 24, "integer type: uint24") 33 | checkEquals(class.nbit("int32"), 32, "integer type: int32") 34 | checkEquals(class.nbit("uint32"), 32, "integer type: uint32") 35 | checkEquals(class.nbit("int64"), 64, "integer type: int64") 36 | checkEquals(class.nbit("uint64"), 64, "integer type: uint64") 37 | 38 | # sbit?? 39 | for (n in 2:16) 40 | { 41 | cn <- sprintf("sbit%d", n) 42 | checkEquals(class.nbit(cn), n, sprintf("integer type: %s", cn)) 43 | } 44 | 45 | # bit?? 46 | for (n in 1:16) 47 | { 48 | cn <- sprintf("bit%d", n) 49 | checkEquals(class.nbit(cn), n, sprintf("integer type: %s", cn)) 50 | } 51 | 52 | # float 53 | checkEquals(class.nbit("float"), 32, "numeric type: float32") 54 | checkEquals(class.nbit("float32"), 32, "numeric type: float32") 55 | checkEquals(class.nbit("double"), 64, "numeric type: double") 56 | checkEquals(class.nbit("float64"), 64, "numeric type: float64") 57 | checkEquals(class.nbit("packedreal8"), 8, "numeric type: packedreal8") 58 | checkEquals(class.nbit("packedreal16"), 16, "numeric type: packedreal16") 59 | checkEquals(class.nbit("packedreal32"), 32, "numeric type: packedreal32") 60 | 61 | # string 62 | checkEquals(class.nbit("character"), 8, "character type: character") 63 | checkEquals(class.nbit("string"), 8, "character type: string") 64 | checkEquals(class.nbit("string16"), 16, "character type: string16") 65 | checkEquals(class.nbit("string32"), 32, "character type: string32") 66 | 67 | checkEquals(class.nbit("fstring"), 8, "character type: string") 68 | checkEquals(class.nbit("fstring16"), 16, "character type: string16") 69 | checkEquals(class.nbit("fstring32"), 32, "character type: string32") 70 | 71 | # others 72 | checkEquals(class.nbit("logical"), 32, "integer type: logical") 73 | checkEquals(class.nbit("factor"), 32, "integer type: factor") 74 | } 75 | -------------------------------------------------------------------------------- /src/CoreArray/dStrGDS.cpp: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // dStrGDS.cpp: GDS format with character types and functions 10 | // 11 | // Copyright (C) 2018-2019 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | #ifndef COREARRAY_COMPILER_OPTIMIZE_FLAG 29 | # define COREARRAY_COMPILER_OPTIMIZE_FLAG 3 30 | #endif 31 | 32 | #include "dStrGDS.h" 33 | 34 | 35 | namespace CoreArray 36 | { 37 | template static CdObjRef *OnObjCreate() 38 | { 39 | return new TClass(); 40 | } 41 | 42 | COREARRAY_DLL_LOCAL void RegisterClass_String() 43 | { 44 | #define REG_CLASS(T, CLASS, CType, Desp) \ 45 | dObjManager().AddClass(TdTraits< T >::StreamName(), \ 46 | OnObjCreate< CLASS >, CdObjClassMgr::CType, Desp) 47 | 48 | // fixed-length strings 49 | REG_CLASS(FIXED_LEN, CdFStr8, ctArray, "fixed-length UTF-8 string"); 50 | REG_CLASS(FIXED_LEN, CdFStr16, ctArray, "fixed-length UTF-16 string"); 51 | REG_CLASS(FIXED_LEN, CdFStr32, ctArray, "fixed-length UTF-32 string"); 52 | 53 | // variable-length null-terminated strings 54 | REG_CLASS(C_STRING, CdVStr8, ctArray, "UTF-8 null-terminated string"); 55 | REG_CLASS(C_STRING, CdVStr16, ctArray, "UTF-16 null-terminated string"); 56 | REG_CLASS(C_STRING, CdVStr32, ctArray, "UTF-32 null-terminated string"); 57 | 58 | // variable-length strings allowing null character 59 | REG_CLASS(VARIABLE_LEN, CdStr8, ctArray, "variable-length UTF-8 string"); 60 | REG_CLASS(VARIABLE_LEN, CdStr16, ctArray, "variable-length UTF-16 string"); 61 | REG_CLASS(VARIABLE_LEN, CdStr32, ctArray, "variable-length UTF-32 string"); 62 | 63 | #undef REG_CLASS 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /man/objdesp.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{objdesp.gdsn} 2 | \alias{objdesp.gdsn} 3 | \title{Variable description} 4 | \description{ 5 | Get the description of a GDS node. 6 | } 7 | 8 | \usage{ 9 | objdesp.gdsn(node) 10 | } 11 | \arguments{ 12 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 13 | } 14 | \value{ 15 | Returns a list: 16 | \item{name}{the variable name of a specified node} 17 | \item{fullname}{the full name of a specified node} 18 | \item{storage}{the storage mode in the GDS file} 19 | \item{trait}{the description of data field, like "Int8"} 20 | \item{type}{a factor indicating the storage mode in R: 21 | Label -- a label node, 22 | Folder -- a directory, 23 | VFolder -- a virtual folder linking to another GDS file, 24 | Raw -- raw data (\code{\link{addfile.gdsn}}), 25 | Integer -- integers, 26 | Factor -- factor values, 27 | Logical -- logical values (FALSE, TRUE and NA), 28 | Real -- floating numbers, 29 | String -- characters, 30 | Unknown -- unknown type} 31 | \item{is.array}{indicates whether it is array-type} 32 | \item{is.sparse}{TRUE, if it is a sparse array} 33 | \item{dim}{the dimension of data field} 34 | \item{encoder}{encoder for compressed data, such like "ZIP"} 35 | \item{compress}{the compression method: "", "ZIP.max", etc} 36 | \item{cpratio}{data compression ratio, \code{NaN} indicates no compression} 37 | \item{size}{the size of data stored in the GDS file} 38 | \item{good}{logical, indicates the state of GDS file, e.g., 39 | FALSE if the virtual folder fails to link the target GDS file} 40 | \item{hidden}{logical, \code{TRUE} if it is a hidden object} 41 | \item{message}{if applicable, messages of the GDS node, such like error 42 | messages, log information} 43 | \item{param}{the parameters, used in \code{\link{add.gdsn}}, like 44 | "maxlen", "offset", "scale"} 45 | } 46 | 47 | \author{Xiuwen Zheng} 48 | \seealso{ 49 | \code{\link{cnt.gdsn}}, \code{\link{name.gdsn}}, 50 | \code{\link{ls.gdsn}}, \code{\link{index.gdsn}} 51 | } 52 | 53 | \examples{ 54 | # cteate a GDS file 55 | f <- createfn.gds("test.gds") 56 | 57 | # add a vector to "test.gds" 58 | node1 <- add.gdsn(f, name="vector1", val=1:10000) 59 | objdesp.gdsn(node1) 60 | 61 | # add a vector to "test.gds" 62 | node2 <- add.gdsn(f, name="vector2", val=1:10000, compress="ZIP.max", 63 | closezip=FALSE) 64 | objdesp.gdsn(node2) 65 | 66 | # add a character to "test.gds" 67 | node3 <- add.gdsn(f, name="vector3", val=c("A", "BC", "DEF"), 68 | compress="ZIP", closezip=TRUE) 69 | objdesp.gdsn(node3) 70 | 71 | # close the GDS file 72 | closefn.gds(f) 73 | 74 | 75 | # delete the temporary file 76 | unlink("test.gds", force=TRUE) 77 | } 78 | 79 | \keyword{GDS} 80 | \keyword{utilities} 81 | -------------------------------------------------------------------------------- /src/XZ/api/lzma/hardware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/hardware.h 3 | * \brief Hardware information 4 | * 5 | * Since liblzma can consume a lot of system resources, it also provides 6 | * ways to limit the resource usage. Applications linking against liblzma 7 | * need to do the actual decisions how much resources to let liblzma to use. 8 | * To ease making these decisions, liblzma provides functions to find out 9 | * the relevant capabilities of the underlying hardware. Currently there 10 | * is only a function to find out the amount of RAM, but in the future there 11 | * will be also a function to detect how many concurrent threads the system 12 | * can run. 13 | * 14 | * \note On some operating systems, these function may temporarily 15 | * load a shared library or open file descriptor(s) to find out 16 | * the requested hardware information. Unless the application 17 | * assumes that specific file descriptors are not touched by 18 | * other threads, this should have no effect on thread safety. 19 | * Possible operations involving file descriptors will restart 20 | * the syscalls if they return EINTR. 21 | */ 22 | 23 | /* 24 | * Author: Lasse Collin 25 | * 26 | * This file has been put into the public domain. 27 | * You can do whatever you want with this file. 28 | * 29 | * See ../lzma.h for information about liblzma as a whole. 30 | */ 31 | 32 | #ifndef LZMA_H_INTERNAL 33 | # error Never include this file directly. Use instead. 34 | #endif 35 | 36 | 37 | /** 38 | * \brief Get the total amount of physical memory (RAM) in bytes 39 | * 40 | * This function may be useful when determining a reasonable memory 41 | * usage limit for decompressing or how much memory it is OK to use 42 | * for compressing. 43 | * 44 | * \return On success, the total amount of physical memory in bytes 45 | * is returned. If the amount of RAM cannot be determined, 46 | * zero is returned. This can happen if an error occurs 47 | * or if there is no code in liblzma to detect the amount 48 | * of RAM on the specific operating system. 49 | */ 50 | extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; 51 | 52 | 53 | /** 54 | * \brief Get the number of processor cores or threads 55 | * 56 | * This function may be useful when determining how many threads to use. 57 | * If the hardware supports more than one thread per CPU core, the number 58 | * of hardware threads is returned if that information is available. 59 | * 60 | * \return On success, the number of available CPU threads or cores is 61 | * returned. If this information isn't available or an error 62 | * occurs, zero is returned. 63 | */ 64 | extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow; 65 | -------------------------------------------------------------------------------- /inst/unitTests/test_02_dataconvert.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: test data conversion 4 | # 5 | 6 | source(system.file("unitTests", "include.r", package="gdsfmt")) 7 | 8 | 9 | # create a gds file, read and write data 10 | gds_read_write <- function(class.name, data.kind, compress="") 11 | { 12 | on.exit({ 13 | showfile.gds(closeall=TRUE, verbose=FALSE) 14 | unlink("tmp.gds", force=TRUE) 15 | }) 16 | 17 | if (data.kind == 1) 18 | dta <- seq(-1000, 999) 19 | else 20 | dta <- seq(-499, 299) 21 | 22 | if (class.name %in% c("packedreal8", "packedreal16", "packedreal24", "packedreal32")) 23 | dta <- dta / 1000 24 | else if (class.name %in% c("packedreal8u", "packedreal16u", "packedreal24u", "packedreal32u")) 25 | dta <- abs(dta) / 1000 26 | else if (class.name == "vl_uint") 27 | dta <- dta + 1000L 28 | 29 | # create a new gds file 30 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 31 | 32 | # add a 33 | node <- add.gdsn(gfile, "data", val=dta, storage=class.name, 34 | compress=compress, closezip=TRUE) 35 | # close the gds file 36 | closefn.gds(gfile) 37 | 38 | # open the gds file 39 | gfile <- openfn.gds("tmp.gds", allow.duplicate=TRUE) 40 | node <- index.gdsn(gfile, "data") 41 | 42 | rv <- read.gdsn(node) 43 | 44 | # close the gds file 45 | closefn.gds(gfile) 46 | 47 | rv 48 | } 49 | 50 | # create standard dataset 51 | data.create <- function() 52 | { 53 | dta <- list() 54 | for (n in type.list) 55 | { 56 | # the first dataset 57 | dta[[sprintf("valid1.%s", n)]] <- gds_read_write(n, 1) 58 | 59 | # the second dataset 60 | dta[[sprintf("valid2.%s", n)]] <- gds_read_write(n, 2) 61 | } 62 | save(dta, file="standard.RData", compress="xz") 63 | } 64 | 65 | 66 | 67 | 68 | ############################################################# 69 | # 70 | # test functions 71 | # 72 | 73 | test.dataconvert <- function() 74 | { 75 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 76 | 77 | for (n in type.list) 78 | { 79 | checkEquals(gds_read_write(n, 1), valid.dta[[sprintf("valid1.%s", n)]], 80 | sprintf("data conversion: %s", n)) 81 | checkEquals(gds_read_write(n, 2), valid.dta[[sprintf("valid2.%s", n)]], 82 | sprintf("data conversion: %s", n)) 83 | } 84 | } 85 | 86 | 87 | test.dataconvert.compress <- function() 88 | { 89 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 90 | 91 | for (cp in compress.list) 92 | { 93 | for (n in type.list) 94 | { 95 | checkEquals(gds_read_write(n, 1, cp), valid.dta[[sprintf("valid1.%s", n)]], 96 | sprintf("data conversion: %s, compress: %s", n, cp)) 97 | checkEquals(gds_read_write(n, 2, cp), valid.dta[[sprintf("valid2.%s", n)]], 98 | sprintf("data conversion: %s, compress: %s", n, cp)) 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /man/assign.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{assign.gdsn} 2 | \alias{assign.gdsn} 3 | \title{Assign/append data to a GDS node} 4 | \description{ 5 | Assign data to a GDS node, or append data to a GDS node 6 | } 7 | 8 | \usage{ 9 | assign.gdsn(node, src.node=NULL, resize=TRUE, seldim=NULL, append=FALSE, 10 | .value=NULL, .substitute=NULL) 11 | } 12 | \arguments{ 13 | \item{node}{an object of class \code{\link{gdsn.class}}, 14 | a target GDS node} 15 | \item{src.node}{an object of class \code{\link{gdsn.class}}, 16 | a source GDS node} 17 | \item{resize}{whether call \code{\link{setdim.gdsn}} to reset the 18 | dimension(s)} 19 | \item{seldim}{the selection of \code{src.obj} with numeric or logical 20 | indicators, or \code{NULL} for all data} 21 | \item{append}{if \code{TRUE}, append data by calling 22 | \code{\link{append.gdsn}}; otherwise, replace the old one} 23 | \item{.value}{a vector of values to be replaced in the original data array, 24 | or \code{NULL} for nothing} 25 | \item{.substitute}{a vector of values after replacing, or NULL for 26 | nothing; \code{length(.substitute)} should be one or 27 | \code{length(.value)}; if \code{length(.substitute)} = 28 | \code{length(.value)}, it is a mapping from \code{.value} to 29 | \code{.substitute}} 30 | } 31 | \value{ 32 | None. 33 | } 34 | 35 | \author{Xiuwen Zheng} 36 | \seealso{ 37 | \code{\link{read.gdsn}}, \code{\link{readex.gdsn}}, 38 | \code{\link{apply.gdsn}}, \code{\link{write.gdsn}}, 39 | \code{\link{append.gdsn}} 40 | } 41 | 42 | \examples{ 43 | f <- createfn.gds("test.gds") 44 | 45 | n1 <- add.gdsn(f, "n1", 1:100) 46 | n2 <- add.gdsn(f, "n2", storage="int", valdim=c(20, 0)) 47 | n3 <- add.gdsn(f, "n3", storage="int", valdim=c(0)) 48 | n4 <- add.gdsn(f, "n4", matrix(1:48, 6)) 49 | f 50 | 51 | assign.gdsn(n2, n1, resize=FALSE, append=TRUE) 52 | 53 | read.gdsn(n1) 54 | read.gdsn(n2) 55 | 56 | assign.gdsn(n2, n1, resize=FALSE, append=TRUE) 57 | append.gdsn(n2, n1) 58 | read.gdsn(n2) 59 | 60 | assign.gdsn(n3, n2, seldim= 61 | list(rep(c(TRUE, FALSE), 10), c(rep(c(TRUE, FALSE), 7), TRUE))) 62 | read.gdsn(n3) 63 | 64 | setdim.gdsn(n2, c(25,0)) 65 | assign.gdsn(n2, n1, append=TRUE, seldim=rep(c(TRUE, FALSE), 50)) 66 | read.gdsn(n2) 67 | 68 | assign.gdsn(n2, n1); read.gdsn(n2) 69 | f 70 | 71 | ## 72 | 73 | read.gdsn(n4) 74 | 75 | # substitute 76 | assign.gdsn(n4, .value=c(3:8,35:40), .substitute=NA); read.gdsn(n4) 77 | 78 | # subset 79 | assign.gdsn(n4, seldim=list(c(4,2,6,NA), c(5,6,NA,2,8,NA,4))); read.gdsn(n4) 80 | 81 | 82 | n4 <- add.gdsn(f, "n4", matrix(1:48, 6), replace=TRUE) 83 | read.gdsn(n4) 84 | # sort into descending order 85 | assign.gdsn(n4, seldim=list(6:1, 8:1)); read.gdsn(n4) 86 | 87 | 88 | # close the GDS file 89 | closefn.gds(f) 90 | 91 | 92 | # delete the temporary file 93 | unlink("test.gds", force=TRUE) 94 | } 95 | 96 | \keyword{GDS} 97 | \keyword{utilities} 98 | -------------------------------------------------------------------------------- /src/ZLIB/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2( 23 | Bytef *dest, 24 | uLongf *destLen, 25 | const Bytef *source, 26 | uLong sourceLen, 27 | int level) 28 | { 29 | z_stream stream; 30 | int err; 31 | const uInt max = (uInt)-1; 32 | uLong left; 33 | 34 | left = *destLen; 35 | *destLen = 0; 36 | 37 | stream.zalloc = (alloc_func)0; 38 | stream.zfree = (free_func)0; 39 | stream.opaque = (voidpf)0; 40 | 41 | err = deflateInit(&stream, level); 42 | if (err != Z_OK) return err; 43 | 44 | stream.next_out = dest; 45 | stream.avail_out = 0; 46 | stream.next_in = (z_const Bytef *)source; 47 | stream.avail_in = 0; 48 | 49 | do { 50 | if (stream.avail_out == 0) { 51 | stream.avail_out = left > (uLong)max ? max : (uInt)left; 52 | left -= stream.avail_out; 53 | } 54 | if (stream.avail_in == 0) { 55 | stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; 56 | sourceLen -= stream.avail_in; 57 | } 58 | err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); 59 | } while (err == Z_OK); 60 | 61 | *destLen = stream.total_out; 62 | deflateEnd(&stream); 63 | return err == Z_STREAM_END ? Z_OK : err; 64 | } 65 | 66 | /* =========================================================================== 67 | */ 68 | int ZEXPORT compress( 69 | Bytef *dest, 70 | uLongf *destLen, 71 | const Bytef *source, 72 | uLong sourceLen) 73 | { 74 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 75 | } 76 | 77 | /* =========================================================================== 78 | If the default memLevel or windowBits for deflateInit() is changed, then 79 | this function needs to be updated. 80 | */ 81 | uLong ZEXPORT compressBound( 82 | uLong sourceLen) 83 | { 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 85 | (sourceLen >> 25) + 13; 86 | } 87 | -------------------------------------------------------------------------------- /src/XZ/api/lzma/bcj.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/bcj.h 3 | * \brief Branch/Call/Jump conversion filters 4 | */ 5 | 6 | /* 7 | * Author: Lasse Collin 8 | * 9 | * This file has been put into the public domain. 10 | * You can do whatever you want with this file. 11 | * 12 | * See ../lzma.h for information about liblzma as a whole. 13 | */ 14 | 15 | #ifndef LZMA_H_INTERNAL 16 | # error Never include this file directly. Use instead. 17 | #endif 18 | 19 | 20 | /* Filter IDs for lzma_filter.id */ 21 | 22 | #define LZMA_FILTER_X86 LZMA_VLI_C(0x04) 23 | /**< 24 | * Filter for x86 binaries 25 | */ 26 | 27 | #define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) 28 | /**< 29 | * Filter for Big endian PowerPC binaries 30 | */ 31 | 32 | #define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) 33 | /**< 34 | * Filter for IA-64 (Itanium) binaries. 35 | */ 36 | 37 | #define LZMA_FILTER_ARM LZMA_VLI_C(0x07) 38 | /**< 39 | * Filter for ARM binaries. 40 | */ 41 | 42 | #define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) 43 | /**< 44 | * Filter for ARM-Thumb binaries. 45 | */ 46 | 47 | #define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) 48 | /**< 49 | * Filter for SPARC binaries. 50 | */ 51 | 52 | 53 | /** 54 | * \brief Options for BCJ filters 55 | * 56 | * The BCJ filters never change the size of the data. Specifying options 57 | * for them is optional: if pointer to options is NULL, default value is 58 | * used. You probably never need to specify options to BCJ filters, so just 59 | * set the options pointer to NULL and be happy. 60 | * 61 | * If options with non-default values have been specified when encoding, 62 | * the same options must also be specified when decoding. 63 | * 64 | * \note At the moment, none of the BCJ filters support 65 | * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified, 66 | * LZMA_OPTIONS_ERROR will be returned. If there is need, 67 | * partial support for LZMA_SYNC_FLUSH can be added in future. 68 | * Partial means that flushing would be possible only at 69 | * offsets that are multiple of 2, 4, or 16 depending on 70 | * the filter, except x86 which cannot be made to support 71 | * LZMA_SYNC_FLUSH predictably. 72 | */ 73 | typedef struct { 74 | /** 75 | * \brief Start offset for conversions 76 | * 77 | * This setting is useful only when the same filter is used 78 | * _separately_ for multiple sections of the same executable file, 79 | * and the sections contain cross-section branch/call/jump 80 | * instructions. In that case it is beneficial to set the start 81 | * offset of the non-first sections so that the relative addresses 82 | * of the cross-section branch/call/jump instructions will use the 83 | * same absolute addresses as in the first section. 84 | * 85 | * When the pointer to options is NULL, the default value (zero) 86 | * is used. 87 | */ 88 | uint32_t start_offset; 89 | 90 | } lzma_options_bcj; 91 | -------------------------------------------------------------------------------- /man/digest.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{digest.gdsn} 2 | \alias{digest.gdsn} 3 | \title{create hash function digests} 4 | \description{ 5 | Create hash function digests for a GDS node. 6 | } 7 | 8 | \usage{ 9 | digest.gdsn(node, algo=c("md5", "sha1", "sha256", "sha384", "sha512"), 10 | action=c("none", "Robject", "add", "add.Robj", "clear", "verify", "return")) 11 | } 12 | \arguments{ 13 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 14 | \item{algo}{the algorithm to be used; currently available choices are 15 | "md5" (by default), "sha1", "sha256", "sha384", "sha512"} 16 | \item{action}{"none": nothing (by default); "Robject": convert to R object, 17 | i.e., raw, integer, double or character before applying hash digests; 18 | "add": add a barcode attribute; "add.Robj": add a barcode attribute 19 | generated from R object; "clear": remove all hash barcodes; 20 | "verify": verify data integrity if there is any hash code in the 21 | attributes, and stop if any fails; "return": compare the existing hash 22 | code in the attributes, and return \code{FALSE} if fails, \code{NA} if 23 | no hash code, and \code{TRUE} if the verification succeeds} 24 | } 25 | \details{ 26 | The R package \code{digest} should be installed to perform hash function 27 | digests. 28 | } 29 | \value{ 30 | A character or \code{NA_character_} when the hash algorithm is not 31 | available. 32 | } 33 | 34 | \author{Xiuwen Zheng} 35 | 36 | \examples{ 37 | library(digest) 38 | library(tools) 39 | 40 | # cteate a GDS file 41 | f <- createfn.gds("test.gds") 42 | 43 | val <- as.raw(rep(1:128, 1024)) 44 | n1 <- add.gdsn(f, "raw1", val) 45 | n2 <- add.gdsn(f, "int1", as.integer(val)) 46 | n3 <- add.gdsn(f, "int2", as.integer(val), compress="ZIP", closezip=TRUE) 47 | 48 | digest.gdsn(n1) 49 | digest.gdsn(n1, action="Robject") 50 | digest.gdsn(n1, action="add") 51 | digest.gdsn(n1, action="add.Robj") 52 | writeBin(read.gdsn(n1, .useraw=TRUE), con="test1.bin") 53 | 54 | write.gdsn(n1, 0, start=1027, count=1) 55 | digest.gdsn(n1, action="add") 56 | digest.gdsn(n1, action="add.Robj") 57 | digest.gdsn(n1, "sha1", action="add") 58 | digest.gdsn(n1, "sha256", action="add") 59 | # digest.gdsn(n1, "sha384", action="add") ## digest_0.6.11 does not work 60 | digest.gdsn(n1, "sha512", action="add") 61 | writeBin(read.gdsn(n1, .useraw=TRUE), con="test2.bin") 62 | 63 | print(n1, attribute=TRUE) 64 | digest.gdsn(n1, action="verify") 65 | 66 | digest.gdsn(n1, action="clear") 67 | print(n1, attribute=TRUE) 68 | 69 | 70 | digest.gdsn(n2) 71 | digest.gdsn(n2, action="Robject") 72 | 73 | # using R object 74 | digest.gdsn(n2) == digest.gdsn(n3) # FALSE 75 | digest.gdsn(n2, action="Robject") == digest.gdsn(n3, action="Robject") # TRUE 76 | 77 | # close the GDS file 78 | closefn.gds(f) 79 | 80 | # check with other program 81 | md5sum(c("test1.bin", "test2.bin")) 82 | 83 | 84 | # delete the temporary file 85 | unlink(c("test.gds", "test1.bin", "test2.bin"), force=TRUE) 86 | } 87 | 88 | \keyword{GDS} 89 | \keyword{utilities} 90 | -------------------------------------------------------------------------------- /man/read.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{read.gdsn} 2 | \alias{read.gdsn} 3 | \title{Read data field of a GDS node} 4 | \description{ 5 | Get data from a GDS node. 6 | } 7 | 8 | \usage{ 9 | read.gdsn(node, start=NULL, count=NULL, 10 | simplify=c("auto", "none", "force"), .useraw=FALSE, .value=NULL, 11 | .substitute=NULL, .sparse=TRUE) 12 | } 13 | \arguments{ 14 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 15 | \item{start}{a vector of integers, starting from 1 for each dimension 16 | component} 17 | \item{count}{a vector of integers, the length of each dimnension. As a 18 | special case, the value "-1" indicates that all entries along that 19 | dimension should be read, starting from \code{start}} 20 | \item{simplify}{if \code{"auto"}, the result is collapsed to be a vector 21 | if possible; \code{"force"}, the result is forced to be a vector} 22 | \item{.useraw}{use R RAW storage mode if integers can be stored in a byte, 23 | to reduce memory usage} 24 | \item{.value}{a vector of values to be replaced in the original data array, 25 | or NULL for nothing} 26 | \item{.substitute}{a vector of values after replacing, or NULL for 27 | nothing; \code{length(.substitute)} should be one or 28 | \code{length(.value)}; if \code{length(.substitute)} = 29 | \code{length(.value)}, it is a mapping from \code{.value} to 30 | \code{.substitute}} 31 | \item{.sparse}{only applicable for the sparse array nodes, if \code{TRUE} 32 | and it is a vector or matrix, return a \code{Matrix::dgCMatrix} object} 33 | } 34 | \details{ 35 | \code{start}, \code{count}: the values in data are taken to be those 36 | in the array with the leftmost subscript moving fastest. 37 | } 38 | \value{ 39 | Return an array, \code{list}, or \code{data.frame}. 40 | } 41 | 42 | \author{Xiuwen Zheng} 43 | \seealso{ 44 | \code{\link{readex.gdsn}}, \code{\link{append.gdsn}}, 45 | \code{\link{write.gdsn}}, \code{\link{add.gdsn}} 46 | } 47 | 48 | \examples{ 49 | # cteate a GDS file 50 | f <- createfn.gds("test.gds") 51 | 52 | add.gdsn(f, "vector", 1:128) 53 | add.gdsn(f, "list", list(X=1:10, Y=seq(1, 10, 0.25))) 54 | add.gdsn(f, "data.frame", data.frame(X=1:19, Y=seq(1, 10, 0.5))) 55 | add.gdsn(f, "matrix", matrix(1:12, ncol=4)) 56 | 57 | f 58 | 59 | read.gdsn(index.gdsn(f, "vector")) 60 | read.gdsn(index.gdsn(f, "list")) 61 | read.gdsn(index.gdsn(f, "data.frame")) 62 | 63 | 64 | # the effects of 'simplify' 65 | read.gdsn(index.gdsn(f, "matrix"), start=c(2,2), count=c(-1,1)) 66 | # [1] 5 6 <- a vector 67 | 68 | read.gdsn(index.gdsn(f, "matrix"), start=c(2,2), count=c(-1,1), 69 | simplify="none") 70 | # [,1] <- a matrix 71 | # [1,] 5 72 | # [2,] 6 73 | 74 | read.gdsn(index.gdsn(f, "matrix"), start=c(2,2), count=c(-1,3)) 75 | read.gdsn(index.gdsn(f, "matrix"), start=c(2,2), count=c(-1,3), 76 | .value=c(12,5), .substitute=NA) 77 | 78 | 79 | # close the GDS file 80 | closefn.gds(f) 81 | 82 | 83 | # delete the temporary file 84 | unlink("test.gds", force=TRUE) 85 | } 86 | 87 | \keyword{GDS} 88 | \keyword{utilities} 89 | -------------------------------------------------------------------------------- /man/addfolder.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{addfolder.gdsn} 2 | \alias{addfolder.gdsn} 3 | \title{Add a folder to the GDS node} 4 | \description{ 5 | Add a directory or a virtual folder to the GDS node. 6 | } 7 | 8 | \usage{ 9 | addfolder.gdsn(node, name, type=c("directory", "virtual"), gds.fn="", 10 | replace=FALSE, visible=TRUE) 11 | } 12 | 13 | \arguments{ 14 | \item{node}{an object of class \code{\link{gdsn.class}} or 15 | \code{\link{gds.class}}} 16 | \item{name}{the variable name; if it is not specified, a temporary name 17 | is assigned} 18 | \item{type}{"directory" (default) -- create a directory of GDS node; 19 | "virtual" -- create a virtual folder linking another GDS file by 20 | mapping all of the content to this virtual folder} 21 | \item{gds.fn}{the name of another GDS file; it is applicable only if 22 | \code{type="virtual"}} 23 | \item{replace}{if \code{TRUE}, replace the existing variable silently 24 | if possible} 25 | \item{visible}{\code{FALSE} -- invisible/hidden, except 26 | \code{print(, all=TRUE)}} 27 | } 28 | 29 | \value{ 30 | An object of class \code{\link{gdsn.class}}. 31 | } 32 | 33 | \author{Xiuwen Zheng} 34 | \seealso{ 35 | \code{\link{add.gdsn}}, \code{\link{addfile.gdsn}} 36 | } 37 | 38 | \examples{ 39 | # create the first GDS file 40 | f1 <- createfn.gds("test1.gds") 41 | 42 | add.gdsn(f1, "NULL") 43 | addfolder.gdsn(f1, "dir") 44 | add.gdsn(f1, "int", 1:100) 45 | f1 46 | 47 | # open the GDS file 48 | closefn.gds(f1) 49 | 50 | ############################################## 51 | 52 | # create the second GDS file 53 | f2 <- createfn.gds("test2.gds") 54 | 55 | add.gdsn(f2, "int", 101:200) 56 | 57 | # link to the first file 58 | addfolder.gdsn(f2, "virtual_folder", type="virtual", gds.fn="test1.gds") 59 | 60 | f2 61 | 62 | # open the GDS file 63 | closefn.gds(f2) 64 | 65 | 66 | ############################################## 67 | 68 | # open the second file (writable) 69 | (f <- openfn.gds("test2.gds", FALSE)) 70 | # + [ ] 71 | # |--+ int { Int32 100, 400 bytes } 72 | # |--+ virtual_folder [ --> test1.gds ] 73 | # | |--+ NULL 74 | # | |--+ dir [ ] 75 | # | |--+ int { Int32 100, 400 bytes } 76 | 77 | read.gdsn(index.gdsn(f, "int")) 78 | read.gdsn(index.gdsn(f, "virtual_folder/int")) 79 | add.gdsn(index.gdsn(f, "virtual_folder/dir"), "nm", 1:10) 80 | 81 | f 82 | 83 | # open the GDS file 84 | closefn.gds(f) 85 | 86 | 87 | ############################################## 88 | # open 'test1.gds', there is a new variable "dir/nm" 89 | 90 | (f <- openfn.gds("test1.gds")) 91 | closefn.gds(f) 92 | 93 | 94 | ############################################## 95 | # remove 'test1.gds' 96 | 97 | file.remove("test1.gds") 98 | 99 | \dontrun{ 100 | (f <- openfn.gds("test2.gds")) 101 | # + [ ] 102 | # |--+ int { Int32 100, 400 bytes } 103 | # |--+ virtual_folder [ -X- test1.gds ] 104 | 105 | closefn.gds(f)} 106 | 107 | # delete the temporary file 108 | unlink("test.gds", force=TRUE) 109 | } 110 | 111 | \keyword{GDS} 112 | \keyword{utilities} 113 | -------------------------------------------------------------------------------- /src/ZLIB/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /man/openfn.gds.Rd: -------------------------------------------------------------------------------- 1 | \name{openfn.gds} 2 | \alias{openfn.gds} 3 | \title{Open a GDS file} 4 | \description{ 5 | Open an existing file of CoreArray Genomic Data Structure (GDS) for 6 | reading or writing. 7 | } 8 | 9 | \usage{ 10 | openfn.gds(filename, readonly=TRUE, allow.duplicate=FALSE, allow.fork=FALSE, 11 | allow.error=FALSE, use.abspath=TRUE) 12 | } 13 | \arguments{ 14 | \item{filename}{the file name of a GDS file to be opened} 15 | \item{readonly}{if \code{TRUE}, the file is opened read-only; 16 | otherwise, it is allowed to write data to the file} 17 | \item{allow.duplicate}{if \code{TRUE}, it is allowed to open a GDS file 18 | with read-only mode when it has been opened in the same R session} 19 | \item{allow.fork}{\code{TRUE} for parallel environment using forking, 20 | see details} 21 | \item{allow.error}{\code{TRUE} for data recovery from a crashed GDS file} 22 | \item{use.abspath}{if \code{TRUE}, 'filename' of the gds.class object is 23 | set to be the absolute path} 24 | } 25 | \details{ 26 | This function opens an existing GDS file for reading (or, if 27 | \code{readonly=FALSE}, for writing). To create a new GDS file, use 28 | \code{\link{createfn.gds}} instead. 29 | 30 | If the file is opened read-only, all data in the file are not allowed to 31 | be changed, including hierachical structure, variable names, data fields, etc. 32 | 33 | \code{\link{mclapply}} and \code{\link{mcmapply}} in 34 | the R package \code{parallel} rely on unix forking. However, the forked child 35 | process inherits copies of the parent's set of open file descriptors. Each 36 | file descriptor in the child refers to the same open file description as the 37 | corresponding file descriptor in the parent. This means that the two 38 | descriptors share open file status flags, current file offset, and 39 | signal-driven I/O attributes. The sharing of file description can cause a 40 | serious problem (wrong reading, even program crashes), when child processes 41 | read or write the same GDS file simultaneously. 42 | \code{allow.fork=TRUE} adds additional file operations to avoid any 43 | conflict using forking. The current implementation does not support writing 44 | in forked processes. 45 | } 46 | \value{ 47 | Return an object of class \code{\link{gds.class}}. 48 | \item{filename}{the file name to be created} 49 | \item{id}{internal file id, an integer} 50 | \item{root}{an object of class \code{\link{gdsn.class}}, 51 | the root of hierachical structure} 52 | \item{readonly}{whether it is read-only or not} 53 | } 54 | 55 | \author{Xiuwen Zheng} 56 | \seealso{ 57 | \code{\link{createfn.gds}}, \code{\link{closefn.gds}} 58 | } 59 | 60 | \examples{ 61 | # cteate a GDS file 62 | f <- createfn.gds("test.gds") 63 | 64 | # add a list to "test.gds" 65 | node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE)) 66 | # close 67 | closefn.gds(f) 68 | 69 | # open the same file 70 | f <- openfn.gds("test.gds") 71 | 72 | # read 73 | (node <- index.gdsn(f, "list")) 74 | read.gdsn(node) 75 | 76 | # close the GDS file 77 | closefn.gds(f) 78 | 79 | 80 | # delete the temporary file 81 | unlink("test.gds", force=TRUE) 82 | } 83 | 84 | \keyword{GDS} 85 | \keyword{utilities} 86 | -------------------------------------------------------------------------------- /src/ZLIB/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. *sourceLen is 13 | the byte length of the source buffer. Upon entry, *destLen is the total size 14 | of the destination buffer, which must be large enough to hold the entire 15 | uncompressed data. (The size of the uncompressed data must have been saved 16 | previously by the compressor and transmitted to the decompressor by some 17 | mechanism outside the scope of this compression library.) Upon exit, 18 | *destLen is the size of the decompressed data and *sourceLen is the number 19 | of source bytes consumed. Upon return, source + *sourceLen points to the 20 | first unused input byte. 21 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is 25 | an incomplete zlib stream. 26 | */ 27 | int ZEXPORT uncompress2( 28 | Bytef *dest, 29 | uLongf *destLen, 30 | const Bytef *source, 31 | uLong *sourceLen) 32 | { 33 | z_stream stream; 34 | int err; 35 | const uInt max = (uInt)-1; 36 | uLong len, left; 37 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ 38 | 39 | len = *sourceLen; 40 | if (*destLen) { 41 | left = *destLen; 42 | *destLen = 0; 43 | } 44 | else { 45 | left = 1; 46 | dest = buf; 47 | } 48 | 49 | stream.next_in = (z_const Bytef *)source; 50 | stream.avail_in = 0; 51 | stream.zalloc = (alloc_func)0; 52 | stream.zfree = (free_func)0; 53 | stream.opaque = (voidpf)0; 54 | 55 | err = inflateInit(&stream); 56 | if (err != Z_OK) return err; 57 | 58 | stream.next_out = dest; 59 | stream.avail_out = 0; 60 | 61 | do { 62 | if (stream.avail_out == 0) { 63 | stream.avail_out = left > (uLong)max ? max : (uInt)left; 64 | left -= stream.avail_out; 65 | } 66 | if (stream.avail_in == 0) { 67 | stream.avail_in = len > (uLong)max ? max : (uInt)len; 68 | len -= stream.avail_in; 69 | } 70 | err = inflate(&stream, Z_NO_FLUSH); 71 | } while (err == Z_OK); 72 | 73 | *sourceLen -= len + stream.avail_in; 74 | if (dest != buf) 75 | *destLen = stream.total_out; 76 | else if (stream.total_out && err == Z_BUF_ERROR) 77 | left = 1; 78 | 79 | inflateEnd(&stream); 80 | return err == Z_STREAM_END ? Z_OK : 81 | err == Z_NEED_DICT ? Z_DATA_ERROR : 82 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : 83 | err; 84 | } 85 | 86 | int ZEXPORT uncompress( 87 | Bytef *dest, 88 | uLongf *destLen, 89 | const Bytef *source, 90 | uLong sourceLen) 91 | { 92 | return uncompress2(dest, destLen, source, &sourceLen); 93 | } 94 | -------------------------------------------------------------------------------- /man/readex.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{readex.gdsn} 2 | \alias{readex.gdsn} 3 | \title{Read data field of a GDS node with a selection} 4 | \description{ 5 | Get data from a GDS node with subset selection. 6 | } 7 | 8 | \usage{ 9 | readex.gdsn(node, sel=NULL, simplify=c("auto", "none", "force"), 10 | .useraw=FALSE, .value=NULL, .substitute=NULL, .sparse=TRUE) 11 | } 12 | \arguments{ 13 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 14 | \item{sel}{a list of \code{m} logical vectors, where \code{m} is the 15 | number of dimensions of \code{node} and each logical vector should 16 | have the same size of dimension in \code{node}} 17 | \item{simplify}{if \code{"auto"}, the result is collapsed to be a vector 18 | if possible; \code{"force"}, the result is forced to be a vector} 19 | \item{.useraw}{use R RAW storage mode if integers can be stored in a byte, 20 | to reduce memory usage} 21 | \item{.value}{a vector of values to be replaced in the original data array, 22 | or NULL for nothing} 23 | \item{.substitute}{a vector of values after replacing, or NULL for 24 | nothing; \code{length(.substitute)} should be one or 25 | \code{length(.value)}; if \code{length(.substitute)} = 26 | \code{length(.value)}, it is a mapping from \code{.value} to 27 | \code{.substitute}} 28 | \item{.sparse}{only applicable for the sparse array nodes, if \code{TRUE} 29 | and it is a vector or matrix, return a \code{Matrix::dgCMatrix} object} 30 | } 31 | \details{ 32 | If \code{sel} is a list of numeric vectors, the internal method converts 33 | the numeric vectors to logical vectors first, extract data with logical 34 | vectors, and then call \code{\link{[}} to reorder or expend data. 35 | } 36 | \value{ 37 | Return an array. 38 | } 39 | 40 | \author{Xiuwen Zheng} 41 | \seealso{ 42 | \code{\link{read.gdsn}}, \code{\link{append.gdsn}}, 43 | \code{\link{write.gdsn}}, \code{\link{add.gdsn}} 44 | } 45 | 46 | \examples{ 47 | # cteate a GDS file 48 | f <- createfn.gds("test.gds") 49 | 50 | add.gdsn(f, "vector", 1:128) 51 | add.gdsn(f, "matrix", matrix(as.character(1:(10*6)), nrow=10)) 52 | f 53 | 54 | # read vector 55 | readex.gdsn(index.gdsn(f, "vector"), sel=rep(c(TRUE, FALSE), 64)) 56 | readex.gdsn(index.gdsn(f, "vector"), sel=c(4:8, 1, 2, 12)) 57 | readex.gdsn(index.gdsn(f, "vector"), sel=-1:-10) 58 | 59 | readex.gdsn(index.gdsn(f, "vector"), sel=c(4, 1, 10, NA, 12, NA)) 60 | readex.gdsn(index.gdsn(f, "vector"), sel=c(4, 1, 10, NA, 12, NA), 61 | .value=c(NA, 1, 12), .substitute=c(6, 7, NA)) 62 | 63 | 64 | # read matrix 65 | readex.gdsn(index.gdsn(f, "matrix")) 66 | readex.gdsn(index.gdsn(f, "matrix"), 67 | sel=list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3))) 68 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(NULL, c(1,3,6))) 69 | readex.gdsn(index.gdsn(f, "matrix"), 70 | sel=list(rep(c(TRUE, FALSE), 5), c(1,3,6))) 71 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(c(1,3,6,10), c(1,3,6))) 72 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(c(-1,-3), -6)) 73 | 74 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(c(1,3,NA,10), c(1,3,NA,5))) 75 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(c(1,3,NA,10), c(1,3,NA,5)), 76 | simplify="force") 77 | 78 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(c(1,3,NA,10), c(1,3,NA,5))) 79 | readex.gdsn(index.gdsn(f, "matrix"), sel=list(c(1,3,NA,10), c(1,3,NA,5)), 80 | .value=NA, .substitute="X") 81 | 82 | 83 | # close the GDS file 84 | closefn.gds(f) 85 | 86 | 87 | # delete the temporary file 88 | unlink("test.gds", force=TRUE) 89 | } 90 | 91 | \keyword{GDS} 92 | \keyword{utilities} 93 | -------------------------------------------------------------------------------- /src/Makevars.win: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | ### CoreArray Codes ### 3 | ### ### 4 | 5 | # additional preprocessor options 6 | PKG_CPPFLAGS = -DUSING_R -D_FILE_OFFSET_BITS=64 -I../inst/include -ICoreArray 7 | 8 | # to set flags for the linker 9 | PKG_LIBS = ./liblzma.a 10 | 11 | SOURCES = \ 12 | R_CoreArray.cpp \ 13 | gdsfmt.cpp \ 14 | digest.cpp \ 15 | CoreArray/CoreArray.cpp \ 16 | CoreArray/dAllocator.cpp \ 17 | CoreArray/dAny.cpp \ 18 | CoreArray/dBase.cpp \ 19 | CoreArray/dBitGDS.cpp \ 20 | CoreArray/dEndian.cpp \ 21 | CoreArray/dFile.cpp \ 22 | CoreArray/dParallel.cpp \ 23 | CoreArray/dParallel_Ext.c \ 24 | CoreArray/dPlatform.cpp \ 25 | CoreArray/dRealGDS.cpp \ 26 | CoreArray/dSerial.cpp \ 27 | CoreArray/dStrGDS.cpp \ 28 | CoreArray/dStream.cpp \ 29 | CoreArray/dStruct.cpp \ 30 | CoreArray/dSparse.cpp \ 31 | CoreArray/dVLIntGDS.cpp \ 32 | ZLIB/adler32.c \ 33 | ZLIB/compress.c \ 34 | ZLIB/crc32.c \ 35 | ZLIB/deflate.c \ 36 | ZLIB/infback.c \ 37 | ZLIB/inffast.c \ 38 | ZLIB/inflate.c \ 39 | ZLIB/inftrees.c \ 40 | ZLIB/trees.c \ 41 | ZLIB/uncompr.c \ 42 | ZLIB/zutil.c \ 43 | LZ4/lz4.c \ 44 | LZ4/lz4hc.c \ 45 | LZ4/lz4frame.c \ 46 | LZ4/xxhash.c 47 | 48 | OBJECTS = \ 49 | R_CoreArray.o \ 50 | gdsfmt.o \ 51 | digest.o \ 52 | CoreArray/CoreArray.o \ 53 | CoreArray/dAllocator.o \ 54 | CoreArray/dAny.o \ 55 | CoreArray/dBase.o \ 56 | CoreArray/dBitGDS.o \ 57 | CoreArray/dEndian.o \ 58 | CoreArray/dFile.o \ 59 | CoreArray/dParallel.o \ 60 | CoreArray/dParallel_Ext.o \ 61 | CoreArray/dPlatform.o \ 62 | CoreArray/dRealGDS.o \ 63 | CoreArray/dSerial.o \ 64 | CoreArray/dStrGDS.o \ 65 | CoreArray/dStream.o \ 66 | CoreArray/dStruct.o \ 67 | CoreArray/dVLIntGDS.o \ 68 | CoreArray/dSparse.o \ 69 | ZLIB/adler32.o \ 70 | ZLIB/compress.o \ 71 | ZLIB/crc32.o \ 72 | ZLIB/deflate.o \ 73 | ZLIB/infback.o \ 74 | ZLIB/inffast.o \ 75 | ZLIB/inflate.o \ 76 | ZLIB/inftrees.o \ 77 | ZLIB/trees.o \ 78 | ZLIB/uncompr.o \ 79 | ZLIB/zutil.o \ 80 | LZ4/lz4.o \ 81 | LZ4/lz4hc.o \ 82 | LZ4/lz4frame.o \ 83 | LZ4/xxhash.o 84 | 85 | 86 | all: $(SHLIB) 87 | 88 | $(SHLIB): liblzma.a 89 | 90 | 91 | ZLIB/adler32.o: 92 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/adler32.c -o $@ 93 | 94 | ZLIB/compress.o: 95 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/compress.c -o $@ 96 | 97 | ZLIB/crc32.o: 98 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/crc32.c -o $@ 99 | 100 | ZLIB/deflate.o: 101 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/deflate.c -o $@ 102 | 103 | ZLIB/infback.o: 104 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/infback.c -o $@ 105 | 106 | ZLIB/inffast.o: 107 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/inffast.c -o $@ 108 | 109 | ZLIB/inflate.o: 110 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/inflate.c -o $@ 111 | 112 | ZLIB/inftrees.o: 113 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/inftrees.c -o $@ 114 | 115 | ZLIB/trees.o: 116 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/trees.c -o $@ 117 | 118 | ZLIB/uncompr.o: 119 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/uncompr.c -o $@ 120 | 121 | ZLIB/zutil.o: 122 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/zutil.c -o $@ 123 | 124 | 125 | liblzma.a: 126 | cd XZ && unzip -o -q xz-5.2.9-win.zip 127 | cp XZ/xz-5.2.9-win${R_ARCH}/liblzma.a . 128 | 129 | 130 | clean: 131 | rm -f $(OBJECTS) 132 | rm -f ../.gitignore 133 | rm -f liblzma.a 134 | rm -rf ../.github 135 | rm -rf XZ/xz-5.2.9 136 | -------------------------------------------------------------------------------- /inst/unitTests/test_03_dimension.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: test data dimension 4 | # 5 | 6 | source(system.file("unitTests", "include.r", package="gdsfmt")) 7 | 8 | 9 | 10 | ############################################################# 11 | # 12 | # test functions 13 | # 14 | 15 | test.data.dimension <- function() 16 | { 17 | on.exit({ 18 | showfile.gds(closeall=TRUE, verbose=FALSE) 19 | unlink("tmp.gds", force=TRUE) 20 | }) 21 | 22 | # create a new gds file 23 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 24 | 25 | # one dimension: 26 | dta <- seq(0, 1999) 27 | node <- add.gdsn(gfile, "data1", val=dta) 28 | checkEquals(read.gdsn(node), dta, "data.dimension: one dimension") 29 | setdim.gdsn(node, 100) 30 | checkEquals(read.gdsn(node), dta[1:100], "data.dimension: one dimension") 31 | 32 | # two dimensions: 33 | dta <- matrix(seq(0, 1999), nrow=50, ncol=40) 34 | node <- add.gdsn(gfile, "data2", val=dta) 35 | checkEquals(read.gdsn(node), dta, "data.dimension: two dimensions") 36 | setdim.gdsn(node, c(40, 40)) 37 | checkEquals(read.gdsn(node), matrix(seq(0, 1599), nrow=40, ncol=40), 38 | "data.dimension: two dimensions") 39 | 40 | # three dimensions: 41 | dta <- array(seq(0, 999), c(20, 10, 5)) 42 | node <- add.gdsn(gfile, "data3", val=dta) 43 | checkEquals(read.gdsn(node), dta, "data.dimension: three dimensions") 44 | setdim.gdsn(node, c(15, 10, 5)) 45 | checkEquals(read.gdsn(node), array(0:749, dim=c(15, 10, 5)), 46 | "data.dimension: three dimensions") 47 | 48 | # close the gds file 49 | closefn.gds(gfile) 50 | } 51 | 52 | 53 | test.data.append <- function() 54 | { 55 | on.exit({ 56 | showfile.gds(closeall=TRUE, verbose=FALSE) 57 | unlink("tmp.gds", force=TRUE) 58 | }) 59 | 60 | verbose <- options("test.verbose")$test.verbose 61 | if (verbose) cat("\n>>>> test.data.append <<<<\n") 62 | 63 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 64 | 65 | for (n in type.list) 66 | { 67 | if (verbose) 68 | cat(n, "\t", sep="") 69 | 70 | dta1 <- matrix(valid.dta[[sprintf("valid1.%s", n)]], nrow=50) 71 | dta2 <- dta1[, 1:30] 72 | 73 | # create a new gds file 74 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 75 | 76 | # append data 77 | node <- add.gdsn(gfile, "data", val=dta1) 78 | append.gdsn(node, dta2) 79 | 80 | checkEquals(read.gdsn(node), cbind(dta1, dta2), 81 | sprintf("data append: %s", n)) 82 | 83 | # close the gds file 84 | closefn.gds(gfile) 85 | } 86 | } 87 | 88 | 89 | test.data.append.compress <- function() 90 | { 91 | on.exit({ 92 | showfile.gds(closeall=TRUE, verbose=FALSE) 93 | unlink("tmp.gds", force=TRUE) 94 | }) 95 | 96 | verbose <- options("test.verbose")$test.verbose 97 | if (verbose) cat("\n\n>>>> test.data.append.compress <<<<\n") 98 | 99 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 100 | 101 | for (cp in compress.list) 102 | { 103 | if (verbose) 104 | cat("Compression:", cp, "\n", sep="") 105 | 106 | for (n in type.list) 107 | { 108 | if (verbose) cat(n, "\t", sep="") 109 | 110 | dta1 <- matrix(valid.dta[[sprintf("valid1.%s", n)]], nrow=50) 111 | dta2 <- dta1[, 1:30] 112 | 113 | # create a new gds file 114 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 115 | 116 | # append data 117 | node <- add.gdsn(gfile, "data", val=dta1, compress=cp) 118 | append.gdsn(node, dta2) 119 | readmode.gdsn(node) 120 | 121 | checkEquals(read.gdsn(node), cbind(dta1, dta2), 122 | sprintf("data append: %s with compression %s", n, cp)) 123 | 124 | # close the gds file 125 | closefn.gds(gfile) 126 | } 127 | 128 | if (verbose) cat("\n") 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/Makevars: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | ### CoreArray Codes ### 3 | ### ### 4 | 5 | # additional preprocessor options 6 | PKG_CPPFLAGS = -DUSING_R -D_FILE_OFFSET_BITS=64 -I../inst/include -ICoreArray 7 | 8 | # to set flags for the linker 9 | PKG_LIBS = ./liblzma.a -lpthread 10 | 11 | SOURCES = \ 12 | R_CoreArray.cpp \ 13 | gdsfmt.cpp \ 14 | digest.cpp \ 15 | CoreArray/CoreArray.cpp \ 16 | CoreArray/dAllocator.cpp \ 17 | CoreArray/dAny.cpp \ 18 | CoreArray/dBase.cpp \ 19 | CoreArray/dBitGDS.cpp \ 20 | CoreArray/dEndian.cpp \ 21 | CoreArray/dFile.cpp \ 22 | CoreArray/dParallel.cpp \ 23 | CoreArray/dParallel_Ext.c \ 24 | CoreArray/dPlatform.cpp \ 25 | CoreArray/dRealGDS.cpp \ 26 | CoreArray/dSerial.cpp \ 27 | CoreArray/dStrGDS.cpp \ 28 | CoreArray/dStream.cpp \ 29 | CoreArray/dStruct.cpp \ 30 | CoreArray/dSparse.cpp \ 31 | CoreArray/dVLIntGDS.cpp \ 32 | ZLIB/adler32.c \ 33 | ZLIB/compress.c \ 34 | ZLIB/crc32.c \ 35 | ZLIB/deflate.c \ 36 | ZLIB/infback.c \ 37 | ZLIB/inffast.c \ 38 | ZLIB/inflate.c \ 39 | ZLIB/inftrees.c \ 40 | ZLIB/trees.c \ 41 | ZLIB/uncompr.c \ 42 | ZLIB/zutil.c \ 43 | LZ4/lz4.c \ 44 | LZ4/lz4hc.c \ 45 | LZ4/lz4frame.c \ 46 | LZ4/xxhash.c 47 | 48 | OBJECTS = \ 49 | R_CoreArray.o \ 50 | gdsfmt.o \ 51 | digest.o \ 52 | CoreArray/CoreArray.o \ 53 | CoreArray/dAllocator.o \ 54 | CoreArray/dAny.o \ 55 | CoreArray/dBase.o \ 56 | CoreArray/dBitGDS.o \ 57 | CoreArray/dEndian.o \ 58 | CoreArray/dFile.o \ 59 | CoreArray/dParallel.o \ 60 | CoreArray/dParallel_Ext.o \ 61 | CoreArray/dPlatform.o \ 62 | CoreArray/dRealGDS.o \ 63 | CoreArray/dSerial.o \ 64 | CoreArray/dStrGDS.o \ 65 | CoreArray/dStream.o \ 66 | CoreArray/dStruct.o \ 67 | CoreArray/dSparse.o \ 68 | CoreArray/dVLIntGDS.o \ 69 | ZLIB/adler32.o \ 70 | ZLIB/compress.o \ 71 | ZLIB/crc32.o \ 72 | ZLIB/deflate.o \ 73 | ZLIB/infback.o \ 74 | ZLIB/inffast.o \ 75 | ZLIB/inflate.o \ 76 | ZLIB/inftrees.o \ 77 | ZLIB/trees.o \ 78 | ZLIB/uncompr.o \ 79 | ZLIB/zutil.o \ 80 | LZ4/lz4.o \ 81 | LZ4/lz4hc.o \ 82 | LZ4/lz4frame.o \ 83 | LZ4/xxhash.o 84 | 85 | 86 | all: $(SHLIB) 87 | 88 | $(SHLIB): liblzma.a 89 | 90 | 91 | ZLIB/adler32.o: 92 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/adler32.c -o $@ 93 | 94 | ZLIB/compress.o: 95 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/compress.c -o $@ 96 | 97 | ZLIB/crc32.o: 98 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/crc32.c -o $@ 99 | 100 | ZLIB/deflate.o: 101 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/deflate.c -o $@ 102 | 103 | ZLIB/infback.o: 104 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/infback.c -o $@ 105 | 106 | ZLIB/inffast.o: 107 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/inffast.c -o $@ 108 | 109 | ZLIB/inflate.o: 110 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/inflate.c -o $@ 111 | 112 | ZLIB/inftrees.o: 113 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/inftrees.c -o $@ 114 | 115 | ZLIB/trees.o: 116 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/trees.c -o $@ 117 | 118 | ZLIB/uncompr.o: 119 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/uncompr.c -o $@ 120 | 121 | ZLIB/zutil.o: 122 | $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -g0 ZLIB/zutil.c -o $@ 123 | 124 | 125 | liblzma.a: 126 | cd XZ && tar -xzf xz-5.2.9.tar.gz 127 | cd XZ/xz-5.2.9 && \ 128 | ./configure CC="${CC}" CPP="${CPP}" CXX="${CXX}" CXXCPP="${CXXCPP}" --build="${R_ARCH#*/}" \ 129 | --with-pic --enable-silent-rules --quiet --disable-xz --disable-shared > /dev/null 130 | cd XZ/xz-5.2.9/src/liblzma && make 131 | cp XZ/xz-5.2.9/src/liblzma/.libs/liblzma.a . 132 | rm -rf XZ/xz-5.2.9/dos 133 | rm -rf XZ/xz-5.2.9/po 134 | 135 | 136 | clean: 137 | rm -f $(OBJECTS) 138 | rm -f ../.gitignore 139 | rm -f liblzma.a 140 | rm -rf ../.github 141 | rm -rf XZ/xz-5.2.9 142 | -------------------------------------------------------------------------------- /src/XZ/api/lzma/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/version.h 3 | * \brief Version number 4 | */ 5 | 6 | /* 7 | * Author: Lasse Collin 8 | * 9 | * This file has been put into the public domain. 10 | * You can do whatever you want with this file. 11 | * 12 | * See ../lzma.h for information about liblzma as a whole. 13 | */ 14 | 15 | #ifndef LZMA_H_INTERNAL 16 | # error Never include this file directly. Use instead. 17 | #endif 18 | 19 | 20 | /* 21 | * Version number split into components 22 | */ 23 | #define LZMA_VERSION_MAJOR 5 24 | #define LZMA_VERSION_MINOR 2 25 | #define LZMA_VERSION_PATCH 9 26 | #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE 27 | 28 | #ifndef LZMA_VERSION_COMMIT 29 | # define LZMA_VERSION_COMMIT "" 30 | #endif 31 | 32 | 33 | /* 34 | * Map symbolic stability levels to integers. 35 | */ 36 | #define LZMA_VERSION_STABILITY_ALPHA 0 37 | #define LZMA_VERSION_STABILITY_BETA 1 38 | #define LZMA_VERSION_STABILITY_STABLE 2 39 | 40 | 41 | /** 42 | * \brief Compile-time version number 43 | * 44 | * The version number is of format xyyyzzzs where 45 | * - x = major 46 | * - yyy = minor 47 | * - zzz = revision 48 | * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable 49 | * 50 | * The same xyyyzzz triplet is never reused with different stability levels. 51 | * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta 52 | * or 5.1.0 stable. 53 | * 54 | * \note The version number of liblzma has nothing to with 55 | * the version number of Igor Pavlov's LZMA SDK. 56 | */ 57 | #define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \ 58 | + LZMA_VERSION_MINOR * UINT32_C(10000) \ 59 | + LZMA_VERSION_PATCH * UINT32_C(10) \ 60 | + LZMA_VERSION_STABILITY) 61 | 62 | 63 | /* 64 | * Macros to construct the compile-time version string 65 | */ 66 | #if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA 67 | # define LZMA_VERSION_STABILITY_STRING "alpha" 68 | #elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA 69 | # define LZMA_VERSION_STABILITY_STRING "beta" 70 | #elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE 71 | # define LZMA_VERSION_STABILITY_STRING "" 72 | #else 73 | # error Incorrect LZMA_VERSION_STABILITY 74 | #endif 75 | 76 | #define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \ 77 | #major "." #minor "." #patch stability commit 78 | 79 | #define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \ 80 | LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) 81 | 82 | 83 | /** 84 | * \brief Compile-time version as a string 85 | * 86 | * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable 87 | * versions don't have any "stable" suffix). In future, a snapshot built 88 | * from source code repository may include an additional suffix, for example 89 | * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form 90 | * in LZMA_VERSION macro. 91 | */ 92 | #define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \ 93 | LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \ 94 | LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \ 95 | LZMA_VERSION_COMMIT) 96 | 97 | 98 | /* #ifndef is needed for use with windres (MinGW or Cygwin). */ 99 | #ifndef LZMA_H_INTERNAL_RC 100 | 101 | /** 102 | * \brief Run-time version number as an integer 103 | * 104 | * Return the value of LZMA_VERSION macro at the compile time of liblzma. 105 | * This allows the application to compare if it was built against the same, 106 | * older, or newer version of liblzma that is currently running. 107 | */ 108 | extern LZMA_API(uint32_t) lzma_version_number(void) 109 | lzma_nothrow lzma_attr_const; 110 | 111 | 112 | /** 113 | * \brief Run-time version as a string 114 | * 115 | * This function may be useful if you want to display which version of 116 | * liblzma your application is currently using. 117 | */ 118 | extern LZMA_API(const char *) lzma_version_string(void) 119 | lzma_nothrow lzma_attr_const; 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /man/addfile.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{addfile.gdsn} 2 | \alias{addfile.gdsn} 3 | \title{Add a GDS node with a file} 4 | \description{ 5 | Add a file to a GDS file as a node. 6 | } 7 | 8 | \usage{ 9 | addfile.gdsn(node, name, filename, 10 | compress=c("ZIP", "ZIP_RA", "LZMA", "LZMA_RA", "LZ4", "LZ4_RA"), 11 | replace=FALSE, visible=TRUE) 12 | } 13 | 14 | \arguments{ 15 | \item{node}{an object of class \code{\link{gdsn.class}} or 16 | \code{\link{gds.class}}} 17 | \item{name}{the variable name; if it is not specified, a temporary name 18 | is assigned} 19 | \item{filename}{the file name of input stream.} 20 | \item{compress}{the compression method can be "" (no compression), 21 | "ZIP", "ZIP.fast", "ZIP.default", "ZIP.max" or "ZIP.none" (original 22 | zlib); "ZIP_RA", "ZIP_RA.fast", "ZIP_RA.default", "ZIP_RA.max" or 23 | "ZIP_RA.none" (zlib with efficient random access); "LZ4", "LZ4.none", 24 | "LZ4.fast", "LZ4.hc" or "LZ4.max"; "LZ4_RA", "LZ4_RA.none", 25 | "LZ4_RA.fast", "LZ4_RA.hc" or "LZ4_RA.max" (with efficient random 26 | access). See details} 27 | \item{replace}{if \code{TRUE}, replace the existing variable silently 28 | if possible} 29 | \item{visible}{\code{FALSE} -- invisible/hidden, except 30 | \code{print(, all=TRUE)}} 31 | } 32 | 33 | \details{ 34 | \code{compress}: 35 | Z compression algorithm (\url{http://www.zlib.net/}) can be used to 36 | deflate the data stored in the GDS file. "ZIP" option is equivalent 37 | to "ZIP.default". "ZIP.fast", "ZIP.default" and "ZIP.max" correspond 38 | to different compression levels. 39 | 40 | To support efficient random access of Z stream, "ZIP_RA", 41 | "ZIP_RA.fast", "ZIP_RA.default", "ZIP_RA.max" or "ZIP_RA.none" should 42 | be specified. "ZIP_RA" option is equivalent to "ZIP_RA.default:256K". 43 | The block size can be specified by following colon, and "16K", "32K", 44 | "64K", "128K", "256K", "512K", "1M", "2M", "4M" and "8M" are allowed, 45 | like "ZIP_RA:64K". The compression algorithm tries to keep each 46 | independent compressed data block to be about of the specified block 47 | size, like 64K. 48 | 49 | LZ4 fast lossless compression algorithm is allowed when 50 | \code{compress="LZ4"} (\url{https://github.com/lz4/lz4}). Three 51 | compression levels can be specified, "LZ4.fast" (LZ4 fast mode), 52 | "LZ4.hc" (LZ4 high compression mode), "LZ4.max" (maximize the 53 | compression ratio). The block size can be specified by following colon, 54 | and "64K", "256K", "1M" and "4M" are allowed according to LZ4 frame 55 | format. "LZ4" is equivalent to "LZ4.hc:256K". 56 | 57 | To support efficient random access of LZ4 stream, "LZ4_RA", 58 | "LZ4_RA.fast", "LZ4_RA.hc", "ZIP_RA.max" or "LZ4_RA.none" should 59 | be specified. "LZ4_RA" option is equivalent to "LZ4_RA.hc:256K". 60 | The block size can be specified by following colon, and "16K", "32K", 61 | "64K", "128K", "256K", "512K", "1M", "2M", "4M" and "8M" are allowed, 62 | like "LZ4_RA:64K". The compression algorithm tries to keep each 63 | independent compressed data block to be about of the specified block 64 | size, like 64K. 65 | } 66 | 67 | \value{ 68 | An object of class \code{\link{gdsn.class}}. 69 | } 70 | 71 | \author{Xiuwen Zheng} 72 | \seealso{ 73 | \code{\link{getfile.gdsn}}, \code{\link{add.gdsn}} 74 | } 75 | 76 | \examples{ 77 | # save a .RData object 78 | obj <- list(X=1:10, Y=seq(1, 10, 0.1)) 79 | save(obj, file="tmp.RData") 80 | 81 | # cteate a GDS file 82 | f <- createfn.gds("test.gds") 83 | 84 | add.gdsn(f, "double", val=seq(1, 1000, 0.4)) 85 | addfile.gdsn(f, "tmp.RData", "tmp.RData") 86 | 87 | # open the GDS file 88 | closefn.gds(f) 89 | 90 | 91 | # open the existing file 92 | (f <- openfn.gds("test.gds")) 93 | 94 | getfile.gdsn(index.gdsn(f, "tmp.RData"), "tmp1.RData") 95 | (obj <- get(load("tmp1.RData"))) 96 | 97 | # open the GDS file 98 | closefn.gds(f) 99 | 100 | 101 | # delete the temporary files 102 | unlink(c("test.gds", "tmp.RData", "tmp1.RData"), force=TRUE) 103 | } 104 | 105 | \keyword{GDS} 106 | \keyword{utilities} 107 | -------------------------------------------------------------------------------- /src/CoreArray/CoreArray.cpp: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // CoreArray.cpp: CoreArray interface 10 | // 11 | // Copyright (C) 2007-2019 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | #ifndef COREARRAY_COMPILER_OPTIMIZE_FLAG 29 | # define COREARRAY_COMPILER_OPTIMIZE_FLAG 3 30 | #endif 31 | 32 | #include "CoreDEF.h" 33 | #include "dType.h" 34 | #include "dTrait.h" 35 | #include "dPlatform.h" 36 | #include "dParallel.h" 37 | #include "dStream.h" 38 | #include "dEndian.h" 39 | #include "dSerial.h" 40 | #include "dBase.h" 41 | #include "dFile.h" 42 | #include "dStruct.h" 43 | 44 | 45 | namespace CoreArray 46 | { 47 | static bool CoreArray_ifRegClass = false; 48 | 49 | 50 | template static CdObjRef *OnObjCreate() 51 | { 52 | return new TClass(); 53 | } 54 | 55 | extern COREARRAY_DLL_LOCAL void RegisterClass_Bit_s24(); 56 | extern COREARRAY_DLL_LOCAL void RegisterClass_Bit_u24(); 57 | extern COREARRAY_DLL_LOCAL void RegisterClass_Bit(); 58 | extern COREARRAY_DLL_LOCAL void RegisterClass_VLInt(); 59 | extern COREARRAY_DLL_LOCAL void RegisterClass_PackedReal(); 60 | extern COREARRAY_DLL_LOCAL void RegisterClass_String(); 61 | extern COREARRAY_DLL_LOCAL void RegisterClass_Sparse(); 62 | 63 | 64 | COREARRAY_DLL_DEFAULT void RegisterClass() 65 | { 66 | if (CoreArray_ifRegClass) return; 67 | 68 | #define REG_CLASS(T, CLASS, CType, Desp) \ 69 | dObjManager().AddClass(TdTraits< T >::StreamName(), \ 70 | OnObjCreate< CLASS >, CdObjClassMgr::CType, Desp) 71 | #define REG_CLASS_EX(Name, CLASS, CType, Desp) \ 72 | dObjManager().AddClass(Name, OnObjCreate< CLASS >, \ 73 | CdObjClassMgr::CType, Desp) 74 | 75 | // primitive integers 76 | REG_CLASS(C_Int8, CdInt8, ctArray, "signed integer of 8 bits"); 77 | REG_CLASS(C_Int16, CdInt16, ctArray, "signed integer of 16 bits"); 78 | RegisterClass_Bit_s24(); 79 | REG_CLASS(C_Int32, CdInt32, ctArray, "signed integer of 32 bits"); 80 | REG_CLASS(C_Int64, CdInt64, ctArray, "signed integer of 64 bits"); 81 | 82 | REG_CLASS(C_UInt8, CdUInt8, ctArray, "unsigned integer of 8 bits"); 83 | REG_CLASS(C_UInt16, CdUInt16, ctArray, "unsigned integer of 16 bits"); 84 | RegisterClass_Bit_u24(); 85 | REG_CLASS(C_UInt32, CdUInt32, ctArray, "unsigned integer of 32 bits"); 86 | REG_CLASS(C_UInt64, CdUInt64, ctArray, "unsigned integer of 64 bits"); 87 | 88 | // signed and unsigned bit integers 89 | RegisterClass_Bit(); 90 | 91 | // variable-length integers 92 | RegisterClass_VLInt(); 93 | 94 | // real numbers 95 | REG_CLASS(C_Float32, CdFloat32, ctArray, "floating-point number (32 bits)"); 96 | REG_CLASS(C_Float64, CdFloat64, ctArray, "floating-point number (64 bits)"); 97 | RegisterClass_PackedReal(); 98 | 99 | // sparse array 100 | RegisterClass_Sparse(); 101 | 102 | // fixed-length strings 103 | // variable-length null-terminated strings 104 | // variable-length strings allowing null character 105 | RegisterClass_String(); 106 | 107 | // stream container 108 | dObjManager().AddClass("dStream", OnObjCreate, 109 | CdObjClassMgr::ctStream, "stream container"); 110 | 111 | CoreArray_ifRegClass = true; 112 | 113 | #undef REG_CLASS 114 | #undef REG_CLASS_EX 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/XZ/api/lzma/index_hash.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/index_hash.h 3 | * \brief Validate Index by using a hash function 4 | * 5 | * Hashing makes it possible to use constant amount of memory to validate 6 | * Index of arbitrary size. 7 | */ 8 | 9 | /* 10 | * Author: Lasse Collin 11 | * 12 | * This file has been put into the public domain. 13 | * You can do whatever you want with this file. 14 | * 15 | * See ../lzma.h for information about liblzma as a whole. 16 | */ 17 | 18 | #ifndef LZMA_H_INTERNAL 19 | # error Never include this file directly. Use instead. 20 | #endif 21 | 22 | /** 23 | * \brief Opaque data type to hold the Index hash 24 | */ 25 | typedef struct lzma_index_hash_s lzma_index_hash; 26 | 27 | 28 | /** 29 | * \brief Allocate and initialize a new lzma_index_hash structure 30 | * 31 | * If index_hash is NULL, a new lzma_index_hash structure is allocated, 32 | * initialized, and a pointer to it returned. If allocation fails, NULL 33 | * is returned. 34 | * 35 | * If index_hash is non-NULL, it is reinitialized and the same pointer 36 | * returned. In this case, return value cannot be NULL or a different 37 | * pointer than the index_hash that was given as an argument. 38 | */ 39 | extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( 40 | lzma_index_hash *index_hash, const lzma_allocator *allocator) 41 | lzma_nothrow lzma_attr_warn_unused_result; 42 | 43 | 44 | /** 45 | * \brief Deallocate lzma_index_hash structure 46 | */ 47 | extern LZMA_API(void) lzma_index_hash_end( 48 | lzma_index_hash *index_hash, const lzma_allocator *allocator) 49 | lzma_nothrow; 50 | 51 | 52 | /** 53 | * \brief Add a new Record to an Index hash 54 | * 55 | * \param index_hash Pointer to a lzma_index_hash structure 56 | * \param unpadded_size Unpadded Size of a Block 57 | * \param uncompressed_size Uncompressed Size of a Block 58 | * 59 | * \return - LZMA_OK 60 | * - LZMA_DATA_ERROR: Compressed or uncompressed size of the 61 | * Stream or size of the Index field would grow too big. 62 | * - LZMA_PROG_ERROR: Invalid arguments or this function is being 63 | * used when lzma_index_hash_decode() has already been used. 64 | */ 65 | extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash, 66 | lzma_vli unpadded_size, lzma_vli uncompressed_size) 67 | lzma_nothrow lzma_attr_warn_unused_result; 68 | 69 | 70 | /** 71 | * \brief Decode and validate the Index field 72 | * 73 | * After telling the sizes of all Blocks with lzma_index_hash_append(), 74 | * the actual Index field is decoded with this function. Specifically, 75 | * once decoding of the Index field has been started, no more Records 76 | * can be added using lzma_index_hash_append(). 77 | * 78 | * This function doesn't use lzma_stream structure to pass the input data. 79 | * Instead, the input buffer is specified using three arguments. This is 80 | * because it matches better the internal APIs of liblzma. 81 | * 82 | * \param index_hash Pointer to a lzma_index_hash structure 83 | * \param in Pointer to the beginning of the input buffer 84 | * \param in_pos in[*in_pos] is the next byte to process 85 | * \param in_size in[in_size] is the first byte not to process 86 | * 87 | * \return - LZMA_OK: So far good, but more input is needed. 88 | * - LZMA_STREAM_END: Index decoded successfully and it matches 89 | * the Records given with lzma_index_hash_append(). 90 | * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the 91 | * information given with lzma_index_hash_append(). 92 | * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size. 93 | * - LZMA_PROG_ERROR 94 | */ 95 | extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash, 96 | const uint8_t *in, size_t *in_pos, size_t in_size) 97 | lzma_nothrow lzma_attr_warn_unused_result; 98 | 99 | 100 | /** 101 | * \brief Get the size of the Index field as bytes 102 | * 103 | * This is needed to verify the Backward Size field in the Stream Footer. 104 | */ 105 | extern LZMA_API(lzma_vli) lzma_index_hash_size( 106 | const lzma_index_hash *index_hash) 107 | lzma_nothrow lzma_attr_pure; 108 | -------------------------------------------------------------------------------- /inst/COPYRIGHTS: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | CoreArray C++ library 3 | Copyright (C) 2007-2020, Xiuwen Zheng 4 | All rights reserved. 5 | 6 | CoreArray/gdsfmt is free software: you can redistribute it and/or modify it 7 | under the terms of the GNU Lesser General Public License Version 3 as published 8 | by the Free Software Foundation. 9 | 10 | CoreArray is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 13 | details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License along 16 | with CoreArray. If not, see . 17 | 18 | 19 | 20 | 21 | ============================================================================== 22 | LZ4 Library 23 | Copyright (C) 2011-2019, Yann Collet 24 | All rights reserved. 25 | 26 | Redistribution and use in source and binary forms, with or without modification, 27 | are permitted provided that the following conditions are met: 28 | 29 | * Redistributions of source code must retain the above copyright notice, this 30 | list of conditions and the following disclaimer. 31 | 32 | * Redistributions in binary form must reproduce the above copyright notice, this 33 | list of conditions and the following disclaimer in the documentation and/or 34 | other materials provided with the distribution. 35 | 36 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 37 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 38 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 39 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 40 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 41 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 43 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 45 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | 47 | 48 | 49 | 50 | ============================================================================== 51 | Acknowledgments: 52 | 53 | The deflate format used by zlib was defined by Phil Katz. The deflate and 54 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 55 | people who reported problems and suggested various improvements in zlib; they 56 | are too numerous to cite here. 57 | 58 | Copyright notice: 59 | 60 | (C) 1995-2017 Jean-loup Gailly and Mark Adler 61 | 62 | This software is provided 'as-is', without any express or implied 63 | warranty. In no event will the authors be held liable for any damages 64 | arising from the use of this software. 65 | 66 | Permission is granted to anyone to use this software for any purpose, 67 | including commercial applications, and to alter it and redistribute it 68 | freely, subject to the following restrictions: 69 | 70 | 1. The origin of this software must not be misrepresented; you must not 71 | claim that you wrote the original software. If you use this software 72 | in a product, an acknowledgment in the product documentation would be 73 | appreciated but is not required. 74 | 2. Altered source versions must be plainly marked as such, and must not be 75 | misrepresented as being the original software. 76 | 3. This notice may not be removed or altered from any source distribution. 77 | 78 | Jean-loup Gailly Mark Adler 79 | jloup@gzip.org madler@alumni.caltech.edu 80 | 81 | If you use the zlib library in a product, we would appreciate *not* receiving 82 | lengthy legal documents to sign. The sources are provided for free but without 83 | warranty of any kind. The library has been entirely written by Jean-loup 84 | Gailly and Mark Adler; it does not include third-party code. 85 | 86 | If you redistribute modified sources, we would appreciate that you include in 87 | the file ChangeLog history information documenting your changes. Please read 88 | the FAQ for more information on the distribution of modified source versions. 89 | 90 | 91 | 92 | 93 | ============================================================================== 94 | liblzma library 95 | 2005-2018, Lasse Collin and other xz contributors 96 | http://tukaani.org/xz/ 97 | 98 | liblzma is in the public domain. 99 | -------------------------------------------------------------------------------- /man/gdsfmt-package.Rd: -------------------------------------------------------------------------------- 1 | \name{gdsfmt-package} 2 | \alias{gdsfmt-package} 3 | \alias{gdsfmt} 4 | \docType{package} 5 | \title{R Interface to CoreArray Genomic Data Structure (GDS) files} 6 | \description{ 7 | This package provides a high-level R interface to CoreArray Genomic Data 8 | Structure (GDS) data files, which are portable across platforms and include 9 | hierarchical structure to store multiple scalable array-oriented data sets 10 | with metadata information. It is suited for large-scale datasets, especially 11 | for data which are much larger than the available random-access memory. The 12 | gdsfmt package offers the efficient operations specifically designed for 13 | integers with less than 8 bits, since a single genetic/genomic variant, such 14 | like single-nucleotide polymorphism, usually occupies fewer bits than a byte. 15 | It is also allowed to read a GDS file in parallel with multiple R processes 16 | supported by the parallel package. 17 | } 18 | \details{ 19 | \tabular{ll}{ 20 | Package: \tab gdsfmt\cr 21 | Type: \tab R/Bioconductor Package\cr 22 | License: \tab LGPL version 3\cr 23 | } 24 | R interface of CoreArray GDS is based on the CoreArray project initiated 25 | and developed from 2007 (\url{http://corearray.sourceforge.net}). The CoreArray 26 | project is to develop portable, scalable, bioinformatic data visualization 27 | and storage technologies. 28 | 29 | R is the most popular statistical environment, but one not necessarily 30 | optimized for high performance or parallel computing which ease the burden of 31 | large-scale calculations. To support efficient data management in parallel for 32 | numerical genomic data, we developed the Genomic Data Structure (GDS) file 33 | format. \code{gdsfmt} provides fundamental functions to support accessing data 34 | in parallel, and allows future R packages to call these functions. 35 | 36 | Webpage: \url{http://corearray.sourceforge.net}, 37 | or \url{https://github.com/zhengxwen/gdsfmt} 38 | 39 | Copyright notice: 40 | The package includes the sources of CoreArray C++ library written by 41 | Xiuwen Zheng (LGPL-3), zlib written by Jean-loup Gailly and Mark Adler 42 | (zlib license), and LZ4 written by Yann Collet (simplified BSD). 43 | } 44 | \references{ 45 | \url{http://corearray.sourceforge.net}, 46 | \url{https://github.com/zhengxwen/gdsfmt} 47 | 48 | Xiuwen Zheng, David Levine, Jess Shen, Stephanie M. Gogarten, Cathy Laurie, 49 | Bruce S. Weir. A High-performance Computing Toolset for Relatedness and 50 | Principal Component Analysis of SNP Data. Bioinformatics 2012; 51 | doi: 10.1093/bioinformatics/bts606. 52 | } 53 | \author{Xiuwen Zheng \email{zhengx@u.washington.edu}} 54 | 55 | \examples{ 56 | # cteate a GDS file 57 | f <- createfn.gds("test.gds") 58 | L <- -2500:2499 59 | 60 | # commom types 61 | add.gdsn(f, "label", NULL) 62 | add.gdsn(f, "int", val=1:10000, compress="ZIP", closezip=TRUE) 63 | add.gdsn(f, "int.matrix", val=matrix(L, nrow=100, ncol=50)) 64 | add.gdsn(f, "mat", val=matrix(1:(10*6), nrow=10)) 65 | add.gdsn(f, "double", val=seq(1, 1000, 0.4)) 66 | add.gdsn(f, "character", val=c("int", "double", "logical", "factor")) 67 | add.gdsn(f, "logical", val=rep(c(TRUE, FALSE, NA), 50)) 68 | add.gdsn(f, "factor", val=as.factor(c(letters, NA, "AA", "CC"))) 69 | add.gdsn(f, "NA", val=rep(NA, 10)) 70 | add.gdsn(f, "NaN", val=c(rep(NaN, 20), 1:20)) 71 | add.gdsn(f, "bit2-matrix", val=matrix(L[1:5000], nrow=50, ncol=100), 72 | storage="bit2") 73 | # list and data.frame 74 | add.gdsn(f, "list", val=list(X=1:10, Y=seq(1, 10, 0.25))) 75 | add.gdsn(f, "data.frame", val=data.frame(X=1:19, Y=seq(1, 10, 0.5))) 76 | 77 | # save a .RData object 78 | obj <- list(X=1:10, Y=seq(1, 10, 0.1)) 79 | save(obj, file="tmp.RData") 80 | addfile.gdsn(f, "tmp.RData", filename="tmp.RData") 81 | 82 | f 83 | 84 | read.gdsn(index.gdsn(f, "list")) 85 | read.gdsn(index.gdsn(f, "list/Y")) 86 | read.gdsn(index.gdsn(f, "data.frame")) 87 | read.gdsn(index.gdsn(f, "mat")) 88 | 89 | # Apply functions over columns of matrix 90 | tmp <- apply.gdsn(index.gdsn(f, "mat"), margin=2, FUN=function(x) print(x)) 91 | tmp <- apply.gdsn(index.gdsn(f, "mat"), margin=2, 92 | selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)), 93 | FUN=function(x) print(x)) 94 | 95 | # close the GDS file 96 | closefn.gds(f) 97 | 98 | 99 | # delete the temporary file 100 | unlink("test.gds", force=TRUE) 101 | } 102 | 103 | \keyword{GDS} 104 | \keyword{utilities} 105 | \keyword{IO} 106 | \keyword{interface} 107 | \keyword{file} 108 | \keyword{database} 109 | -------------------------------------------------------------------------------- /man/clusterApply.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{clusterApply.gdsn} 2 | \alias{clusterApply.gdsn} 3 | \title{Apply functions over matrix margins in parallel} 4 | \description{ 5 | Return a vector or list of values obtained by applying a function to 6 | margins of a GDS matrix in parallel. 7 | } 8 | 9 | \usage{ 10 | clusterApply.gdsn(cl, gds.fn, node.name, margin, FUN, selection=NULL, 11 | as.is=c("list", "none", "integer", "double", "character", "logical", "raw"), 12 | var.index=c("none", "relative", "absolute"), .useraw=FALSE, 13 | .value=NULL, .substitute=NULL, ...) 14 | } 15 | \arguments{ 16 | \item{cl}{a cluster object, created by this package or by the package 17 | \link{parallel}} 18 | \item{gds.fn}{the file name of a GDS file} 19 | \item{node.name}{a character vector indicating GDS node path} 20 | \item{margin}{an integer giving the subscripts which the function will be 21 | applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns} 22 | \item{FUN}{the function to be applied} 23 | \item{selection}{a list or NULL; if a list, it is a list of logical vectors 24 | according to dimensions indicating selection; if NULL, uses all data} 25 | \item{as.is}{returned value: a list, an integer vector, etc} 26 | \item{var.index}{if \code{"none"}, call \code{FUN(x, ...)} without an 27 | index; if \code{"relative"} or \code{"absolute"}, add an argument to 28 | the user-defined function \code{FUN} like \code{FUN(index, x, ...)} 29 | where \code{index} in the function is an index starting from 1: 30 | \code{"relative"} for indexing in the selection defined by 31 | \code{selection}, \code{"absolute"} for indexing with respect to 32 | all data} 33 | \item{.useraw}{use R RAW storage mode if integers can be stored in a byte, 34 | to reduce memory usage} 35 | \item{.value}{a vector of values to be replaced in the original data array, 36 | or NULL for nothing} 37 | \item{.substitute}{a vector of values after replacing, or NULL for 38 | nothing; \code{length(.substitute)} should be one or 39 | \code{length(.value)}; if \code{length(.substitute)} = 40 | \code{length(.value)}, it is a mapping from \code{.value} to 41 | \code{.substitute}} 42 | \item{...}{optional arguments to \code{FUN}} 43 | } 44 | \details{ 45 | The algorithm of applying is optimized by blocking the computations to 46 | exploit the high-speed memory instead of disk. 47 | } 48 | \value{ 49 | A vector or list of values. 50 | } 51 | 52 | \author{Xiuwen Zheng} 53 | \seealso{ 54 | \code{\link{apply.gdsn}} 55 | } 56 | 57 | \examples{ 58 | ########################################################### 59 | # prepare a GDS file 60 | 61 | # cteate a GDS file 62 | f <- createfn.gds("test1.gds") 63 | 64 | (n <- add.gdsn(f, "matrix", val=matrix(1:(10*6), nrow=10))) 65 | read.gdsn(index.gdsn(f, "matrix")) 66 | 67 | closefn.gds(f) 68 | 69 | 70 | # cteate the GDS file "test2.gds" 71 | (f <- createfn.gds("test2.gds")) 72 | 73 | X <- matrix(1:50, nrow=10) 74 | Y <- matrix((1:50)/100, nrow=10) 75 | Z1 <- factor(c(rep(c("ABC", "DEF", "ETD"), 3), "TTT")) 76 | Z2 <- c(TRUE, FALSE, TRUE, FALSE, TRUE) 77 | 78 | node.X <- add.gdsn(f, "X", X) 79 | node.Y <- add.gdsn(f, "Y", Y) 80 | node.Z1 <- add.gdsn(f, "Z1", Z1) 81 | node.Z2 <- add.gdsn(f, "Z2", Z2) 82 | f 83 | 84 | closefn.gds(f) 85 | 86 | 87 | 88 | ########################################################### 89 | # apply in parallel 90 | 91 | library(parallel) 92 | 93 | # Use option cl.core to choose an appropriate cluster size. 94 | cl <- makeCluster(getOption("cl.cores", 2L)) 95 | 96 | 97 | # Apply functions over rows or columns of matrix 98 | 99 | clusterApply.gdsn(cl, "test1.gds", "matrix", margin=1, FUN=function(x) x) 100 | 101 | clusterApply.gdsn(cl, "test1.gds", "matrix", margin=2, FUN=function(x) x) 102 | 103 | clusterApply.gdsn(cl, "test1.gds", "matrix", margin=1, 104 | selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)), 105 | FUN=function(x) x) 106 | 107 | clusterApply.gdsn(cl, "test1.gds", "matrix", margin=2, 108 | selection = list(rep(c(TRUE, FALSE), 5), rep(c(TRUE, FALSE), 3)), 109 | FUN=function(x) x) 110 | 111 | 112 | 113 | # Apply functions over rows or columns of multiple data sets 114 | 115 | clusterApply.gdsn(cl, "test2.gds", c("X", "Y", "Z1"), margin=c(1, 1, 1), 116 | FUN=function(x) x) 117 | 118 | # with variable names 119 | clusterApply.gdsn(cl, "test2.gds", c(X="X", Y="Y", Z="Z2"), margin=c(2, 2, 1), 120 | FUN=function(x) x) 121 | 122 | 123 | # stop clusters 124 | stopCluster(cl) 125 | 126 | 127 | # delete the temporary file 128 | unlink(c("test1.gds", "test2.gds"), force=TRUE) 129 | } 130 | 131 | \keyword{GDS} 132 | \keyword{utilities} 133 | -------------------------------------------------------------------------------- /src/XZ/api/lzma/check.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/check.h 3 | * \brief Integrity checks 4 | */ 5 | 6 | /* 7 | * Author: Lasse Collin 8 | * 9 | * This file has been put into the public domain. 10 | * You can do whatever you want with this file. 11 | * 12 | * See ../lzma.h for information about liblzma as a whole. 13 | */ 14 | 15 | #ifndef LZMA_H_INTERNAL 16 | # error Never include this file directly. Use instead. 17 | #endif 18 | 19 | 20 | /** 21 | * \brief Type of the integrity check (Check ID) 22 | * 23 | * The .xz format supports multiple types of checks that are calculated 24 | * from the uncompressed data. They vary in both speed and ability to 25 | * detect errors. 26 | */ 27 | typedef enum { 28 | LZMA_CHECK_NONE = 0, 29 | /**< 30 | * No Check is calculated. 31 | * 32 | * Size of the Check field: 0 bytes 33 | */ 34 | 35 | LZMA_CHECK_CRC32 = 1, 36 | /**< 37 | * CRC32 using the polynomial from the IEEE 802.3 standard 38 | * 39 | * Size of the Check field: 4 bytes 40 | */ 41 | 42 | LZMA_CHECK_CRC64 = 4, 43 | /**< 44 | * CRC64 using the polynomial from the ECMA-182 standard 45 | * 46 | * Size of the Check field: 8 bytes 47 | */ 48 | 49 | LZMA_CHECK_SHA256 = 10 50 | /**< 51 | * SHA-256 52 | * 53 | * Size of the Check field: 32 bytes 54 | */ 55 | } lzma_check; 56 | 57 | 58 | /** 59 | * \brief Maximum valid Check ID 60 | * 61 | * The .xz file format specification specifies 16 Check IDs (0-15). Some 62 | * of them are only reserved, that is, no actual Check algorithm has been 63 | * assigned. When decoding, liblzma still accepts unknown Check IDs for 64 | * future compatibility. If a valid but unsupported Check ID is detected, 65 | * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK, 66 | * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h. 67 | */ 68 | #define LZMA_CHECK_ID_MAX 15 69 | 70 | 71 | /** 72 | * \brief Test if the given Check ID is supported 73 | * 74 | * Return true if the given Check ID is supported by this liblzma build. 75 | * Otherwise false is returned. It is safe to call this with a value that 76 | * is not in the range [0, 15]; in that case the return value is always false. 77 | * 78 | * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always 79 | * supported (even if liblzma is built with limited features). 80 | */ 81 | extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) 82 | lzma_nothrow lzma_attr_const; 83 | 84 | 85 | /** 86 | * \brief Get the size of the Check field with the given Check ID 87 | * 88 | * Although not all Check IDs have a check algorithm associated, the size of 89 | * every Check is already frozen. This function returns the size (in bytes) of 90 | * the Check field with the specified Check ID. The values are: 91 | * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 } 92 | * 93 | * If the argument is not in the range [0, 15], UINT32_MAX is returned. 94 | */ 95 | extern LZMA_API(uint32_t) lzma_check_size(lzma_check check) 96 | lzma_nothrow lzma_attr_const; 97 | 98 | 99 | /** 100 | * \brief Maximum size of a Check field 101 | */ 102 | #define LZMA_CHECK_SIZE_MAX 64 103 | 104 | 105 | /** 106 | * \brief Calculate CRC32 107 | * 108 | * Calculate CRC32 using the polynomial from the IEEE 802.3 standard. 109 | * 110 | * \param buf Pointer to the input buffer 111 | * \param size Size of the input buffer 112 | * \param crc Previously returned CRC value. This is used to 113 | * calculate the CRC of a big buffer in smaller chunks. 114 | * Set to zero when starting a new calculation. 115 | * 116 | * \return Updated CRC value, which can be passed to this function 117 | * again to continue CRC calculation. 118 | */ 119 | extern LZMA_API(uint32_t) lzma_crc32( 120 | const uint8_t *buf, size_t size, uint32_t crc) 121 | lzma_nothrow lzma_attr_pure; 122 | 123 | 124 | /** 125 | * \brief Calculate CRC64 126 | * 127 | * Calculate CRC64 using the polynomial from the ECMA-182 standard. 128 | * 129 | * This function is used similarly to lzma_crc32(). See its documentation. 130 | */ 131 | extern LZMA_API(uint64_t) lzma_crc64( 132 | const uint8_t *buf, size_t size, uint64_t crc) 133 | lzma_nothrow lzma_attr_pure; 134 | 135 | 136 | /* 137 | * SHA-256 functions are currently not exported to public API. 138 | * Contact Lasse Collin if you think it should be. 139 | */ 140 | 141 | 142 | /** 143 | * \brief Get the type of the integrity check 144 | * 145 | * This function can be called only immediately after lzma_code() has 146 | * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. 147 | * Calling this function in any other situation has undefined behavior. 148 | */ 149 | extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm) 150 | lzma_nothrow; 151 | -------------------------------------------------------------------------------- /man/compression.gdsn.Rd: -------------------------------------------------------------------------------- 1 | \name{compression.gdsn} 2 | \alias{compression.gdsn} 3 | \title{Modify compression mode} 4 | \description{ 5 | Modifie the compression mode of data field in the GDS node. 6 | } 7 | 8 | \usage{ 9 | compression.gdsn(node, 10 | compress=c("", "ZIP", "ZIP_RA", "LZMA", "LZMA_RA", "LZ4", "LZ4_RA")) 11 | } 12 | \arguments{ 13 | \item{node}{an object of class \code{\link{gdsn.class}}, a GDS node} 14 | \item{compress}{the compression method can be "" (no compression), 15 | "ZIP", "ZIP.fast", "ZIP.def", "ZIP.max" or "ZIP.none" (original 16 | zlib); "ZIP_RA", "ZIP_RA.fast", "ZIP_RA.def", "ZIP_RA.max" or 17 | "ZIP_RA.none" (zlib with efficient random access); "LZ4", "LZ4.none", 18 | "LZ4.fast", "LZ4.hc" or "LZ4.max" (LZ4 compression/decompression 19 | library); "LZ4_RA", "LZ4_RA.none", "LZ4_RA.fast", "LZ4_RA.hc" or 20 | "LZ4_RA.max" (with efficient random access). "LZMA", "LZMA.fast", 21 | "LZMA.def", "LZMA.max", "LZMA_RA", "LZMA_RA.fast", "LZMA_RA.def", 22 | "LZMA_RA.max" (lzma compression/decompression algorithm). 23 | See details} 24 | } 25 | \details{ 26 | Z compression algorithm (\url{http://www.zlib.net}) can be used to 27 | deflate the data stored in the GDS file. "ZIP" option is equivalent 28 | to "ZIP.def". "ZIP.fast", "ZIP.def" and "ZIP.max" correspond to 29 | different compression levels. 30 | 31 | To support efficient random access of Z stream, "ZIP_RA", "ZIP_RA.fast", 32 | "ZIP_RA.def" or "ZIP_RA.max" should be specified. "ZIP_RA" option is 33 | equivalent to "ZIP_RA.def:256K". The block size can be specified by 34 | following colon, and "16K", "32K", "64K", "128K", "256K", "512K", "1M", 35 | "2M", "4M" and "8M" are allowed, like "ZIP_RA:64K". The compression 36 | algorithm tries to keep each independent compressed data block to be 37 | about of the specified block size, like 64K. 38 | 39 | LZ4 fast lossless compression algorithm is allowed when 40 | \code{compress="LZ4"} (\url{https://github.com/lz4/lz4}). Three 41 | compression levels can be specified, "LZ4.fast" (LZ4 fast mode), 42 | "LZ4.hc" (LZ4 high compression mode), "LZ4.max" (maximize the 43 | compression ratio). The block size can be specified by following colon, 44 | and "64K", "256K", "1M" and "4M" are allowed according to LZ4 frame 45 | format. "LZ4" is equivalent to "LZ4.hc:256K". 46 | 47 | To support efficient random access of LZ4 stream, "LZ4_RA", 48 | "LZ4_RA.fast", "LZ4_RA.hc" or "ZIP_RA.max" should be specified. 49 | "LZ4_RA" option is equivalent to "LZ4_RA.hc:256K". The block size can 50 | be specified by following colon, and "16K", "32K", "64K", "128K", 51 | "256K", "512K", "1M", "2M", "4M" and "8M" are allowed, like 52 | "LZ4_RA:64K". The compression algorithm tries to keep each independent 53 | compressed data block to be about of the specified block size, like 64K. 54 | 55 | LZMA compression algorithm (\url{https://tukaani.org/xz/}) is available 56 | since gdsfmt_v1.7.18, which has a higher compression ratio than ZIP 57 | algorithm. "LZMA", "LZMA.fast", "LZMA.def" and "LZMA.max" available. 58 | To support efficient random access of LZMA stream, "LZMA_RA", 59 | "LZMA_RA.fast", "LZMA_RA.def" and "LZMA_RA.max" can be used. The block 60 | size can be specified by following colon. "LZMA_RA" is equivalent to 61 | "LZMA_RA.def:256K". 62 | 63 | \tabular{lll}{ 64 | compression 1 \tab compression 2 \tab command line \cr 65 | ZIP \tab ZIP_RA \tab \code{gzip -6} \cr 66 | ZIP.fast \tab ZIP_RA.fast \tab \code{gzip --fast} \cr 67 | ZIP.def \tab ZIP_RA.def \tab \code{gzip -6} \cr 68 | ZIP.max \tab ZIP_RA.max \tab \code{gzip --best} \cr 69 | LZ4 \tab LZ4_RA \tab \code{LZ4 HC -6} \cr 70 | LZ4.min \tab LZ4_RA.min \tab \code{LZ4 fast 0} \cr 71 | LZ4.fast \tab LZ4_RA.fast \tab \code{LZ4 fast 2} \cr 72 | LZ4.hc \tab LZ4_RA.hc \tab \code{LZ4 HC -6} \cr 73 | LZ4.max \tab LZ4_RA.max \tab \code{LZ4 HC -9} \cr 74 | LZMA \tab LZMA_RA \tab \code{xz -6} \cr 75 | LZMA.min \tab LZMA_RA.min \tab \code{xz -0} \cr 76 | LZMA.fast \tab LZMA_RA.fast \tab \code{xz -2} \cr 77 | LZMA.def \tab LZMA_RA.def \tab \code{xz -6} \cr 78 | LZMA.max \tab LZMA_RA.max \tab \code{xz -9e} \cr 79 | LZMA.ultra \tab LZMA_RA.ultra \tab \code{xz --lzma2=dict=512Mi} \cr 80 | LZMA.ultra_max \tab LZMA_RA.ultra_max \tab \code{xz --lzma2=dict=1536Mi} \cr 81 | } 82 | } 83 | \value{ 84 | Return \code{node}. 85 | } 86 | 87 | \references{ 88 | \url{http://zlib.net}, 89 | \url{https://github.com/lz4/lz4}, 90 | \url{https://tukaani.org/xz/} 91 | } 92 | \author{Xiuwen Zheng} 93 | \seealso{ 94 | \code{\link{readmode.gdsn}}, \code{\link{add.gdsn}} 95 | } 96 | 97 | \examples{ 98 | # cteate a GDS file 99 | f <- createfn.gds("test.gds") 100 | 101 | n <- add.gdsn(f, "int.matrix", matrix(1:50*100, nrow=100, ncol=50)) 102 | n 103 | 104 | compression.gdsn(n, "ZIP") 105 | 106 | # close the GDS file 107 | closefn.gds(f) 108 | 109 | # delete the temporary file 110 | unlink("test.gds", force=TRUE) 111 | } 112 | 113 | \keyword{GDS} 114 | \keyword{utilities} 115 | -------------------------------------------------------------------------------- /inst/include/R_GDS_CPP.h: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // R_GDS_CPP.h: C interface to gdsfmt dynamic library + CPP classes 10 | // 11 | // Copyright (C) 2014-2024 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | /** 29 | * \file R_GDS_CPP.h 30 | * \author Xiuwen Zheng [zhengxwen@gmail.com] 31 | * \version 1.0 32 | * \date 2014 - 2024 33 | * \brief C interface to gdsfmt dynamic library + CPP classes 34 | * \details 35 | **/ 36 | 37 | #ifndef _HEADER_R_GDS_CPP_ 38 | #define _HEADER_R_GDS_CPP_ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | 47 | namespace CoreArray 48 | { 49 | // ================================================================== 50 | // ================================================================== 51 | 52 | /// try block for CoreArray library 53 | #define CORE_TRY \ 54 | try { 55 | 56 | /// try block for CoreArray library 57 | #define COREARRAY_TRY \ 58 | bool has_error = false; \ 59 | SEXP rv_ans = R_NilValue; \ 60 | CORE_TRY 61 | 62 | 63 | /// catch block for CoreArray library 64 | #define CORE_CATCH(cmd) \ 65 | } \ 66 | catch (std::exception &E) { \ 67 | GDS_SetError(E.what()); cmd; \ 68 | } \ 69 | catch (const char *E) { \ 70 | GDS_SetError(E); cmd; \ 71 | } \ 72 | catch (...) { \ 73 | GDS_SetError("unknown error!"); cmd; \ 74 | } \ 75 | 76 | /// catch block for CoreArray library 77 | #define COREARRAY_CATCH \ 78 | CORE_CATCH(has_error = true); \ 79 | if (has_error) Rf_error("%s", GDS_GetError()); \ 80 | return rv_ans; 81 | 82 | 83 | 84 | // ================================================================== 85 | // ================================================================== 86 | 87 | // [[ ******** 88 | #ifndef COREARRAY_GDSFMT_PACKAGE 89 | 90 | /// Error Macro 91 | #define _COREARRAY_ERRMACRO_(x) { \ 92 | va_list args; va_start(args, x); \ 93 | Init(x, args); \ 94 | va_end(args); \ 95 | } 96 | 97 | /// The root class of exception for CoreArray library 98 | class ErrCoreArray: public std::exception 99 | { 100 | public: 101 | ErrCoreArray() {} 102 | ErrCoreArray(const char *fmt, ...) { _COREARRAY_ERRMACRO_(fmt); } 103 | ErrCoreArray(const std::string &msg) { fMessage = msg; } 104 | 105 | virtual const char *what() const throw() 106 | { return fMessage.c_str(); } 107 | virtual ~ErrCoreArray() throw() {}; 108 | 109 | protected: 110 | std::string fMessage; 111 | 112 | void Init(const char *fmt, va_list arglist) 113 | { 114 | char buf[1024]; 115 | vsnprintf(buf, sizeof(buf), fmt, arglist); 116 | fMessage = buf; 117 | } 118 | }; 119 | 120 | 121 | /// automatic mutex object 122 | struct TdAutoMutex 123 | { 124 | PdThreadMutex mutex; 125 | 126 | TdAutoMutex(PdThreadMutex m) 127 | { mutex = m; if (m) GDS_Parallel_LockMutex(m); } 128 | ~TdAutoMutex() 129 | { if (mutex) GDS_Parallel_UnlockMutex(mutex); } 130 | 131 | COREARRAY_INLINE void Reset(PdThreadMutex m) 132 | { 133 | if (m != mutex) 134 | { 135 | if (mutex) GDS_Parallel_UnlockMutex(mutex); 136 | mutex = m; 137 | if (m) GDS_Parallel_LockMutex(m); 138 | } 139 | } 140 | }; 141 | 142 | 143 | /// the class of read array 144 | class CArrayRead 145 | { 146 | public: 147 | CArrayRead(PdAbstractArray Obj, int Margin, C_SVType SVType, 148 | const C_BOOL *const Selection[], bool buf_if_need=true) 149 | { 150 | _Obj = GDS_ArrayRead_Init(Obj, Margin, SVType, Selection, 151 | buf_if_need); 152 | if (!_Obj) 153 | throw ErrCoreArray("Error 'initialize CArrayRead'."); 154 | } 155 | ~CArrayRead() 156 | { 157 | GDS_ArrayRead_Free(_Obj); 158 | } 159 | 160 | /// read data 161 | void Read(void *Buffer) 162 | { 163 | GDS_ArrayRead_Read(_Obj, Buffer); 164 | } 165 | 166 | /// return true, if it is of the end 167 | bool Eof() 168 | { 169 | return GDS_ArrayRead_Eof(_Obj); 170 | } 171 | 172 | protected: 173 | PdArrayRead _Obj; 174 | }; 175 | 176 | #else // COREARRAY_GDSFMT_PACKAGE 177 | 178 | /// error exception for the gdsfmt package 179 | class COREARRAY_DLL_EXPORT ErrGDSFmt: public ErrCoreArray 180 | { 181 | public: 182 | ErrGDSFmt() {} 183 | ErrGDSFmt(const char *fmt, ...) { _COREARRAY_ERRMACRO_(fmt); } 184 | ErrGDSFmt(const std::string &msg) { fMessage = msg; } 185 | }; 186 | 187 | #endif // COREARRAY_GDSFMT_PACKAGE 188 | // ]] ******** 189 | 190 | } 191 | 192 | #endif /* _HEADER_R_GDS_CPP_ */ 193 | -------------------------------------------------------------------------------- /src/ZLIB/LICENSE: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.12 is a general purpose data compression library. All the code is 4 | thread safe. The data format used by the zlib library is described by RFCs 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and 7 | rfc1952 (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 11 | of the library is given in the file test/example.c which also tests that 12 | the library is working correctly. Another example is given in the file 13 | test/minigzip.c. The compression library itself is composed of all source 14 | files in the root directory. 15 | 16 | To compile all files and run the test program, follow the instructions given at 17 | the top of Makefile.in. In short "./configure; make test", and if that goes 18 | well, "make install" should work for most flavors of Unix. For Windows, use 19 | one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 20 | make_vms.com. 21 | 22 | Questions about zlib should be sent to , or to Gilles Vollant 23 | for the Windows DLL version. The zlib home page is 24 | http://zlib.net/ . Before reporting a problem, please check this site to 25 | verify that you have the latest version of zlib; otherwise get the latest 26 | version and check whether the problem still exists or not. 27 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. 29 | 30 | Mark Nelson wrote an article about zlib for the Jan. 1997 31 | issue of Dr. Dobb's Journal; a copy of the article is available at 32 | http://marknelson.us/1997/01/01/zlib-engine/ . 33 | 34 | The changes made in version 1.2.12 are documented in the file ChangeLog. 35 | 36 | Unsupported third party contributions are provided in directory contrib/ . 37 | 38 | zlib is available in Java using the java.util.zip package, documented at 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . 40 | 41 | A Perl interface to zlib written by Paul Marquess is available 42 | at CPAN (Comprehensive Perl Archive Network) sites, including 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . 44 | 45 | A Python interface to zlib written by A.M. Kuchling is 46 | available in Python 1.5 and later versions, see 47 | http://docs.python.org/library/zlib.html . 48 | 49 | zlib is built into tcl: http://wiki.tcl.tk/4610 . 50 | 51 | An experimental package to read and write files in .zip format, written on top 52 | of zlib by Gilles Vollant , is available in the 53 | contrib/minizip directory of zlib. 54 | 55 | 56 | Notes for some targets: 57 | 58 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 59 | 60 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 61 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 62 | compiler flag). The compiler bug has been reported to SGI. 63 | 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 65 | when compiled with cc. 66 | 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 68 | necessary to get gzprintf working correctly. This is done by configure. 69 | 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 71 | other compilers. Use "make test" to check your compiler. 72 | 73 | - gzdopen is not supported on RISCOS or BEOS. 74 | 75 | - For PalmOs, see http://palmzlib.sourceforge.net/ 76 | 77 | 78 | Acknowledgments: 79 | 80 | The deflate format used by zlib was defined by Phil Katz. The deflate and 81 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 82 | people who reported problems and suggested various improvements in zlib; they 83 | are too numerous to cite here. 84 | 85 | Copyright notice: 86 | 87 | (C) 1995-2022 Jean-loup Gailly and Mark Adler 88 | 89 | This software is provided 'as-is', without any express or implied 90 | warranty. In no event will the authors be held liable for any damages 91 | arising from the use of this software. 92 | 93 | Permission is granted to anyone to use this software for any purpose, 94 | including commercial applications, and to alter it and redistribute it 95 | freely, subject to the following restrictions: 96 | 97 | 1. The origin of this software must not be misrepresented; you must not 98 | claim that you wrote the original software. If you use this software 99 | in a product, an acknowledgment in the product documentation would be 100 | appreciated but is not required. 101 | 2. Altered source versions must be plainly marked as such, and must not be 102 | misrepresented as being the original software. 103 | 3. This notice may not be removed or altered from any source distribution. 104 | 105 | Jean-loup Gailly Mark Adler 106 | jloup@gzip.org madler@alumni.caltech.edu 107 | 108 | If you use the zlib library in a product, we would appreciate *not* receiving 109 | lengthy legal documents to sign. The sources are provided for free but without 110 | warranty of any kind. The library has been entirely written by Jean-loup 111 | Gailly and Mark Adler; it does not include third-party code. We make all 112 | contributions to and distributions of this project solely in our personal 113 | capacity, and are not conveying any rights to any intellectual property of 114 | any third parties. 115 | 116 | If you redistribute modified sources, we would appreciate that you include in 117 | the file ChangeLog history information documenting your changes. Please read 118 | the FAQ for more information on the distribution of modified source versions. 119 | -------------------------------------------------------------------------------- /src/ZLIB/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2011, 2016 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 11 | 12 | #define BASE 65521U /* largest prime smaller than 65536 */ 13 | #define NMAX 5552 14 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 15 | 16 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 17 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 18 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 19 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 20 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 21 | 22 | /* use NO_DIVIDE if your processor does not do division in hardware -- 23 | try it both ways to see which is faster */ 24 | #ifdef NO_DIVIDE 25 | /* note that this assumes BASE is 65521, where 65536 % 65521 == 15 26 | (thank you to John Reiser for pointing this out) */ 27 | # define CHOP(a) \ 28 | do { \ 29 | unsigned long tmp = a >> 16; \ 30 | a &= 0xffffUL; \ 31 | a += (tmp << 4) - tmp; \ 32 | } while (0) 33 | # define MOD28(a) \ 34 | do { \ 35 | CHOP(a); \ 36 | if (a >= BASE) a -= BASE; \ 37 | } while (0) 38 | # define MOD(a) \ 39 | do { \ 40 | CHOP(a); \ 41 | MOD28(a); \ 42 | } while (0) 43 | # define MOD63(a) \ 44 | do { /* this assumes a is not negative */ \ 45 | z_off64_t tmp = a >> 32; \ 46 | a &= 0xffffffffL; \ 47 | a += (tmp << 8) - (tmp << 5) + tmp; \ 48 | tmp = a >> 16; \ 49 | a &= 0xffffL; \ 50 | a += (tmp << 4) - tmp; \ 51 | tmp = a >> 16; \ 52 | a &= 0xffffL; \ 53 | a += (tmp << 4) - tmp; \ 54 | if (a >= BASE) a -= BASE; \ 55 | } while (0) 56 | #else 57 | # define MOD(a) a %= BASE 58 | # define MOD28(a) a %= BASE 59 | # define MOD63(a) a %= BASE 60 | #endif 61 | 62 | /* ========================================================================= */ 63 | uLong ZEXPORT adler32_z( 64 | uLong adler, 65 | const Bytef *buf, 66 | z_size_t len) 67 | { 68 | unsigned long sum2; 69 | unsigned n; 70 | 71 | /* split Adler-32 into component sums */ 72 | sum2 = (adler >> 16) & 0xffff; 73 | adler &= 0xffff; 74 | 75 | /* in case user likes doing a byte at a time, keep it fast */ 76 | if (len == 1) { 77 | adler += buf[0]; 78 | if (adler >= BASE) 79 | adler -= BASE; 80 | sum2 += adler; 81 | if (sum2 >= BASE) 82 | sum2 -= BASE; 83 | return adler | (sum2 << 16); 84 | } 85 | 86 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 87 | if (buf == Z_NULL) 88 | return 1L; 89 | 90 | /* in case short lengths are provided, keep it somewhat fast */ 91 | if (len < 16) { 92 | while (len--) { 93 | adler += *buf++; 94 | sum2 += adler; 95 | } 96 | if (adler >= BASE) 97 | adler -= BASE; 98 | MOD28(sum2); /* only added so many BASE's */ 99 | return adler | (sum2 << 16); 100 | } 101 | 102 | /* do length NMAX blocks -- requires just one modulo operation */ 103 | while (len >= NMAX) { 104 | len -= NMAX; 105 | n = NMAX / 16; /* NMAX is divisible by 16 */ 106 | do { 107 | DO16(buf); /* 16 sums unrolled */ 108 | buf += 16; 109 | } while (--n); 110 | MOD(adler); 111 | MOD(sum2); 112 | } 113 | 114 | /* do remaining bytes (less than NMAX, still just one modulo) */ 115 | if (len) { /* avoid modulos if none remaining */ 116 | while (len >= 16) { 117 | len -= 16; 118 | DO16(buf); 119 | buf += 16; 120 | } 121 | while (len--) { 122 | adler += *buf++; 123 | sum2 += adler; 124 | } 125 | MOD(adler); 126 | MOD(sum2); 127 | } 128 | 129 | /* return recombined sums */ 130 | return adler | (sum2 << 16); 131 | } 132 | 133 | /* ========================================================================= */ 134 | uLong ZEXPORT adler32( 135 | uLong adler, 136 | const Bytef *buf, 137 | uInt len) 138 | { 139 | return adler32_z(adler, buf, len); 140 | } 141 | 142 | /* ========================================================================= */ 143 | local uLong adler32_combine_( 144 | uLong adler1, 145 | uLong adler2, 146 | z_off64_t len2) 147 | { 148 | unsigned long sum1; 149 | unsigned long sum2; 150 | unsigned rem; 151 | 152 | /* for negative len, return invalid adler32 as a clue for debugging */ 153 | if (len2 < 0) 154 | return 0xffffffffUL; 155 | 156 | /* the derivation of this formula is left as an exercise for the reader */ 157 | MOD63(len2); /* assumes len2 >= 0 */ 158 | rem = (unsigned)len2; 159 | sum1 = adler1 & 0xffff; 160 | sum2 = rem * sum1; 161 | MOD(sum2); 162 | sum1 += (adler2 & 0xffff) + BASE - 1; 163 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 164 | if (sum1 >= BASE) sum1 -= BASE; 165 | if (sum1 >= BASE) sum1 -= BASE; 166 | if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); 167 | if (sum2 >= BASE) sum2 -= BASE; 168 | return sum1 | (sum2 << 16); 169 | } 170 | 171 | /* ========================================================================= */ 172 | uLong ZEXPORT adler32_combine( 173 | uLong adler1, 174 | uLong adler2, 175 | z_off_t len2) 176 | { 177 | return adler32_combine_(adler1, adler2, len2); 178 | } 179 | 180 | uLong ZEXPORT adler32_combine64( 181 | uLong adler1, 182 | uLong adler2, 183 | z_off64_t len2) 184 | { 185 | return adler32_combine_(adler1, adler2, len2); 186 | } 187 | -------------------------------------------------------------------------------- /R/methods.r: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # 3 | # methods.r: generic methods for GDS objects 4 | # 5 | # Copyright (C) 2015-2023 Xiuwen Zheng 6 | # 7 | # This is free software: you can redistribute it and/or modify it 8 | # under the terms of the GNU Lesser General Public License Version 3 as 9 | # published by the Free Software Foundation. 10 | # 11 | # gdsfmt is distributed in the hope that it will be useful, but 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with gdsfmt. 18 | # If not, see . 19 | 20 | 21 | 22 | ############################################################################## 23 | # Class Register 24 | ############################################################################## 25 | 26 | # register old-style (S3) classes and inheritance 27 | setOldClass("gds.class") 28 | setOldClass("gdsn.class") 29 | 30 | 31 | 32 | ############################################################# 33 | # show methods 34 | # 35 | 36 | # read and drop upper dimensions 37 | .get <- function(node, start, count) 38 | { 39 | v <- read.gdsn(node, start=start, count=count, simplify="none", 40 | .sparse=FALSE) 41 | if (!is.null(dm <- dim(v))) 42 | { 43 | if (length(dm) > 2L) 44 | dim(v) <- dm[c(1L,2L)] 45 | } 46 | if (is.factor(v)) v <- as.character(v) 47 | v 48 | } 49 | 50 | # view 2-dim array 51 | .view_dim2 <- function(dm, node, st, nprev, BLURRED) 52 | { 53 | if (any(dm[1L] <= 0L, dm[2L] <= 0L)) 54 | { 55 | cat("\n") 56 | return(invisible()) 57 | } 58 | 59 | cn <- rep(1L, length(st)) 60 | if (dm[1L] <= nprev*2L) 61 | { 62 | if (dm[2L] <= nprev*2L) 63 | { 64 | v <- .get(node, c(1L,1L,st), c(-1L,-1L,cn)) 65 | } else { 66 | v <- cbind( 67 | .get(node, c(1L,1L,st), c(-1L,nprev,cn)), 68 | .get(node, c(1L,dm[2L]-nprev+1L,st), c(-1L,nprev,cn)) 69 | ) 70 | } 71 | } else { 72 | if (dm[2L] <= nprev*2L) 73 | { 74 | v <- rbind( 75 | .get(node, c(1L,1L,st), c(nprev,-1L,cn)), 76 | .get(node, c(dm[1L]-nprev+1L,1L,st), c(nprev,-1L,cn)) 77 | ) 78 | } else { 79 | v1 <- cbind( 80 | .get(node, c(1L,1L,st), c(nprev,nprev,cn)), 81 | .get(node, c(1L,dm[2L]-nprev+1L,st), c(nprev,nprev,cn)) 82 | ) 83 | v2 <- cbind( 84 | .get(node, c(dm[1L]-nprev+1L,1L,st), c(nprev,nprev,cn)), 85 | .get(node, c(dm[1L]-nprev+1L,dm[2L]-nprev+1L,st), c(nprev,nprev,cn)) 86 | ) 87 | v <- rbind(v1, v2) 88 | } 89 | } 90 | 91 | s <- format(v) 92 | if (dm[2L] > nprev*2L) 93 | { 94 | s <- s[, c(1L:nprev, NA, seq(nprev+1L,ncol(s))), drop=FALSE] 95 | s[, nprev+1L] <- BLURRED("..") 96 | } 97 | if (dm[1L] > nprev*2L) 98 | { 99 | s <- s[c(1L:nprev, NA, seq(nprev+1L,nrow(s))), , drop=FALSE] 100 | s[nprev+1L, ] <- "" 101 | s[nprev+1L, 1L] <- BLURRED("......") 102 | } 103 | 104 | write.table(s, col.names=FALSE, row.names=FALSE, quote=FALSE) 105 | invisible() 106 | } 107 | 108 | # view >2-dim array 109 | .view_dim <- function(i, st, dm, node, nprev, BLURRED, UNDERLINE) 110 | { 111 | if (i > length(dm)) 112 | { 113 | cat(UNDERLINE(sprintf("[,,%s]:\n", paste(st, collapse=",")))) 114 | .view_dim2(dm, node, st, nprev, BLURRED) 115 | } else { 116 | if (dm[i] > (nprev-2L)*2L) 117 | { 118 | for (j in seq_len(nprev-2L)) 119 | { 120 | st2 <- c(st, j) 121 | .view_dim(i + 1L, st2, dm, node, nprev, BLURRED, UNDERLINE) 122 | } 123 | cat(BLURRED("......"), "\n", sep="") 124 | for (j in seq.int(dm[i]-nprev+3L, dm[i])) 125 | { 126 | st2 <- c(st, j) 127 | .view_dim(i + 1L, st2, dm, node, nprev, BLURRED, UNDERLINE) 128 | } 129 | } else { 130 | for (j in seq_len(dm[i])) 131 | { 132 | st2 <- c(st, j) 133 | .view_dim(i + 1L, st2, dm, node, nprev, BLURRED, UNDERLINE) 134 | } 135 | } 136 | } 137 | invisible() 138 | } 139 | 140 | 141 | setMethod("show", signature(object="gdsn.class"), 142 | function(object) 143 | { 144 | print(object) 145 | 146 | n <- getOption("gds.preview.num", 6L) 147 | if (.crayon()) 148 | { 149 | INVERSE <- crayon::inverse 150 | UNDERLINE <- crayon::silver 151 | BLURRED <- crayon::silver 152 | } else { 153 | INVERSE <- UNDERLINE <- BLURRED <- identity 154 | } 155 | 156 | dp <- objdesp.gdsn(object) 157 | dm <- dp$dim 158 | if (dp$is.array && !is.null(dm)) 159 | { 160 | cat(INVERSE("Preview:\n")) 161 | if (length(dm) == 1L) 162 | { 163 | if (dm <= 0L) 164 | { 165 | s <- "" 166 | } else if (dm <= n*2L) 167 | { 168 | s <- format(read.gdsn(object)) 169 | } else { 170 | s <- format(c(.get(object,1L,n), .get(object, dm-n+1L, n))) 171 | s <- s[c(1L:n, NA, seq(n+1L, length(s)))] 172 | s[n+1L] <- BLURRED("...") 173 | } 174 | cat(s, sep="\n") 175 | } else if (length(dp$dim) == 2L) 176 | { 177 | .view_dim2(dm, object, NULL, n, BLURRED) 178 | } else { 179 | .view_dim(3L, NULL, dm, object, n, BLURRED, UNDERLINE) 180 | } 181 | } 182 | invisible() 183 | } 184 | ) 185 | -------------------------------------------------------------------------------- /src/CoreArray/dEndian.cpp: -------------------------------------------------------------------------------- 1 | // =========================================================== 2 | // _/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ 3 | // _/ _/ _/ _/ _/ _/ _/ _/ 4 | // _/ _/ _/_/_/_/ _/ _/ _/ _/_/_/ 5 | // _/ _/ _/ _/ _/ _/ _/ 6 | // _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/_/_/ _/_/ 7 | // =========================================================== 8 | // 9 | // dEndian.cpp: Cross-platform functions with independent endianness 10 | // 11 | // Copyright (C) 2007-2017 Xiuwen Zheng 12 | // 13 | // This file is part of CoreArray. 14 | // 15 | // CoreArray is free software: you can redistribute it and/or modify it 16 | // under the terms of the GNU Lesser General Public License Version 3 as 17 | // published by the Free Software Foundation. 18 | // 19 | // CoreArray is distributed in the hope that it will be useful, but 20 | // WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU Lesser General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public 25 | // License along with CoreArray. 26 | // If not, see . 27 | 28 | #include "dEndian.h" 29 | 30 | 31 | namespace CoreArray 32 | { 33 | // ===================================================================== 34 | // Endian Macro and Function 35 | // ===================================================================== 36 | 37 | #ifndef COREARRAY_ENDIAN_LITTLE 38 | 39 | // native format to little endian, array 40 | 41 | void NT_TO_LE_ARRAY(C_Int16 *p, size_t n) 42 | { 43 | for (; n > 0; n--, p++) *p = NT_TO_LE(*p); 44 | } 45 | 46 | void NT_TO_LE_ARRAY(C_UInt16 *p, size_t n) 47 | { 48 | for (; n > 0; n--, p++) *p = NT_TO_LE(*p); 49 | } 50 | 51 | void NT_TO_LE_ARRAY(C_Int32 *p, size_t n) 52 | { 53 | for (; n > 0; n--, p++) *p = NT_TO_LE(*p); 54 | } 55 | 56 | void NT_TO_LE_ARRAY(C_UInt32 *p, size_t n) 57 | { 58 | for (; n > 0; n--, p++) *p = NT_TO_LE(*p); 59 | } 60 | 61 | void NT_TO_LE_ARRAY(C_Int64 *p, size_t n) 62 | { 63 | for (; n > 0; n--, p++) *p = NT_TO_LE(*p); 64 | } 65 | 66 | void NT_TO_LE_ARRAY(C_UInt64 *p, size_t n) 67 | { 68 | for (; n > 0; n--, p++) *p = NT_TO_LE(*p); 69 | } 70 | 71 | void NT_TO_LE_ARRAY(C_Float32 *p, size_t n) 72 | { 73 | C_UInt32 *pp = (C_UInt32*)p; 74 | for (; n > 0; n--, pp++) *pp = NT_TO_LE(*pp); 75 | } 76 | 77 | void NT_TO_LE_ARRAY(C_Float64 *p, size_t n) 78 | { 79 | C_UInt64 *pp = (C_UInt64*)p; 80 | for (; n > 0; n--, pp++) *pp = NT_TO_LE(*pp); 81 | } 82 | 83 | void NT_TO_LE_ARRAY2(C_Int16 *d, const C_Int16 *s, size_t n) 84 | { 85 | for (; n > 0; n--) *d++ = NT_TO_LE(*s++); 86 | } 87 | 88 | void NT_TO_LE_ARRAY2(C_UInt16 *d, const C_UInt16 *s, size_t n) 89 | { 90 | for (; n > 0; n--) *d++ = NT_TO_LE(*s++); 91 | } 92 | 93 | void NT_TO_LE_ARRAY2(C_Int32 *d, const C_Int32 *s, size_t n) 94 | { 95 | for (; n > 0; n--) *d++ = NT_TO_LE(*s++); 96 | } 97 | 98 | void NT_TO_LE_ARRAY2(C_UInt32 *d, const C_UInt32 *s, size_t n) 99 | { 100 | for (; n > 0; n--) *d++ = NT_TO_LE(*s++); 101 | } 102 | 103 | void NT_TO_LE_ARRAY2(C_Int64 *d, const C_Int64 *s, size_t n) 104 | { 105 | for (; n > 0; n--) *d++ = NT_TO_LE(*s++); 106 | } 107 | 108 | void NT_TO_LE_ARRAY2(C_UInt64 *d, const C_UInt64 *s, size_t n) 109 | { 110 | for (; n > 0; n--) *d++ = NT_TO_LE(*s++); 111 | } 112 | 113 | void NT_TO_LE_ARRAY2(C_Float32 *d, const C_Float32 *s, size_t n) 114 | { 115 | C_UInt32 *dd = (C_UInt32*)d; 116 | C_UInt32 *ss = (C_UInt32*)s; 117 | for (; n > 0; n--) *dd++ = NT_TO_LE(*ss++); 118 | } 119 | 120 | void NT_TO_LE_ARRAY2(C_Float64 *d, const C_Float64 *s, size_t n) 121 | { 122 | C_UInt64 *dd = (C_UInt64*)d; 123 | C_UInt64 *ss = (C_UInt64*)s; 124 | for (; n > 0; n--) *dd++ = NT_TO_LE(*ss++); 125 | } 126 | 127 | 128 | // native format to little endian, array 129 | 130 | void LE_TO_NT_ARRAY(C_Int16 *p, size_t n) 131 | { 132 | for (; n > 0; n--, p++) *p = LE_TO_NT(*p); 133 | } 134 | 135 | void LE_TO_NT_ARRAY(C_UInt16 *p, size_t n) 136 | { 137 | for (; n > 0; n--, p++) *p = LE_TO_NT(*p); 138 | } 139 | 140 | void LE_TO_NT_ARRAY(C_Int32 *p, size_t n) 141 | { 142 | for (; n > 0; n--, p++) *p = LE_TO_NT(*p); 143 | } 144 | 145 | void LE_TO_NT_ARRAY(C_UInt32 *p, size_t n) 146 | { 147 | for (; n > 0; n--, p++) *p = LE_TO_NT(*p); 148 | } 149 | 150 | void LE_TO_NT_ARRAY(C_Int64 *p, size_t n) 151 | { 152 | for (; n > 0; n--, p++) *p = LE_TO_NT(*p); 153 | } 154 | 155 | void LE_TO_NT_ARRAY(C_UInt64 *p, size_t n) 156 | { 157 | for (; n > 0; n--, p++) *p = LE_TO_NT(*p); 158 | } 159 | 160 | void LE_TO_NT_ARRAY(C_Float32 *p, size_t n) 161 | { 162 | C_UInt32 *pp = (C_UInt32*)p; 163 | for (; n > 0; n--, pp++) *pp = LE_TO_NT(*pp); 164 | } 165 | 166 | void LE_TO_NT_ARRAY(C_Float64 *p, size_t n) 167 | { 168 | C_UInt64 *pp = (C_UInt64*)p; 169 | for (; n > 0; n--, pp++) *pp = LE_TO_NT(*pp); 170 | } 171 | 172 | void LE_TO_NT_ARRAY2(C_Int16 *d, const C_Int16 *s, size_t n) 173 | { 174 | for (; n > 0; n--) *d++ = LE_TO_NT(*s++); 175 | } 176 | 177 | void LE_TO_NT_ARRAY2(C_UInt16 *d, const C_UInt16 *s, size_t n) 178 | { 179 | for (; n > 0; n--) *d++ = LE_TO_NT(*s++); 180 | } 181 | 182 | void LE_TO_NT_ARRAY2(C_Int32 *d, const C_Int32 *s, size_t n) 183 | { 184 | for (; n > 0; n--) *d++ = LE_TO_NT(*s++); 185 | } 186 | 187 | void LE_TO_NT_ARRAY2(C_UInt32 *d, const C_UInt32 *s, size_t n) 188 | { 189 | for (; n > 0; n--) *d++ = LE_TO_NT(*s++); 190 | } 191 | 192 | void LE_TO_NT_ARRAY2(C_Int64 *d, const C_Int64 *s, size_t n) 193 | { 194 | for (; n > 0; n--) *d++ = LE_TO_NT(*s++); 195 | } 196 | 197 | void LE_TO_NT_ARRAY2(C_UInt64 *d, const C_UInt64 *s, size_t n) 198 | { 199 | for (; n > 0; n--) *d++ = LE_TO_NT(*s++); 200 | } 201 | 202 | void LE_TO_NT_ARRAY2(C_Float32 *d, const C_Float32 *s, size_t n) 203 | { 204 | C_UInt32 *dd = (C_UInt32*)d; 205 | C_UInt32 *ss = (C_UInt32*)s; 206 | for (; n > 0; n--) *dd++ = LE_TO_NT(*ss++); 207 | } 208 | 209 | void LE_TO_NT_ARRAY2(C_Float64 *d, const C_Float64 *s, size_t n) 210 | { 211 | C_UInt64 *dd = (C_UInt64*)d; 212 | C_UInt64 *ss = (C_UInt64*)s; 213 | for (; n > 0; n--) *dd++ = LE_TO_NT(*ss++); 214 | } 215 | 216 | 217 | #endif 218 | } 219 | -------------------------------------------------------------------------------- /src/ZLIB/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. 6 | It is part of the implementation of this library and is 7 | subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /inst/unitTests/test_04_datareadwrite.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: test data dimension 4 | # 5 | 6 | source(system.file("unitTests", "include.r", package="gdsfmt")) 7 | 8 | 9 | 10 | ############################################################# 11 | # 12 | # test functions 13 | # 14 | 15 | test.data.read_write <- function() 16 | { 17 | on.exit({ 18 | showfile.gds(closeall=TRUE, verbose=FALSE) 19 | unlink("tmp.gds", force=TRUE) 20 | }) 21 | 22 | verbose <- options("test.verbose")$test.verbose 23 | if (verbose) cat("\n\n>>>> test.data.read_write <<<<\n") 24 | 25 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 26 | 27 | for (n in type.list) 28 | { 29 | if (verbose) cat(n, "\t", sep="") 30 | if (n %in% c("vl_uint", "vl_int")) next 31 | 32 | dta <- matrix(valid.dta[[sprintf("valid1.%s", n)]], nrow=50, ncol=40) 33 | 34 | set.seed(1000) 35 | rows <- as.integer(runif(500) * 50) + 1 36 | cols <- as.integer(runif(500) * 40) + 1 37 | 38 | r.dta <- matrix(0, nrow=nrow(dta), ncol=ncol(dta)) 39 | w.dta <- dta 40 | for (i in 1:200) 41 | { 42 | i.row <- rows[i]; i.col <- cols[i] 43 | r.dta[i.row, i.col] <- dta[i.row, i.col] 44 | w.dta[i.row, i.col] <- 0 45 | } 46 | 47 | # create a new gds file 48 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 49 | 50 | # append data 51 | node <- add.gdsn(gfile, "data", val=dta, storage=n) 52 | 53 | r2.dta <- matrix(0, nrow=nrow(dta), ncol=ncol(dta)) 54 | for (i in 1:200) 55 | { 56 | i.row <- rows[i]; i.col <- cols[i] 57 | r2.dta[i.row, i.col] <- read.gdsn(node, start=c(i.row, i.col), 58 | count=c(1, 1)) 59 | } 60 | for (i in 1:200) 61 | { 62 | i.row <- rows[i]; i.col <- cols[i] 63 | write.gdsn(node, 0, start=c(i.row, i.col), count=c(1, 1)) 64 | } 65 | 66 | closefn.gds(gfile) 67 | 68 | gfile <- openfn.gds("tmp.gds", allow.duplicate=TRUE) 69 | node <- index.gdsn(gfile, "data") 70 | 71 | checkEquals(r2.dta, r.dta, sprintf("data random read: %s", n)) 72 | checkEquals(read.gdsn(node), w.dta, sprintf("data random write: %s", n)) 73 | 74 | # close the gds file 75 | closefn.gds(gfile) 76 | } 77 | } 78 | 79 | 80 | test.data.read_write.compress.zip <- function() 81 | { 82 | on.exit({ 83 | showfile.gds(closeall=TRUE, verbose=FALSE) 84 | unlink("tmp.gds", force=TRUE) 85 | }) 86 | 87 | verbose <- options("test.verbose")$test.verbose 88 | if (verbose) cat("\n\n>>>> test.data.read_write.compress.zip <<<<\n") 89 | 90 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 91 | set.seed(1000) 92 | 93 | for (cp in compress.list) 94 | { 95 | if (verbose) 96 | cat("Compression:", cp, "\n", sep="") 97 | 98 | for (n in type.list) 99 | { 100 | if (verbose) cat(n, "\t", sep="") 101 | if (n %in% c("vl_uint", "vl_int")) next 102 | 103 | dta <- matrix(valid.dta[[sprintf("valid1.%s", n)]], nrow=50, ncol=40) 104 | 105 | rows <- as.integer(runif(500) * 50) + 1 106 | cols <- as.integer(runif(500) * 40) + 1 107 | 108 | r.dta <- matrix(0, nrow=nrow(dta), ncol=ncol(dta)) 109 | w.dta <- dta 110 | for (i in 1:200) 111 | { 112 | i.row <- rows[i]; i.col <- cols[i] 113 | r.dta[i.row, i.col] <- dta[i.row, i.col] 114 | w.dta[i.row, i.col] <- 0 115 | } 116 | 117 | # create a new gds file 118 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 119 | 120 | # append data 121 | node <- add.gdsn(gfile, "data", val=dta, storage=n, 122 | compress=cp, closezip=TRUE) 123 | 124 | closefn.gds(gfile) 125 | 126 | gfile <- openfn.gds("tmp.gds", allow.duplicate=TRUE) 127 | node <- index.gdsn(gfile, "data") 128 | 129 | r2.dta <- matrix(0, nrow=nrow(dta), ncol=ncol(dta)) 130 | for (i in 1:200) 131 | { 132 | i.row <- rows[i]; i.col <- cols[i] 133 | r2.dta[i.row, i.col] <- read.gdsn(node, 134 | start=c(i.row, i.col), count=c(1, 1)) 135 | } 136 | 137 | checkEquals(r2.dta, r.dta, 138 | sprintf("data random read (%s): %s", cp, n)) 139 | 140 | # close the gds file 141 | closefn.gds(gfile) 142 | } 143 | 144 | if (verbose) cat("\n") 145 | } 146 | } 147 | 148 | 149 | test.data.read_write.file <- function() 150 | { 151 | on.exit({ 152 | showfile.gds(closeall=TRUE, verbose=FALSE) 153 | unlink(c("tmp.gds", "tmp.RData"), force=TRUE) 154 | }) 155 | 156 | verbose <- options("test.verbose")$test.verbose 157 | if (verbose) cat("\n\n>>>> test.data.read_write.file <<<<\n") 158 | 159 | # the name of file 160 | fn <- sprintf("%s/valid/standard.RData", base.path) 161 | 162 | for (cp in compress.list) 163 | { 164 | if (verbose) cat(cp, "\t", sep="") 165 | 166 | # create a new gds file 167 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 168 | 169 | node <- addfile.gdsn(gfile, "tmp.RData", filename=fn, compress=cp) 170 | getfile.gdsn(node, "tmp.RData") 171 | 172 | checkEquals(get(load("tmp.RData")), get(load(fn)), 173 | sprintf("data stream (%s)", cp)) 174 | 175 | # close the gds file 176 | closefn.gds(gfile) 177 | } 178 | } 179 | 180 | 181 | test.data.read_selection <- function() 182 | { 183 | on.exit({ 184 | showfile.gds(closeall=TRUE, verbose=FALSE) 185 | unlink("tmp.gds", force=TRUE) 186 | }) 187 | 188 | verbose <- options("test.verbose")$test.verbose 189 | if (verbose) cat("\n\n>>>> test.data.read_selection <<<<\n") 190 | 191 | valid.dta <- get(load(sprintf("%s/valid/standard.RData", base.path))) 192 | set.seed(1000) 193 | 194 | for (n in type.list) 195 | { 196 | if (verbose) cat(n, "\t", sep="") 197 | 198 | dta <- matrix(valid.dta[[sprintf("valid1.%s", n)]], nrow=50, ncol=40) 199 | 200 | # create a new gds file 201 | gfile <- createfn.gds("tmp.gds", allow.duplicate=TRUE) 202 | 203 | # append data 204 | node <- add.gdsn(gfile, "data", val=dta, storage=n) 205 | 206 | # for-loop 207 | for (i in 1:25) 208 | { 209 | rsel <- rep(FALSE, nrow(dta)) 210 | rsel[sample.int(length(rsel), 25)] <- TRUE 211 | csel <- rep(FALSE, ncol(dta)) 212 | csel[sample.int(length(csel), 15)] <- TRUE 213 | 214 | r1.dat <- dta[rsel, csel] 215 | r2.dat <- readex.gdsn(node, sel=list(rsel, csel)) 216 | checkEquals(r1.dat, r2.dat, 217 | sprintf("data read with random selection: %s", n)) 218 | 219 | # scan by row 220 | for (j in which(rsel)) 221 | { 222 | rrsel <- rep(FALSE, length(rsel)) 223 | rrsel[j] <- TRUE 224 | r1.dat <- dta[rrsel, csel] 225 | r2.dat <- readex.gdsn(node, sel=list(rrsel, csel)) 226 | checkEquals(r1.dat, r2.dat, 227 | sprintf("data read with random selection: %s", n)) 228 | } 229 | 230 | # scan by column 231 | for (j in which(csel)) 232 | { 233 | ccsel <- rep(FALSE, length(csel)) 234 | ccsel[j] <- TRUE 235 | r1.dat <- dta[rsel, ccsel] 236 | r2.dat <- readex.gdsn(node, sel=list(rsel, ccsel)) 237 | checkEquals(r1.dat, r2.dat, 238 | sprintf("data read with random selection: %s", n)) 239 | } 240 | } 241 | 242 | # close the gds file 243 | closefn.gds(gfile) 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /inst/unitTests/test_08_miscellaneous.R: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # 3 | # DESCRIPTION: miscellaneous 4 | # 5 | 6 | library(RUnit) 7 | library(digest) 8 | library(tools) 9 | library(gdsfmt) 10 | 11 | 12 | ############################################################# 13 | # 14 | # test functions 15 | # 16 | 17 | test.digest <- function() 18 | { 19 | verbose <- options("test.verbose")$test.verbose 20 | if (verbose) cat("\n>>>> test.digest <<<<\n") 21 | 22 | set.seed(1000) 23 | 24 | for (i in 1:10) 25 | { 26 | len <- sample.int(100000, 1) 27 | val <- as.raw(sample.int(256, len, replace=TRUE) - 1L) 28 | writeBin(val, con="test.bin") 29 | 30 | # cteate a GDS file 31 | f <- createfn.gds("test.gds") 32 | add.gdsn(f, "raw", val) 33 | closefn.gds(f) 34 | 35 | f <- openfn.gds("test.gds") 36 | hash1 <- unname(digest.gdsn(index.gdsn(f, "raw"))) 37 | closefn.gds(f) 38 | 39 | # check with other program 40 | hash2 <- unname(md5sum("test.bin")) 41 | 42 | checkEquals(hash1, hash2, paste("md5 digest", i)) 43 | } 44 | 45 | # delete the temporary files 46 | unlink(c("test.gds", "test.bin"), force=TRUE) 47 | } 48 | 49 | 50 | test.digest.factor <- function() 51 | { 52 | verbose <- options("test.verbose")$test.verbose 53 | if (verbose) cat("\n>>>> test.digest.factor <<<<\n") 54 | 55 | set.seed(1000) 56 | 57 | for (i in 1:10) 58 | { 59 | f <- createfn.gds("test.gds") 60 | 61 | v <- sample.int(26, 10000, TRUE) 62 | v[sample.int(length(v), 10)] <- NA 63 | vv <- factor(v, labels=letters) 64 | 65 | n1 <- add.gdsn(f, "i1", vv) 66 | n2 <- add.gdsn(f, "i2", as.character(vv), check=FALSE) 67 | 68 | checkEquals(digest.gdsn(n1, action="Robject"), 69 | digest.gdsn(n2, action="Robject"), "md5 R object digest") 70 | 71 | closefn.gds(f) 72 | } 73 | 74 | # delete the temporary file 75 | unlink("test.gds", force=TRUE) 76 | } 77 | 78 | 79 | test.zip_block.concatenate <- function() 80 | { 81 | verbose <- options("test.verbose")$test.verbose 82 | if (verbose) cat("\n>>>> test.zip_block.concatenate <<<<\n") 83 | 84 | set.seed(1000) 85 | 86 | for (i in 1:10) 87 | { 88 | val <- sample.int(2^28, 500000, replace=TRUE) 89 | val2 <- sample.int(2^28, sample.int(256, 1), replace=TRUE) 90 | 91 | # cteate a GDS file 92 | f <- createfn.gds("test.gds") 93 | 94 | n1 <- add.gdsn(f, "int", val, compress="ZIP_RA:16K", closezip=TRUE) 95 | 96 | n2 <- add.gdsn(f, "int2", storage="int", compress="ZIP_RA:16K") 97 | append.gdsn(n2, n1) 98 | readmode.gdsn(n2) 99 | checkEquals(val, read.gdsn(n2), "concatenating compressed block (1)") 100 | 101 | n3 <- add.gdsn(f, "int3", storage="int", compress="ZIP_RA:16K") 102 | append.gdsn(n3, val2) 103 | append.gdsn(n3, n1) 104 | readmode.gdsn(n3) 105 | checkEquals(c(val2, val), read.gdsn(n3), "concatenating compressed block (2)") 106 | 107 | n4 <- add.gdsn(f, "int4", storage="int", compress="ZIP_RA:16K") 108 | append.gdsn(n4, n1) 109 | append.gdsn(n4, val2) 110 | append.gdsn(n4, n1) 111 | readmode.gdsn(n4) 112 | checkEquals(c(val, val2, val), read.gdsn(n4), "concatenating compressed block (3)") 113 | 114 | closefn.gds(f) 115 | } 116 | } 117 | 118 | 119 | test.zip_block_real16.concatenate <- function() 120 | { 121 | verbose <- options("test.verbose")$test.verbose 122 | if (verbose) cat("\n>>>> test.zip_block_real16.concatenate <<<<\n") 123 | 124 | set.seed(1000) 125 | 126 | for (i in 1:10) 127 | { 128 | val <- round(runif(500000), 4) 129 | val2 <- round(runif(sample.int(256, 1)), 4) 130 | 131 | # cteate a GDS file 132 | f <- createfn.gds("test.gds") 133 | 134 | n1 <- add.gdsn(f, "float", val, storage="packedreal16", 135 | compress="ZIP_RA:16K", closezip=TRUE) 136 | 137 | n2 <- add.gdsn(f, "float2", storage="packedreal16", compress="ZIP_RA:16K") 138 | append.gdsn(n2, n1) 139 | readmode.gdsn(n2) 140 | checkEquals(val, read.gdsn(n2), "concatenating compressed block (1)") 141 | 142 | n3 <- add.gdsn(f, "float3", storage="packedreal16", compress="ZIP_RA:16K") 143 | append.gdsn(n3, val2) 144 | append.gdsn(n3, n1) 145 | readmode.gdsn(n3) 146 | checkEquals(c(val2, val), read.gdsn(n3), "concatenating compressed block (2)") 147 | 148 | n4 <- add.gdsn(f, "float4", storage="packedreal16", compress="ZIP_RA:16K") 149 | append.gdsn(n4, n1) 150 | append.gdsn(n4, val2) 151 | append.gdsn(n4, n1) 152 | readmode.gdsn(n4) 153 | checkEquals(c(val, val2, val), read.gdsn(n4), "concatenating compressed block (3)") 154 | 155 | closefn.gds(f) 156 | } 157 | } 158 | 159 | 160 | test.lz4_block.concatenate <- function() 161 | { 162 | verbose <- options("test.verbose")$test.verbose 163 | if (verbose) cat("\n>>>> test.lz4_block.concatenate <<<<\n") 164 | 165 | set.seed(100) 166 | 167 | for (i in 1:10) 168 | { 169 | val <- sample.int(2^28, 500000, replace=TRUE) 170 | val2 <- sample.int(2^28, sample.int(256, 1), replace=TRUE) 171 | 172 | # cteate a GDS file 173 | f <- createfn.gds("test.gds") 174 | 175 | n1 <- add.gdsn(f, "int", val, compress="LZ4_RA:16K", closezip=TRUE) 176 | 177 | n2 <- add.gdsn(f, "int2", storage="int", compress="LZ4_RA:16K") 178 | append.gdsn(n2, n1) 179 | readmode.gdsn(n2) 180 | checkEquals(val, read.gdsn(n2), "concatenating compressed block (1)") 181 | 182 | n3 <- add.gdsn(f, "int3", storage="int", compress="LZ4_RA:16K") 183 | append.gdsn(n3, val2) 184 | append.gdsn(n3, n1) 185 | readmode.gdsn(n3) 186 | checkEquals(c(val2, val), read.gdsn(n3), "concatenating compressed block (2)") 187 | 188 | n4 <- add.gdsn(f, "int4", storage="int", compress="LZ4_RA:16K") 189 | append.gdsn(n4, n1) 190 | append.gdsn(n4, val2) 191 | append.gdsn(n4, n1) 192 | readmode.gdsn(n4) 193 | checkEquals(c(val, val2, val), read.gdsn(n4), "concatenating compressed block (3)") 194 | 195 | closefn.gds(f) 196 | } 197 | } 198 | 199 | 200 | test.lzma_block.concatenate <- function() 201 | { 202 | verbose <- options("test.verbose")$test.verbose 203 | if (verbose) cat("\n>>>> test.lzma_block.concatenate <<<<\n") 204 | 205 | set.seed(100) 206 | 207 | for (i in 1:10) 208 | { 209 | val <- sample.int(2^28, 500000, replace=TRUE) 210 | val2 <- sample.int(2^28, sample.int(256, 1), replace=TRUE) 211 | 212 | # cteate a GDS file 213 | f <- createfn.gds("test.gds") 214 | 215 | n1 <- add.gdsn(f, "int", val, compress="LZMA_RA:32K", closezip=TRUE) 216 | 217 | n2 <- add.gdsn(f, "int2", storage="int", compress="LZMA_RA:32K") 218 | append.gdsn(n2, n1) 219 | readmode.gdsn(n2) 220 | checkEquals(val, read.gdsn(n2), "concatenating compressed block (1)") 221 | 222 | n3 <- add.gdsn(f, "int3", storage="int", compress="LZMA_RA:32K") 223 | append.gdsn(n3, val2) 224 | append.gdsn(n3, n1) 225 | readmode.gdsn(n3) 226 | checkEquals(c(val2, val), read.gdsn(n3), "concatenating compressed block (2)") 227 | 228 | n4 <- add.gdsn(f, "int4", storage="int", compress="LZMA_RA:32K") 229 | append.gdsn(n4, n1) 230 | append.gdsn(n4, val2) 231 | append.gdsn(n4, n1) 232 | readmode.gdsn(n4) 233 | checkEquals(c(val, val2, val), read.gdsn(n4), "concatenating compressed block (3)") 234 | 235 | closefn.gds(f) 236 | } 237 | } 238 | --------------------------------------------------------------------------------