14 #define _XOPEN_SOURCE 700 22 #include <sys/types.h> 30 #include "sion_error_handler.h" 43 #define TABLE_SIZE 127 45 #define SEARCH_TO_KEY 0 46 #define SEARCH_TO_NEXT 1 47 #define SEARCH_TO_END 2 52 int _sion_scan_forward_to_key(
_sion_filedesc *sion_filedesc, uint64_t key,
int search_mode);
54 size_t _sion_write_data_to_chunks_inline(
_sion_filedesc *sion_filedesc,
const void *data, sion_int64 bytes_to_write);
55 sion_int64 _sion_compute_next_position_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read);
56 size_t _sion_skip_data_from_chunks_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read);
57 size_t _sion_read_data_from_chunks_inline(
_sion_filedesc *sion_filedesc,
void *data, sion_int64 bytes_to_read);
66 #define DFUNCTION "_sion_store_and_write_key_and_len_inline" 67 size_t _sion_store_and_write_key_and_len_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
size_t len) {
68 sion_int64 bytes_to_write;
70 size_t rc=SION_SUCCESS, frc;
73 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
78 buffer[0]=(sion_int64) key;
79 buffer[1]=(sion_int64) len;
80 bytes_to_write=2*
sizeof(sion_int64);
82 frc=_sion_write_data_to_chunks_inline(sion_filedesc, (
const void *) buffer, (sion_int64) bytes_to_write);
85 if(frc != bytes_to_write) {
86 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
87 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) bytes_to_write, (
int) frc, sion_filedesc->
sid));
90 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
95 #define DFUNCTION "_sion_write_value_inline" 96 size_t _sion_write_value_inline(
_sion_filedesc *sion_filedesc,
const void *data, uint64_t key,
size_t len) {
98 sion_int64 bytes_to_write;
99 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
103 frc=_sion_write_data_to_chunks_inline(sion_filedesc, data, (sion_int64) bytes_to_write);
104 if(frc != bytes_to_write) {
105 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
106 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) bytes_to_write, (
int) frc, sion_filedesc->
sid));
109 rc=(size_t) bytes_to_write;
111 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
121 #define DFUNCTION "_sion_find_and_read_key_and_len_inline" 122 int _sion_find_and_read_key_and_len_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
size_t len,
size_t *datalen) {
125 int position_found=0;
126 sion_table_key_t mkey;
127 size_t key_current_pos = (size_t) -1, key_bytes_left = (
size_t) -1;
129 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
132 keymngr=_sion_get_or_init_key_info(sion_filedesc);
143 rc=_sion_keyvalue_keymngr_lookup(keymngr, mkey, &key_current_pos, &key_bytes_left);
144 if(rc!=SION_SUCCESS) {
145 DPRINTFP((2, DFUNCTION, -1,
"key %ld is not found in keymngr, scan forward\n", (
long)mkey));
148 rc=_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_KEY);
151 if(rc==SION_SUCCESS) {
152 DPRINTFP((2, DFUNCTION, -1,
"scan forward found key %ld, get info \n", (
long)mkey));
153 rc=_sion_keyvalue_keymngr_lookup(keymngr, mkey, &key_current_pos, &key_bytes_left);
154 DPRINTFP((2, DFUNCTION, -1,
"key %ld, get info(2): pos=%ld bytes_left=%ld\n", (
long)mkey, (
long) key_current_pos, (
long) key_bytes_left ));
157 DPRINTFP((2, DFUNCTION, -1,
"key %ld, get info(1): pos=%ld bytes_left=%ld\n", (
long)mkey, (
long) key_current_pos, (
long) key_bytes_left ));
159 if(rc==SION_SUCCESS) {
162 if(len<=key_bytes_left) {
166 *datalen=key_bytes_left;
171 DPRINTFP((2, DFUNCTION, -1,
"no more data for key %ld\n", (
long)mkey ));
175 DPRINTFP((2, DFUNCTION, -1,
"check position: current_pos %ld, key_current_pos=%ld len=%ld key_bytes_left=%ld\n",
176 (
long) sion_filedesc->
currentpos, (
long) key_current_pos, (
long) len, (
long) key_bytes_left ));
178 if(key_current_pos!=sion_filedesc->
currentpos) {
179 rc=_sion_move_to_pos(sion_filedesc, key_current_pos);
184 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n", rc));
189 #define DFUNCTION "_sion_read_value_inline" 190 size_t _sion_read_value_inline(
_sion_filedesc *sion_filedesc,
void *data, uint64_t key,
size_t len) {
193 sion_table_key_t mkey;
195 sion_int64 bytes_to_read;
198 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
201 keymngr=_sion_get_or_init_key_info(sion_filedesc);
202 mkey = (sion_table_key_t) key;
211 bread=_sion_read_data_from_chunks_inline(sion_filedesc, (
void *) out, (sion_int64) bytes_to_read);
212 if (bread != bytes_to_read) {
213 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
214 "could not read data (%d bytes) from file ...", (
int) bytes_to_read));
217 DPRINTFP((2, DFUNCTION, -1,
"first value = %3hhu | %c\n", out[0], out[0]));
220 _sion_keyvalue_keymngr_update_read_pos(keymngr, mkey, (
size_t) bread, (sion_int64) sion_filedesc->
currentpos);
224 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",(
int) rc));
230 #define DFUNCTION "_sion_key_full_scan_inline" 232 int rc=SION_NOT_SUCCESS;
234 sion_table_key_t key=0;
236 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
239 keymngr=_sion_get_or_init_key_info(sion_filedesc);
241 if(!_sion_keyvalue_keymngr_is_scan_done(keymngr)) {
242 rc=_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_END);
248 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
254 #define DFUNCTION "_sion_iterator_reset_inline" 259 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
262 keymngr=_sion_get_or_init_key_info(sion_filedesc);
264 rc=_sion_keyvalue_keymngr_iterator_reset(keymngr);
266 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
271 #define DFUNCTION "_sion_iterator_next_inline" 272 int _sion_iterator_next_inline(
_sion_filedesc *sion_filedesc, uint64_t *keyptr,
size_t *sizeptr) {
273 int rc=SION_NOT_SUCCESS;
275 sion_table_key_t key=0;
276 size_t current_pos, offset, len;
278 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
281 keymngr=_sion_get_or_init_key_info(sion_filedesc);
283 if(_sion_keyvalue_keymngr_iterator_next(keymngr, &key, ¤t_pos, &offset, &len)==SION_SUCCESS) {
288 if (_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_NEXT)==SION_SUCCESS) {
290 if(_sion_keyvalue_keymngr_iterator_next(keymngr, &key, ¤t_pos, &offset, &len)==SION_SUCCESS) {
293 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN, sion_filedesc->
rank,
294 "internal error: block could not be find at end of block list ..."));
303 if(rc==SION_SUCCESS) {
304 *keyptr = (uint64_t) key;
305 *sizeptr = (size_t) len;
308 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
313 #define DFUNCTION "_sion_seek_key_inline" 314 int _sion_seek_key_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
int blocknum, sion_int64 posinblock) {
315 int rc=SION_NOT_SUCCESS;
319 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
322 keymngr=_sion_get_or_init_key_info(sion_filedesc);
325 rc=_sion_keyvalue_keymngr_lookup_and_set_pos(keymngr, key, blocknum, posinblock, &offset, &len);
326 DPRINTFP((2, DFUNCTION, -1,
"after first lookup rc=%d offset=%d len=%d\n",rc, (
int)offset, (
int) len ));
328 while( (rc!=SION_SUCCESS) && !_sion_keyvalue_keymngr_is_scan_done(keymngr) ) {
331 DPRINTFP((2, DFUNCTION, -1,
"scan forward to find key %d\n",(
int) key));
332 if (_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_NEXT)==SION_SUCCESS) {
335 rc=_sion_keyvalue_keymngr_lookup_and_set_pos(keymngr, key, blocknum, posinblock, &offset, &len);
336 DPRINTFP((2, DFUNCTION, -1,
"in loop lookup rc=%d offset=%d len=%d\n",rc, (
int)offset, (
int) len ));
343 if( rc==SION_SUCCESS ) {
344 DPRINTFP((2, DFUNCTION, -1,
"move from %ld to new scanpos (%ld) \n",(
long) sion_filedesc->
currentpos,(
long) offset));
345 rc=_sion_move_to_pos(sion_filedesc, offset);
348 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
353 #define DFUNCTION "_sion_key_list_iterator_reset_inline" 354 int _sion_key_list_iterator_reset_inline(
_sion_filedesc *sion_filedesc) {
358 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
361 keymngr=_sion_get_or_init_key_info(sion_filedesc);
363 rc=_sion_keyvalue_keymngr_key_list_iterator_reset(keymngr);
365 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
370 #define DFUNCTION "_sion_iterator_next_inline" 371 int _sion_key_list_iterator_next_inline(
_sion_filedesc *sion_filedesc, uint64_t *keyptr) {
372 int rc=SION_NOT_SUCCESS;
374 sion_table_key_t key=0;
376 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
379 keymngr=_sion_get_or_init_key_info(sion_filedesc);
381 if(_sion_keyvalue_keymngr_key_list_iterator_next(keymngr, &key)==SION_SUCCESS) {
382 *keyptr = (uint64_t) key;
389 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d key=%ld\n",rc,(
long) key));
395 #define DFUNCTION "_sion_key_get_stat_inline" 397 int rc=SION_NOT_SUCCESS;
399 sion_table_key_t key=0;
401 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
404 keymngr=_sion_get_or_init_key_info(sion_filedesc);
406 key= (sion_table_key_t) searchkey;
408 if(_sion_keyvalue_keymngr_key_get_stat(keymngr, key, keystat)==SION_SUCCESS) {
414 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d key=%ld\n",rc,(
long) key));
423 #define DFUNCTION "_sion_scan_forward_to_key" 424 int _sion_scan_forward_to_key(
_sion_filedesc *sion_filedesc, uint64_t key,
int search_mode) {
425 int rc = SION_SUCCESS;
427 sion_table_key_t mkey;
431 size_t bytes_left, lastposinblock, lastposinfile;
432 uint64_t key_and_len[2];
434 size_t bread, bskip, len;
436 DPRINTFP((2, DFUNCTION, -1,
"enter key=%ld\n",(
long) key));
444 if(_sion_keyvalue_keymngr_get_next_scan_pos(keymngr, &scanpos) != SION_SUCCESS) {
447 DPRINTFP((2, DFUNCTION, -1,
"set scanpos to first pos in file pos=%ld\n",(
long) scanpos));
453 DPRINTFP((2, DFUNCTION, -1,
"check if not already scanned to endoffile scanpos=%ld lastposinfile=%ld lastchunknr=%d\n",(
long) scanpos,(
long) lastposinfile, (
int) sion_filedesc->
lastchunknr ));
454 if(scanpos>=lastposinfile) {
455 DPRINTFP((2, DFUNCTION, -1,
"scan is already at end of file (%ld>=%ld) \n",(
long) scanpos, (
long) lastposinfile));
456 _sion_keyvalue_keymngr_set_scan_done(keymngr);
461 if( (sion_filedesc->
currentpos != scanpos) && (!_sion_keyvalue_keymngr_is_scan_done(keymngr)) ) {
462 DPRINTFP((2, DFUNCTION, -1,
"move from %ld to new scanpos (%ld) \n",(
long) sion_filedesc->
currentpos,(
long) scanpos));
463 rc=_sion_move_to_pos(sion_filedesc, scanpos);
467 while ( (!_sion_keyvalue_keymngr_is_scan_done(keymngr)) && (!key_found) ) {
471 bytes_left = lastposinblock - sion_filedesc->
currentpos;
472 DPRINTFP((2, DFUNCTION, -1,
"search loop: lastposinblock=%ld bytes_left=%ld currentpos=%ld\n",(
long) lastposinblock,(
long) bytes_left,(
long) sion_filedesc->
currentpos));
476 if ( bytes_left > 0 ) {
478 bread=_sion_read_data_from_chunks_inline(sion_filedesc, (
void *) key_and_len, (sion_int64)
sizeof(key_and_len));
479 if (bread !=
sizeof(key_and_len)) {
480 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
481 "could not read data (%d bytes) from file ...", (
int)
sizeof(key_and_len)));
486 DPRINTFP((2, DFUNCTION, -1,
"search loop: found next key,len (%ld,%ld)\n",(
long) key_and_len[0],(
long) key_and_len[1]));
489 DPRINTFP((2, DFUNCTION, -1,
"search loop: position is now %ld bytes_left=%ld\n",(
long) sion_filedesc->
currentpos, (
long) bytes_left));
493 DPRINTFP((2, DFUNCTION, -1,
"search loop: data starts in next chunk, moving forward\n"));
494 if(! _sion_move_to_next_chunk(sion_filedesc)) {
495 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
496 "could not move to data section in next block ..."));
500 bytes_left = lastposinblock - sion_filedesc->
currentpos;
501 DPRINTFP((2, DFUNCTION, -1,
"search loop: position is moved to %ld bytes_left=%ld\n",(
long) sion_filedesc->
currentpos, (
long) bytes_left));
507 rc=_sion_keyvalue_keymngr_add_block(keymngr, mkey, (
size_t) sion_filedesc->
currentpos, len);
508 DPRINTFP((2, DFUNCTION, -1,
"search loop: stored new block key=%ld pos=%ld len=%ld\n",(
long) mkey, (
long) sion_filedesc->
currentpos, (
long) len));
512 ( ( (search_mode==SEARCH_TO_KEY) && (key_and_len[0] == key) ) || (search_mode==SEARCH_TO_NEXT) )
513 && ( !(search_mode==SEARCH_TO_END) )
515 DPRINTFP((2, DFUNCTION, -1,
"search loop: found searched key=%ld, leaving\n",(
long) key));
518 scanpos=_sion_compute_next_position_inline(sion_filedesc, len);
520 DPRINTFP((2, DFUNCTION, -1,
"search loop: found another key=%ld <=> %ld, continue\n",(
long) key_and_len[0], (
long) key));
523 DPRINTFP((2, DFUNCTION, -1,
"search loop: found move position forward by %ld bytes\n",(
long) len));
524 bskip=_sion_skip_data_from_chunks_inline(sion_filedesc, (sion_int64) len);
526 if ( bskip == len ) {
531 bytes_left = lastposinblock - sion_filedesc->
currentpos;
535 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
536 "could not skip data section of one block (%d bytes) from file ...", (
int) len));
541 DPRINTFP((2, DFUNCTION, -1,
"search loop: chunk empty, move to next chunk\n"));
542 if(! _sion_move_to_next_chunk(sion_filedesc)) {
543 _sion_keyvalue_keymngr_set_scan_done(keymngr);
544 if(search_mode!=SEARCH_TO_END) {
556 if(! _sion_move_to_next_chunk(sion_filedesc)) {
557 _sion_keyvalue_keymngr_set_scan_done(keymngr);
561 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
562 "unknown data at end of chunk (%d bytes) ...", (
int) bytes_left));
569 if(_sion_keyvalue_keymngr_set_next_scan_pos(keymngr, scanpos) != SION_SUCCESS) {
570 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
571 "internal error set seekpos ..."));
574 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
580 #define DFUNCTION "_sion_get_or_init_key_info" 585 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
588 DPRINTFP((2, DFUNCTION, -1,
"sion_filedesc->keyvalptr == NULL\n"));
589 keymngr =_sion_keyvalue_keymngr_init(TABLE_SIZE);
590 if (keymngr == NULL) {
591 _sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"could not allocate keymngr ...");
594 DPRINTFP((2, DFUNCTION, -1,
"alloc now KEYVALPTR = %x\n",sion_filedesc->
keyvalptr));
597 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
602 #define DFUNCTION "_sion_move_to_next_chunk" 604 int rc = SION_SUCCESS;
606 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
619 DPRINTFP((2, DFUNCTION, -1,
"leave, rc = %d\n", rc));
624 #define DFUNCTION "_sion_move_to_pos" 625 int _sion_move_to_pos(
_sion_filedesc *sion_filedesc,
size_t pos) {
626 int rc = SION_SUCCESS;
627 size_t block_min_pos, block_max_pos;
630 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
635 DPRINTFP((2, DFUNCTION, -1,
"current_chunk: %ld to %ld (pos=%ld)\n", (
long) block_min_pos, (
long) block_max_pos, (
long) pos));
637 if ( (pos>=block_min_pos) && (pos<block_max_pos) ) {
643 DPRINTFP((2, DFUNCTION, -1,
"stay in current chunk: currentpos=%ld\n", (
long) sion_filedesc->
currentpos));
650 block_max_pos = block_min_pos+sion_filedesc->
blocksizes[c];
652 DPRINTFP((2, DFUNCTION, -1,
"check chunk%2d: %ld to %ld (pos=%ld)\n", c, (
long) block_min_pos, (
long) block_max_pos, (
long) pos));
654 if ( (pos>=block_min_pos) && (pos<block_max_pos) ) {
662 DPRINTFP((2, DFUNCTION, -1,
"stay in this chunk: currentpos=%ld\n", (
long) sion_filedesc->
currentpos));
673 DPRINTFP((2, DFUNCTION, -1,
"leave, rc = %d\n", rc));
679 #define DFUNCTION "_sion_write_data_to_chunks_inline" 680 size_t _sion_write_data_to_chunks_inline(
_sion_filedesc *sion_filedesc,
const void *data, sion_int64 bytes_to_write) {
681 sion_int64 btowr, byteswritten, offset;
685 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
689 while(bytes_to_write>0) {
695 btowr=bytes_to_write;
696 if ((byteswritten + btowr) > sion_filedesc->
chunksize) btowr = sion_filedesc->
chunksize - byteswritten;
697 DPRINTFP((2, DFUNCTION, -1,
" bytes_to_write=%ld btowr=%ld chunksize=%ld byteswritten=%ld currentblocknr=%d blsize[%d]=%ld\n",
698 (
long) bytes_to_write, (
long) btowr, (
long) sion_filedesc->
chunksize, (
long) byteswritten, (
int) sion_filedesc->
currentblocknr,
706 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
707 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) btowr, (
int) frc, sion_filedesc->
sid));
712 bytes_to_write -=btowr;
716 if(bytes_to_write>0) {
724 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
730 #define DFUNCTION "_sion_compute_next_position_inline" 731 sion_int64 _sion_compute_next_position_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read) {
732 sion_int64 btord = 0, bytesread = 0, offset = 0;
736 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
742 DPRINTFP((2, DFUNCTION, -1,
" currentpos=%ld bytesread=%ld blocknr=%d bytes_to_read=%ld\n",
743 (
long) sion_filedesc->
currentpos, (
long) bytesread, (
int) blocknr, (
long) bytes_to_read ));
745 DPRINTFP((2, DFUNCTION, -1,
" blocksizes[%d]=%ld\n",
750 offset=sion_filedesc->
currentpos+bytes_to_read;
753 bytes_to_read-=btord;
755 DPRINTFP((2, DFUNCTION, -1,
" skip to next block, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
758 while(bytes_to_read>0) {
761 if (blocknr < sion_filedesc->lastchunknr) { blocknr++; }
else {
762 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"internal error next block not available, but should ..."));
765 DPRINTFP((2, DFUNCTION, -1,
" blocksizes[%d]=%ld\n", (
int) blocknr, (
long) sion_filedesc->
blocksizes[blocknr] ));
766 if ( bytes_to_read > sion_filedesc->
blocksizes[blocknr]) {
768 bytes_to_read-=btord;
769 DPRINTFP((2, DFUNCTION, -1,
"whole block, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
780 if (blocknr < sion_filedesc->lastchunknr) {
783 DPRINTFP((2, DFUNCTION, -1,
" behind end of block, move to next block, blocksizes[%d]=%ld\n", (
int) blocknr, (
long) sion_filedesc->
blocksizes[blocknr] ));
788 DPRINTFP((2, DFUNCTION, -1,
"leave offset=%ld\n",(
long) offset));
794 #define DFUNCTION "_sion_skip_data_from_chunks_inline" 795 size_t _sion_skip_data_from_chunks_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read) {
796 sion_int64 btord, bytesread, offset;
800 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
804 while(bytes_to_read>0) {
812 DPRINTFP((2, DFUNCTION, -1,
" bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
818 bytes_to_read -=btord;
822 if(bytes_to_read>0) {
824 if(! _sion_move_to_next_chunk(sion_filedesc)) {
825 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
826 "could not read data (%d bytes) to file (end of file reached sid=%d) ...", (
int) btord, sion_filedesc->
sid));
837 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
843 #define DFUNCTION "_sion_read_data_from_chunks_inline" 844 size_t _sion_read_data_from_chunks_inline(
_sion_filedesc *sion_filedesc,
void *data, sion_int64 bytes_to_read) {
845 sion_int64 btord, bytesread, offset;
849 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
853 while(bytes_to_read>0) {
857 DPRINTFP((2, DFUNCTION, -1,
"bytesread=%ld, curpos=%ld,startpos=%ld,curblock=%ld,gskip=%ld\n",
864 DPRINTFP((2, DFUNCTION, -1,
"block is split to multiple chunks, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
866 DPRINTFP((2, DFUNCTION, -1,
"block in one chunk, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
874 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
875 "could not read data (%d bytes) to file (frc=%d sid=%d) ...", (
int) btord, (
int) frc, sion_filedesc->
sid));
880 bytes_to_read -=btord;
884 if(bytes_to_read>0) {
886 if(! _sion_move_to_next_chunk(sion_filedesc)) {
887 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
888 "could not read data (%d bytes) to file (end of file reached, frc=%d sid=%d) ...", (
int) btord, (
int) frc, sion_filedesc->
sid));
895 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
901 #define DFUNCTION "_sion_keyval_dup_dataptr_inline" 907 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
914 keymngr =_sion_keyvalue_keymngr_dup(keymngr_orig,new_filedesc->
dup_mode, new_filedesc->
dup_sel_key);
915 if (keymngr == NULL) {
916 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"dup: could not duplicate keymngr ..."));
926 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
sion_int64 _sion_file_write(const void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Write data to file.
int _sion_flush_block(_sion_filedesc *sion_filedesc)
Update the internal data structure.
sion_int64 _sion_file_set_position(_sion_fileptr *sion_fileptr, sion_int64 startpointer)
Set new position in file.
Sion File Descriptor Structure.
int _sion_file_purge(_sion_fileptr *sion_fileptr)
Purge data to file.
sion_int64 _sion_file_read(void *data, sion_int64 bytes, _sion_fileptr *sion_fileptr)
Read data from file.
void sion_swap(void *target, void *source, int size, int n, int do_swap)
sion_int32 currentblocknr
int _sion_create_new_block(_sion_filedesc *sion_filedesc)
Create a new block for the internal data structure.