简体   繁体   English

我们如何使用RHDF5软件包为HDF5文件中的数据集提供无限尺寸?

[英]How can we have unlimited dimensions for a dataset in HDF5 File using RHDF5 package?

Though it might seem similar to an already question: is-it-possible-to-update-dataset-dimensions-in-hdf5-file-using-rhdf5-in-r but they are not exactly same. 尽管它似乎与已经存在的问题相似: 是否可以使用rhdf5-in-r在hdf5-文件中更新数据集维度,但它们并不完全相同。

In RHDF5 documentation, it is written that we can define the maximum dimensions that a dataset can have at the time dataset is created using h5createDataset() (using maxdims parameter). 在RHDF5文档中,我们定义了使用h5createDataset()(使用maxdims参数)创建数据集时,可以定义数据集可以具有的最大尺寸。 But what if we don't know the dimensions of the dataset beforehand eg we might have a situation that the size of the dataset is continuously increasing and so, we have no idea about the maximum dimensions that a dataset can attain. 但是,如果我们事先不知道数据集的尺寸怎么办,例如,我们可能会遇到这样的情况:数据集的大小在不断增加,因此,我们不知道数据集可以达到的最大尺寸。

In the answer to the question mentioned above, it was mentioned that it can be done with the help of dataspace and HDF5 constants. 在上述问题的答案中,提到可以借助数据空间和HDF5常量完成此操作。

Can anyone please give some idea regarding how HDF5 constants and dataspace can be used to do so? 任何人都可以对如何使用HDF5常数和数据空间给出一些想法吗?

While doing some experimentation with the function h5createDataset() , I have found a way of doing this: 在对功能h5createDataset()进行一些试验时,我发现了一种方法:

> library(rhdf5)

> fid <- H5Fcreate('test.h5')

> h5createGroup(fid,'1')
[1] TRUE

> h5createDataset(fid,'1/1',dims = c(2,2,2),maxdims = c(Inf,Inf,Inf))
[1] TRUE
Warning message:
  In H5Screate_simple(dims, maxdims) :
  NAs introduced by coercion to integer range

> arr <- array(c(1:8),c(2,2,2))

> h5write(arr,fid,'1/1')

> h5read(fid,'1/1')
, , 1

     [,1] [,2]
[1,]    1    3
[2,]    2    4

, , 2

     [,1] [,2]
[1,]    5    7
[2,]    6    8

Please correct me if I am wrong somewhere or if there is a better method to do so. 如果我在某个地方错了或者有更好的方法可以纠正我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM