Page tree

The license could not be verified: License Certificate has expired!

 

JAVA

FORTRAN

C++

C

 

Link

H5TB_WRITE_RECORDS

Overwrites records

Procedure:

H5TB_WRITE_RECORDS (loc_id, table_name, start, nrecords, type_size, field_offset, field_Sizes, data )

Signature:

herr_t H5TBwrite_records ( 
            hid_t loc_id, 
            const char *table_name, 
            hsize_t start, 
            hsize_t nrecords, 
            size_t type_size,
            const size_t *field_offset, 
            const size_t *field_sizes, 
            const void *data )

Parameters:
hid_t loc_idIN: Identifier of the file or group where the table is located
const char *table_nameIN: The name of the dataset to overwrite
hsize_t startIN: The zero index record to start writing
hsize_t nrecordsIN: The number of records to write
size_t type_sizeIN: The size of the structure type, as calculated by sizeof()
const size_t *field_offset

IN: An array containing the offsets of the fields

These offsets can be calculated with the HOFFSET macro.

const size_t *field_sizesIN: An array containing the sizes of the fields
const void *dataIN: Buffer with data

Description:

H5TB_WRITE_RECORDS overwrites records starting at the zero index position start of the table named table_name attached to the object specified by the identifier loc_id.

Returns:

Returns a non-negative value if successful; otherwise returns a negative value.

Example:

hl / examples / ex_table_03.c [34:111]  1.10/master  HDFFV/hdf5
 typedef struct Particle
 {
  char   name[16];
  int    lati;
  int    longi;
  float  pressure;
  double temperature;
 } Particle;

 Particle  dst_buf[NRECORDS];

 /* Calculate the size and the offsets of our struct members in memory */
 size_t dst_size =  sizeof( Particle );
 size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
                                HOFFSET( Particle, lati ),
                                HOFFSET( Particle, longi ),
                                HOFFSET( Particle, pressure ),
                                HOFFSET( Particle, temperature )};

 Particle  p = {"zero",0,0, 0.0f, 0.0};
 size_t dst_sizes[NFIELDS] = { sizeof( p.name),
                               sizeof( p.lati),
                               sizeof( p.longi),
                               sizeof( p.pressure),
                               sizeof( p.temperature)};

 /* Define field information */
 const char *field_names[NFIELDS]  =
 { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
 /* Fill value particle */
 Particle   fill_data[1] =
	{ {"no data",-1,-1, -99.0f, -99.0} };
 hid_t      field_type[NFIELDS];
 hid_t      string_type;
 hid_t      file_id;
 hsize_t    chunk_size = 10;
 hsize_t    start;      /* Record to start reading/writing */
 hsize_t    nrecords;   /* Number of records to read/write */
 int        i;

 /* Define 2 new particles to write */
 Particle  particle_in[NRECORDS_WRITE] =
 { {"zero",0,0, 0.0f, 0.0},
 {"one",10,10, 1.0f, 10.0} };

 /* Initialize the field field_type */
 string_type = H5Tcopy( H5T_C_S1 );
 H5Tset_size( string_type, 16 );
 field_type[0] = string_type;
 field_type[1] = H5T_NATIVE_INT;
 field_type[2] = H5T_NATIVE_INT;
 field_type[3] = H5T_NATIVE_FLOAT;
 field_type[4] = H5T_NATIVE_DOUBLE;

/* Create a new file using default properties. */
 file_id = H5Fcreate( "ex_table_03.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );

 /* Make the table */
 H5TBmake_table( "Table Title",
  file_id,
  TABLE_NAME,
  NFIELDS,
  NRECORDS,
  dst_size,
  field_names,
  dst_offset,
  field_type,
  chunk_size,
  fill_data,
  0,           /* no compression */
  NULL );      /* no data written */


 /* Overwrite 2 records starting at record 0 */
 start    = 0;
 nrecords = NRECORDS_WRITE;
 H5TBwrite_records( file_id, TABLE_NAME, start, nrecords, dst_size, dst_offset,
  dst_sizes, particle_in);

--- Last Modified: November 20, 2019 | 12:48 PM