[H5r-commits] r37 - R src tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 24 00:10:25 CEST 2010
Author: extemporaneousb
Date: 2010-08-24 00:10:25 +0200 (Tue, 24 Aug 2010)
New Revision: 37
Modified:
R/h5R.R
src/h5_wrap.c
tests/crash.R
tests/testall.R
Log:
Added some code for faster determination of dataset and attribute existence.
Modified: R/h5R.R
===================================================================
--- R/h5R.R 2010-08-23 19:34:34 UTC (rev 36)
+++ R/h5R.R 2010-08-23 22:10:25 UTC (rev 37)
@@ -475,31 +475,14 @@
}
h5DatasetExists <- function(h5Obj, name) {
- .Call("h5R_attribute_exists", .ePtr(h5Obj), name) == 1
+ .Call("h5R_dataset_exists", .ePtr(h5Obj), name) == 1
}
h5AttributeExists <- function(h5Obj, name) {
-
+ .Call("h5R_attribute_exists", .ePtr(h5Obj), name) == 1
}
-##
-## Does the name exist directly below the h5Obj.
-##
-## XXX: This function might be implemented in C more
-## efficiently, i.e., short-circuiting when the
-## object is found, but I have avoided using the
-## Lightweight interface.
-h5Exists <- function(h5Obj, name) {
- a <- .listH5Contents(h5Obj)
- n <- sapply(a, "[[", 1)
- any(n == name)
- ## This call determines if an object exists anywhere in
- ## the file with 'name'
- ##
- ## return(.Call("h5R_name_exists", .ePtr(h5Obj), name))
-}
-
Modified: src/h5_wrap.c
===================================================================
--- src/h5_wrap.c 2010-08-23 19:34:34 UTC (rev 36)
+++ src/h5_wrap.c 2010-08-23 22:10:25 UTC (rev 37)
@@ -372,10 +372,13 @@
*/
/** Inspection **/
-SEXP h5R_attribute_exists(SEXP h5_obj, const char* name) {
- return ScalarInteger(H5Aexists(HID(h5_obj), name));
+SEXP h5R_attribute_exists(SEXP h5_obj, SEXP name) {
+ return(ScalarInteger(H5Aexists(HID(h5_obj), NM(name))));
}
+SEXP h5R_dataset_exists(SEXP h5_obj, SEXP name) {
+ return(ScalarInteger(H5Lexists(HID(h5_obj), NM(name), H5P_DEFAULT)));
+}
/** Iteration **/
typedef struct __index_and_SEXP__ {
Modified: tests/crash.R
===================================================================
--- tests/crash.R 2010-08-23 19:34:34 UTC (rev 36)
+++ tests/crash.R 2010-08-23 22:10:25 UTC (rev 37)
@@ -1,7 +1,6 @@
##
## These are tests which error in hdf5 libraries and should give an R error.
##
-
require(h5r)
source("tinyTestHarness.R")
Modified: tests/testall.R
===================================================================
--- tests/testall.R 2010-08-23 19:34:34 UTC (rev 36)
+++ tests/testall.R 2010-08-23 22:10:25 UTC (rev 37)
@@ -28,8 +28,8 @@
TH("ds_1 dim, 5", assertError(ds1[,1:12]))
## test existence.
-TH("existence, 1", h5Exists(g, "ds_1"))
-TH("existence, 2", h5Exists(g, "ds_232") == FALSE)
+TH("existence, 1", h5DatasetExists(g, "ds_1"))
+TH("existence, 2", h5DatasetExists(g, "ds_232") == FALSE)
## string dataset
ds2M <- getH5Dataset(g, "ds_2", inMemory = T)
More information about the H5r-commits
mailing list