diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2000-09-28 19:12:43 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2000-09-28 19:12:43 (GMT) |
commit | b53bfca418eef5fa9ba3997a2f9310113434fe73 (patch) | |
tree | 02644a2f6d6588b38bbdc51e6932758395b3afb2 /src/H5Farray.c | |
parent | a9afb07bd8c124d068e8f62b8edaf31b585c33d4 (diff) | |
download | hdf5-b53bfca418eef5fa9ba3997a2f9310113434fe73.zip hdf5-b53bfca418eef5fa9ba3997a2f9310113434fe73.tar.gz hdf5-b53bfca418eef5fa9ba3997a2f9310113434fe73.tar.bz2 |
[svn-r2611] Purpose:
Rearrange code
Description:
The data sieve buffering code for contiguously stored datasets was
wedged in the H5F_arr_read/H5F_arr_write routines.
Solution:
Created a new H5Fcontig.c to hold I/O routines for contiguously stored
datasets (like H5Fistore.c for chunked dataset I/O routines) and moved
data sieving code into those routines.
Platforms tested:
Solaris 2.6 (i.e. baldric)
Diffstat (limited to 'src/H5Farray.c')
-rw-r--r-- | src/H5Farray.c | 257 |
1 files changed, 8 insertions, 249 deletions
diff --git a/src/H5Farray.c b/src/H5Farray.c index e581315..a79c4dc 100644 --- a/src/H5Farray.c +++ b/src/H5Farray.c @@ -309,126 +309,10 @@ printf("%s: feature_flags=%lx\n",FUNC,(unsigned long)f->shared->lf->feature_flag "external data read failed"); } } else { - /* Check if data sieving is enabled */ - if(f->shared->lf->feature_flags&H5FD_FEAT_DATA_SIEVE) { - /* Try reading from the data sieve buffer */ - if(f->shared->sieve_buf) { - /* If entire read is within the sieve buffer, read it from the buffer */ - if((addr>=f->shared->sieve_loc && addr<(f->shared->sieve_loc+f->shared->sieve_size)) - && ((addr+elmt_size-1)>=f->shared->sieve_loc && (addr+elmt_size-1)<(f->shared->sieve_loc+f->shared->sieve_size))) { - /* Grab the data out of the buffer */ - HDmemcpy(buf,f->shared->sieve_buf+(addr-f->shared->sieve_loc),elmt_size); - } /* end if */ - /* Entire request is not within this data sieve buffer */ - else { - /* Check if we can actually hold the I/O request in the sieve buffer */ - if(elmt_size>f->shared->sieve_buf_size) { - /* Check for any overlap with the current sieve buffer */ - if((f->shared->sieve_loc>=addr && f->shared->sieve_loc<(addr+elmt_size)) - || ((f->shared->sieve_loc+f->shared->sieve_size-1)>=addr && (f->shared->sieve_loc+f->shared->sieve_size-1)<(addr+elmt_size))) { - /* Flush the sieve buffer, if it's dirty */ - if(f->shared->sieve_dirty) { - /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - - /* Reset sieve buffer dirty flag */ - f->shared->sieve_dirty=0; - } /* end if */ - } /* end if */ - - /* Read directly into the user's buffer */ - if (H5F_block_read(f, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - } /* end if */ - /* Element size fits within the buffer size */ - else { - /* Flush the sieve buffer if it's dirty */ - if(f->shared->sieve_dirty) { - /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - - /* Reset sieve buffer dirty flag */ - f->shared->sieve_dirty=0; - } /* end if */ - - /* Determine the new sieve buffer size & location */ - f->shared->sieve_loc=addr; - - /* Make certain we don't read off the end of the file */ - if (HADDR_UNDEF==(eof=H5FD_get_eof(f->shared->lf))) { - HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, - "unable to determine file size"); - } - f->shared->sieve_size=MIN(eof-addr,f->shared->sieve_buf_size); - - /* Read the new sieve buffer */ - if (H5F_block_read(f, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - - /* Reset sieve buffer dirty flag */ - f->shared->sieve_dirty=0; - - /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,f->shared->sieve_buf,elmt_size); - } /* end else */ - } /* end else */ - } /* end if */ - /* No data sieve buffer yet, go allocate one */ - else { - /* Check if we can actually hold the I/O request in the sieve buffer */ - if(elmt_size>f->shared->sieve_buf_size) { - if (H5F_block_read(f, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - } /* end if */ - else { - /* Allocate room for the data sieve buffer */ - if (NULL==(f->shared->sieve_buf=H5MM_malloc(f->shared->sieve_buf_size))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } - - /* Determine the new sieve buffer size & location */ - f->shared->sieve_loc=addr; - - /* Make certain we don't read off the end of the file */ - if (HADDR_UNDEF==(eof=H5FD_get_eof(f->shared->lf))) { - HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, - "unable to determine file size"); - } - f->shared->sieve_size=MIN(eof-addr,f->shared->sieve_buf_size); - - /* Read the new sieve buffer */ - if (H5F_block_read(f, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - - /* Reset sieve buffer dirty flag */ - f->shared->sieve_dirty=0; - - /* Grab the data out of the buffer (must be first piece of data in buffer ) */ - HDmemcpy(buf,f->shared->sieve_buf,elmt_size); - } /* end else */ - } /* end else */ - } /* end if */ - else { - if (H5F_block_read(f, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - } /* end else */ + if (H5F_contig_read(f, addr, elmt_size, dxpl_id, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "block read failed"); + } } /* end else */ /* Decrement indices and advance pointers */ @@ -671,135 +555,10 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, "external data write failed"); } } else { - /* Check if data sieving is enabled */ - if(f->shared->lf->feature_flags&H5FD_FEAT_DATA_SIEVE) { - /* Try writing to the data sieve buffer */ - if(f->shared->sieve_buf) { - /* If entire write is within the sieve buffer, write it to the buffer */ - if((addr>=f->shared->sieve_loc && addr<(f->shared->sieve_loc+f->shared->sieve_size)) - && ((addr+elmt_size-1)>=f->shared->sieve_loc && (addr+elmt_size-1)<(f->shared->sieve_loc+f->shared->sieve_size))) { - /* Grab the data out of the buffer */ - HDmemcpy(f->shared->sieve_buf+(addr-f->shared->sieve_loc),buf,elmt_size); - - /* Set sieve buffer dirty flag */ - f->shared->sieve_dirty=1; - - } /* end if */ - /* Entire request is not within this data sieve buffer */ - else { - /* Check if we can actually hold the I/O request in the sieve buffer */ - if(elmt_size>f->shared->sieve_buf_size) { - /* Check for any overlap with the current sieve buffer */ - if((f->shared->sieve_loc>=addr && f->shared->sieve_loc<(addr+elmt_size)) - || ((f->shared->sieve_loc+f->shared->sieve_size-1)>=addr && (f->shared->sieve_loc+f->shared->sieve_size-1)<(addr+elmt_size))) { - /* Flush the sieve buffer, if it's dirty */ - if(f->shared->sieve_dirty) { - /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - - /* Reset sieve buffer dirty flag */ - f->shared->sieve_dirty=0; - } /* end if */ - - /* Force the sieve buffer to be re-read the next time */ - f->shared->sieve_loc=HADDR_UNDEF; - f->shared->sieve_size=0; - } /* end if */ - - /* Write directly from the user's buffer */ - if (H5F_block_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - } /* end if */ - /* Element size fits within the buffer size */ - else { - /* Flush the sieve buffer if it's dirty */ - if(f->shared->sieve_dirty) { - /* Write to file */ - if (H5F_block_write(f, H5FD_MEM_DRAW, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - - /* Reset sieve buffer dirty flag */ - f->shared->sieve_dirty=0; - } /* end if */ - - /* Determine the new sieve buffer size & location */ - f->shared->sieve_loc=addr; - - /* Make certain we don't read off the end of the file */ - if (HADDR_UNDEF==(eof=H5FD_get_eof(f->shared->lf))) { - HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, - "unable to determine file size"); - } - f->shared->sieve_size=MIN(eof-addr,f->shared->sieve_buf_size); - - /* Read the new sieve buffer */ - if (H5F_block_read(f, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - - /* Grab the data out of the buffer (must be first piece of data in buffer) */ - HDmemcpy(f->shared->sieve_buf,buf,elmt_size); - - /* Set sieve buffer dirty flag */ - f->shared->sieve_dirty=1; - - } /* end else */ - } /* end else */ - } /* end if */ - /* No data sieve buffer yet, go allocate one */ - else { - /* Check if we can actually hold the I/O request in the sieve buffer */ - if(elmt_size>f->shared->sieve_buf_size) { - if (H5F_block_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - } /* end if */ - else { - /* Allocate room for the data sieve buffer */ - if (NULL==(f->shared->sieve_buf=H5MM_malloc(f->shared->sieve_buf_size))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } - - /* Determine the new sieve buffer size & location */ - f->shared->sieve_loc=addr; - - /* Make certain we don't read off the end of the file */ - if (HADDR_UNDEF==(eof=H5FD_get_eof(f->shared->lf))) { - HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, - "unable to determine file size"); - } - f->shared->sieve_size=MIN(eof-addr,f->shared->sieve_buf_size); - - /* Read the new sieve buffer */ - if (H5F_block_read(f, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); - } - - /* Grab the data out of the buffer (must be first piece of data in buffer) */ - HDmemcpy(f->shared->sieve_buf,buf,elmt_size); - - /* Set sieve buffer dirty flag */ - f->shared->sieve_dirty=1; - } /* end else */ - } /* end else */ - } /* end if */ - else { - if (H5F_block_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); - } - } /* end else */ + if (H5F_contig_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "block write failed"); + } } /* end else */ /* Decrement indices and advance pointers */ |