LightVoting
 All Classes Namespaces Files Functions Variables Pages
org.lightvoting.CDataWriter Class Reference

Created by sophie on 15.05.17. More...

+ Collaboration diagram for org.lightvoting.CDataWriter:

Static Public Member Functions

static void createHDF5 (final String p_filename)
 create HDF5 file More...
 
static void test (final String p_name)
 test for h5 file More...
 

Private Member Functions

 CDataWriter ()
 

Detailed Description

Definition at line 32 of file CDataWriter.java.

Constructor & Destructor Documentation

org.lightvoting.CDataWriter.CDataWriter ( )
private

Definition at line 36 of file CDataWriter.java.

37  {
38 
39  }

Member Function Documentation

static void org.lightvoting.CDataWriter.createHDF5 ( final String  p_filename)
static

Definition at line 44 of file CDataWriter.java.

45  {
46 
47  // Create a new file.
48  try
49  {
50  final hdf5.H5File l_h5file = new hdf5.H5File( p_filename, org.bytedeco.javacpp.hdf5.H5F_ACC_TRUNC );
51  l_h5file.close();
52  }
53  catch ( final Exception l_ex )
54  {
55  l_ex.printStackTrace();
56  }
57  }
static void org.lightvoting.CDataWriter.test ( final String  p_name)
static
Parameters
p_namename of h5 file

Definition at line 64 of file CDataWriter.java.

65  {
66  final hdf5.H5File l_file = new hdf5.H5File();
67  l_file.openFile( p_name, hdf5.H5F_ACC_RDWR );
68 
69  final String l_DATASETNAME = "Results";
70  final int l_DIM0 = 100;
71  final int l_DIM1 = 20;
72 
73  // dataset dimensions
74  final long[] l_dims = {l_DIM0, l_DIM1};
75  // chunk dimensions
76  final long[] l_chunkDims = {20, 20};
77  final int[] l_buf = new int[l_DIM0 * l_DIM1];
78 
79 
80 
81  // Create the data space for the dataset.
82  final hdf5.DataSpace l_dataSpace = new hdf5.DataSpace( 2, l_dims );
83 
84  // Modify dataset creation property to enable chunking
85  final hdf5.DSetCreatPropList l_plist = new hdf5.DSetCreatPropList();
86  l_plist.setChunk( 2, l_chunkDims );
87 
88  final hdf5.DataSet l_dataset = new hdf5.DataSet( l_file.asCommonFG().createDataSet( l_DATASETNAME,
89  new hdf5.DataType( hdf5.PredType.STD_I32BE() ), l_dataSpace, l_plist ) );
90 
91  for ( int i = 0; i < l_DIM0; i++ )
92  for ( int j = 0; j < l_DIM1; j++ )
93  l_buf[i * l_DIM1 + j] = i + j;
94 
95  // Write data to dataset.
96  l_dataset.write( new IntPointer( l_buf ), new hdf5.DataType( hdf5.PredType.NATIVE_INT() ) );
97 
98  l_dataSpace.close();
99  l_dataset.close();
100  l_plist.close();
101  l_file._close();
102  }