summaryrefslogtreecommitdiffstats
path: root/hl/c++
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-09-26 18:25:03 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-09-26 18:25:03 (GMT)
commit6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62 (patch)
tree2a600b3c00b8f554d0a09f4e29e5e0f831a8b356 /hl/c++
parentfdbdaf656bc91c4802dd4c58ceb622bb51f390a9 (diff)
downloadhdf5-6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62.zip
hdf5-6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62.tar.gz
hdf5-6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62.tar.bz2
[svn-r12686] Added compression to Packet Tables. Now both C and C++ packet tables
have an extra parameter that sets the deflate filter. Added tests, made examples use the new APIs. Cleaned up include files a little and removed some casts that I hope are superfluous. If anybody encounters strange errors in the packet table tests where the chunk size is set to some extremely large value, please let me know, but I was unable to reproduce this error on any system. Tested on mir, heping, sol, juniper, VS 6.0. Looked for the chunk size error on several other systems a month or two ago.
Diffstat (limited to 'hl/c++')
-rw-r--r--hl/c++/examples/ptExampleFL.cpp4
-rw-r--r--hl/c++/src/H5PacketTable.cpp6
-rw-r--r--hl/c++/src/H5PacketTable.h9
-rw-r--r--hl/c++/test/Makefile.am6
-rw-r--r--hl/c++/test/Makefile.in11
-rw-r--r--hl/c++/test/ptableTest.cpp60
-rw-r--r--hl/c++/test/ptableTest.h6
7 files changed, 72 insertions, 30 deletions
diff --git a/hl/c++/examples/ptExampleFL.cpp b/hl/c++/examples/ptExampleFL.cpp
index 4f9c167..93fc58e 100644
--- a/hl/c++/examples/ptExampleFL.cpp
+++ b/hl/c++/examples/ptExampleFL.cpp
@@ -46,8 +46,8 @@ int main(void)
if(fileID <0)
fprintf(stderr, "Couldn't create file.\n");
- /* Create a fixed-length packet table. */
- FL_PacketTable ptable(fileID, "/examplePacketTable", H5T_NATIVE_INT, 1);
+ /* Create a fixed-length packet table with compression level 5. */
+ FL_PacketTable ptable(fileID, "/examplePacketTable", H5T_NATIVE_INT, 100, 5);
if(! ptable.IsValid())
fprintf(stderr, "Unable to create packet table.");
diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp
index 6a16807..dc34995 100644
--- a/hl/c++/src/H5PacketTable.cpp
+++ b/hl/c++/src/H5PacketTable.cpp
@@ -124,9 +124,9 @@
* the packet table, the ID of the datatype of the set, and the size
* of a memory chunk used in chunking.
*/
- FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, int chunkSize)
+ FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression)
{
- table_id = H5PTcreate_fl ( fileID, name, dtypeID, chunkSize);
+ table_id = H5PTcreate_fl ( fileID, name, dtypeID, chunkSize, compression);
}
/* "Open" Constructor
@@ -220,7 +220,7 @@
* Takes the ID of the file the packet table will be created in, the name of
* the packet table, and the size of a memory chunk used in chunking.
*/
- VL_PacketTable::VL_PacketTable(hid_t fileID, char* name, int chunkSize)
+ VL_PacketTable::VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize)
{
table_id = H5PTcreate_vl ( fileID, name, chunkSize);
}
diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h
index 3ba4e5e..cdfb3ee 100644
--- a/hl/c++/src/H5PacketTable.h
+++ b/hl/c++/src/H5PacketTable.h
@@ -103,10 +103,11 @@ public:
/* Constructor
* Creates a packet table in which to store fixed length packets.
* Takes the ID of the file the packet table will be created in, the name of
- * the packet table, the ID of the datatype of the set, and the size
- * of a memory chunk used in chunking.
+ * the packet table, the ID of the datatype of the set, the size
+ * of a memory chunk used in chunking, and the desired compression level
+ * (0-9, or -1 for no compression).
*/
- FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, int chunkSize);
+ FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = -1);
/* "Open" Constructor
* Opens an existing fixed-length packet table.
@@ -169,7 +170,7 @@ public:
* Takes the ID of the file the packet table will be created in, the name of
* the packet table, and the size of a memory chunk used in chunking.
*/
- VL_PacketTable(hid_t fileID, char* name, int chunkSize);
+ VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize);
/* "Open" Constructor
* Opens an existing variable-length packet table.
diff --git a/hl/c++/test/Makefile.am b/hl/c++/test/Makefile.am
index 95917f0..dc543f6 100644
--- a/hl/c++/test/Makefile.am
+++ b/hl/c++/test/Makefile.am
@@ -20,7 +20,7 @@
include $(top_srcdir)/config/commence.am
# Include directories
-INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_srcdir)/hl/c++/src -I$(top_srcdir)/test
+INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/c++/src -I$(top_srcdir)/hl/src -I$(top_srcdir)/hl/c++/src -I$(top_srcdir)/test -I$(top_builddir)/hl/test -I$(top_srcdir)/hl/test
# Shared C++ libraries aren't universally supported.
if CXX_SHARED_CONDITIONAL
@@ -33,8 +33,8 @@ endif
TEST_PROG=ptableTest
check_PROGRAMS=$(TEST_PROG)
-# The tests depend on the hdf5 library and the hdf5_hl library
-LDADD=$(LIBH5CPP_HL) $(LIBH5_HL) $(LIBHDF5)
+# The tests depend on the hdf5, hdf5 C++, and hdf5_hl libraries
+LDADD=$(LIBH5CPP_HL) $(LIBH5_HL) $(LIBH5CPP) $(LIBHDF5)
ptableTest_SOURCES=ptableTest.cpp
include $(top_srcdir)/config/conclude.am
diff --git a/hl/c++/test/Makefile.in b/hl/c++/test/Makefile.in
index d8b2de2..b99ca34 100644
--- a/hl/c++/test/Makefile.in
+++ b/hl/c++/test/Makefile.in
@@ -71,9 +71,10 @@ ptableTest_OBJECTS = $(am_ptableTest_OBJECTS)
ptableTest_LDADD = $(LDADD)
am__DEPENDENCIES_1 = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la
am__DEPENDENCIES_2 = $(top_builddir)/hl/src/libhdf5_hl.la
-am__DEPENDENCIES_3 = $(top_builddir)/src/libhdf5.la
+am__DEPENDENCIES_3 = $(top_builddir)/c++/src/libhdf5_cpp.la
+am__DEPENDENCIES_4 = $(top_builddir)/src/libhdf5.la
ptableTest_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_3)
+ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
@@ -322,7 +323,7 @@ TRACE = perl $(top_srcdir)/bin/trace
CHECK_CLEANFILES = *.chkexe *.chklog *.clog
# Include directories
-INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_srcdir)/hl/c++/src -I$(top_srcdir)/test
+INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/c++/src -I$(top_srcdir)/hl/src -I$(top_srcdir)/hl/c++/src -I$(top_srcdir)/test -I$(top_builddir)/hl/test -I$(top_srcdir)/hl/test
# Shared C++ libraries aren't universally supported.
@CXX_SHARED_CONDITIONAL_FALSE@AM_LDFLAGS = -static
@@ -331,8 +332,8 @@ INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_srcdir)/hl/c++/src
# executed, generally most specific tests to least specific tests.
TEST_PROG = ptableTest
-# The tests depend on the hdf5 library and the hdf5_hl library
-LDADD = $(LIBH5CPP_HL) $(LIBH5_HL) $(LIBHDF5)
+# The tests depend on the hdf5, hdf5 C++, and hdf5_hl libraries
+LDADD = $(LIBH5CPP_HL) $(LIBH5_HL) $(LIBH5CPP) $(LIBHDF5)
ptableTest_SOURCES = ptableTest.cpp
# Automake needs to be taught how to build lib, progs, and tests targets.
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp
index 3b97d3e..d25c2ba 100644
--- a/hl/c++/test/ptableTest.cpp
+++ b/hl/c++/test/ptableTest.cpp
@@ -16,6 +16,8 @@
#include "ptableTest.h"
+using namespace H5;
+
#define TEST_FILE "packettest.h5"
/* Main test function */
@@ -41,6 +43,8 @@ int main(void)
num_errors += TestGetNext();
+ num_errors += TestCompress();
+
num_errors += TestErrors();
num_errors += SystemTest();
@@ -146,8 +150,8 @@ int TestCompoundDatatype()
H5Tinsert(dtypeID, "charlie", HOFFSET( compoundType, c ), H5T_NATIVE_SHORT);
H5Tinsert(dtypeID, "ebert", HOFFSET( compoundType, e ), H5T_NATIVE_INT);
- /* Create packet table */
- FL_PacketTable wrapper(fileID, "/compoundTest", dtypeID, 1);
+ /* Create packet table. Explicitly specify no compression */
+ FL_PacketTable wrapper(fileID, "/compoundTest", dtypeID, 1, -1);
if(! wrapper.IsValid())
goto out;
@@ -193,7 +197,7 @@ int TestGetNext()
TESTING("GetNextPacket")
/* Create a dataset */
- FL_PacketTable wrapper(fileID, "/TestGetNext", H5T_NATIVE_INT, 1);
+ FL_PacketTable wrapper(fileID, "/TestGetNext", H5T_NATIVE_INT, 500);
if(! wrapper.IsValid())
goto out;
@@ -245,6 +249,38 @@ out:
return 1;
}
+int TestCompress()
+{
+ unsigned int flags = 0;
+ unsigned int config = 0;
+ size_t cd_nelemts = 0;
+
+ TESTING("compression")
+
+ try {
+ /* Create packet table with compression. */
+ FL_PacketTable wrapper(fileID, "/compressTest", H5T_NATIVE_CHAR, 100, 8);
+
+ /* Create an HDF5 C++ file object */
+ H5File file;
+ file.setId(fileID);
+
+ /* Make sure that the deflate filter is set by opening the packet table
+ * as a dataset and getting its creation property list */
+ DataSet dsetID = file.openDataSet("/compressTest");
+
+ DSetCreatPropList dcplID = dsetID.getCreatePlist();
+
+ dcplID.getFilterById(H5Z_FILTER_DEFLATE, flags, cd_nelemts, NULL, 0, NULL, config);
+ } catch (Exception e) {
+ H5_FAILED();
+ return 1;
+ }
+
+ PASSED();
+ return 0;
+}
+
int TestGetPacket()
{
int record;
@@ -252,8 +288,8 @@ int TestGetPacket()
int i;
TESTING("GetPacket")
- /* Create a dataset */
- FL_PacketTable wrapper(fileID, "/TestGetPacket", H5T_NATIVE_INT, 1);
+ /* Create a dataset. Explicitly specify no compression */
+ FL_PacketTable wrapper(fileID, "/TestGetPacket", H5T_NATIVE_INT, 1, -1);
if(! wrapper.IsValid())
goto out;
@@ -302,13 +338,13 @@ int TestErrors()
wrapper.AppendPacket(&record);
/* Try to confuse functions with bad indexes */
- error = wrapper.GetPacket(-1, &record);
+ error = wrapper.GetPacket( (unsigned) -1, &record);
if(error >= 0)
goto out;
error = wrapper.GetPacket(4, &record);
if(error >= 0)
goto out;
- error = wrapper.GetPacket(-250, &record);
+ error = wrapper.GetPacket((unsigned) -250, &record);
if(error >= 0)
goto out;
error = wrapper.GetPacket(3000, &record);
@@ -318,13 +354,13 @@ int TestErrors()
if(error < 0)
goto out;
- error = wrapper.GetPackets(-1, 1, records);
+ error = wrapper.GetPackets((unsigned) -1, 1, records);
if(error >= 0)
goto out;
error = wrapper.GetPackets(2, 4, records);
if(error >= 0)
goto out;
- error = wrapper.GetPackets(-60, -62, records);
+ error = wrapper.GetPackets((unsigned) -60, (unsigned) -62, records);
if(error >= 0)
goto out;
error = wrapper.GetPackets(10, 12, records);
@@ -344,7 +380,7 @@ int TestErrors()
goto out;
wrapper.ResetIndex();
- error = wrapper.SetIndex(-1);
+ error = wrapper.SetIndex((unsigned) -1);
if(error >= 0)
goto out;
if(wrapper.GetIndex(error) != 0) goto out;
@@ -433,9 +469,9 @@ int SystemTest()
ct2[0].g.c = 0;
ct2[0].g.e = 3000;
- /* Create the packet table datasets */
+ /* Create the packet table datasets. Make one of them compressed. */
FL_PacketTable wrapper1(fileID, "/SystemTest1", dtypeID1, 1);
- FL_PacketTable wrapper2(fileID, "/SystemTest2", dtypeID2, 1);
+ FL_PacketTable wrapper2(fileID, "/SystemTest2", dtypeID2, 1, 5);
if(! wrapper1.IsValid())
goto out;
diff --git a/hl/c++/test/ptableTest.h b/hl/c++/test/ptableTest.h
index 119b1e4..d51f39e 100644
--- a/hl/c++/test/ptableTest.h
+++ b/hl/c++/test/ptableTest.h
@@ -23,7 +23,8 @@
#define PTABLETEST
#include "H5PacketTable.h"
-#include "h5test.h"
+#include "H5Cpp.h"
+#include "h5hltest.h"
static hid_t fileID;
@@ -36,6 +37,9 @@ int TestCompoundDatatype(void);
/* Test the GetNext functions and their indexes */
int TestGetNext(void);
+/* Make sure that setting compression through the C++ API works. */
+int TestCompress(void);
+
/* Ensure that the functions return the correct errors in
* response to invalid indexes */
int TestErrors(void);