20 #include <sys/types.h> 28 #include "sion_error_handler.h" 41 #define TABLE_SIZE 127 43 #define SEARCH_TO_KEY 0 44 #define SEARCH_TO_NEXT 1 45 #define SEARCH_TO_END 2 50 int _sion_scan_forward_to_key(
_sion_filedesc *sion_filedesc, uint64_t key,
int search_mode);
52 size_t _sion_write_data_to_chunks_inline(
_sion_filedesc *sion_filedesc,
const void *data, sion_int64 bytes_to_write);
53 sion_int64 _sion_compute_next_position_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read);
54 size_t _sion_skip_data_from_chunks_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read);
55 size_t _sion_read_data_from_chunks_inline(
_sion_filedesc *sion_filedesc,
void *data, sion_int64 bytes_to_read);
64 #define DFUNCTION "_sion_store_and_write_key_and_len_inline" 65 size_t _sion_store_and_write_key_and_len_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
size_t len) {
66 sion_int64 bytes_to_write;
68 size_t rc=SION_SUCCESS, frc;
71 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
76 buffer[0]=(sion_int64) key;
77 buffer[1]=(sion_int64) len;
78 bytes_to_write=2*
sizeof(sion_int64);
80 frc=_sion_write_data_to_chunks_inline(sion_filedesc, (
const void *) buffer, (sion_int64) bytes_to_write);
83 if(frc != bytes_to_write) {
84 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
85 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) bytes_to_write, (
int) frc, sion_filedesc->
sid));
88 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
93 #define DFUNCTION "_sion_write_value_inline" 94 size_t _sion_write_value_inline(
_sion_filedesc *sion_filedesc,
const void *data, uint64_t key,
size_t len) {
96 sion_int64 bytes_to_write;
97 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
101 frc=_sion_write_data_to_chunks_inline(sion_filedesc, data, (sion_int64) bytes_to_write);
102 if(frc != bytes_to_write) {
103 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
104 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) bytes_to_write, (
int) frc, sion_filedesc->
sid));
107 rc=(size_t) bytes_to_write;
109 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
119 #define DFUNCTION "_sion_find_and_read_key_and_len_inline" 120 int _sion_find_and_read_key_and_len_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
size_t len,
size_t *datalen) {
123 int position_found=0;
124 sion_table_key_t mkey;
125 size_t key_current_pos = (size_t) -1, key_bytes_left = (
size_t) -1;
127 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
130 keymngr=_sion_get_or_init_key_info(sion_filedesc);
141 rc=_sion_keyvalue_keymngr_lookup(keymngr, mkey, &key_current_pos, &key_bytes_left);
142 if(rc!=SION_SUCCESS) {
143 DPRINTFP((2, DFUNCTION, -1,
"key %ld is not found in keymngr, scan forward\n", (
long)mkey));
146 rc=_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_KEY);
149 if(rc==SION_SUCCESS) {
150 DPRINTFP((2, DFUNCTION, -1,
"scan forward found key %ld, get info \n", (
long)mkey));
151 rc=_sion_keyvalue_keymngr_lookup(keymngr, mkey, &key_current_pos, &key_bytes_left);
152 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 ));
155 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 ));
157 if(rc==SION_SUCCESS) {
160 if(len<=key_bytes_left) {
164 *datalen=key_bytes_left;
169 DPRINTFP((2, DFUNCTION, -1,
"no more data for key %ld\n", (
long)mkey ));
173 DPRINTFP((2, DFUNCTION, -1,
"check position: current_pos %ld, key_current_pos=%ld len=%ld key_bytes_left=%ld\n",
174 (
long) sion_filedesc->
currentpos, (
long) key_current_pos, (
long) len, (
long) key_bytes_left ));
176 if(key_current_pos!=sion_filedesc->
currentpos) {
177 rc=_sion_move_to_pos(sion_filedesc, key_current_pos);
182 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n", rc));
187 #define DFUNCTION "_sion_read_value_inline" 188 size_t _sion_read_value_inline(
_sion_filedesc *sion_filedesc,
void *data, uint64_t key,
size_t len) {
191 sion_table_key_t mkey;
193 sion_int64 bytes_to_read;
196 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
199 keymngr=_sion_get_or_init_key_info(sion_filedesc);
200 mkey = (sion_table_key_t) key;
209 bread=_sion_read_data_from_chunks_inline(sion_filedesc, (
void *) out, (sion_int64) bytes_to_read);
210 if (bread != bytes_to_read) {
211 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
212 "could not read data (%d bytes) from file ...", (
int) bytes_to_read));
215 DPRINTFP((2, DFUNCTION, -1,
"first value = %3hhu | %c\n", out[0], out[0]));
218 _sion_keyvalue_keymngr_update_read_pos(keymngr, mkey, (
size_t) bread, (sion_int64) sion_filedesc->
currentpos);
222 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",(
int) rc));
228 #define DFUNCTION "_sion_key_full_scan_inline" 230 int rc=SION_NOT_SUCCESS;
232 sion_table_key_t key=0;
234 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
237 keymngr=_sion_get_or_init_key_info(sion_filedesc);
239 if(!_sion_keyvalue_keymngr_is_scan_done(keymngr)) {
240 rc=_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_END);
246 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
252 #define DFUNCTION "_sion_iterator_reset_inline" 257 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
260 keymngr=_sion_get_or_init_key_info(sion_filedesc);
262 rc=_sion_keyvalue_keymngr_iterator_reset(keymngr);
264 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
269 #define DFUNCTION "_sion_iterator_next_inline" 270 int _sion_iterator_next_inline(
_sion_filedesc *sion_filedesc, uint64_t *keyptr,
size_t *sizeptr) {
271 int rc=SION_NOT_SUCCESS;
273 sion_table_key_t key=0;
274 size_t current_pos, offset, len;
276 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
279 keymngr=_sion_get_or_init_key_info(sion_filedesc);
281 if(_sion_keyvalue_keymngr_iterator_next(keymngr, &key, ¤t_pos, &offset, &len)==SION_SUCCESS) {
286 if (_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_NEXT)==SION_SUCCESS) {
288 if(_sion_keyvalue_keymngr_iterator_next(keymngr, &key, ¤t_pos, &offset, &len)==SION_SUCCESS) {
291 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN, sion_filedesc->
rank,
292 "internal error: block could not be find at end of block list ..."));
301 if(rc==SION_SUCCESS) {
302 *keyptr = (uint64_t) key;
303 *sizeptr = (size_t) len;
306 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
311 #define DFUNCTION "_sion_seek_key_inline" 312 int _sion_seek_key_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
int blocknum, sion_int64 posinblock) {
313 int rc=SION_NOT_SUCCESS;
317 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
320 keymngr=_sion_get_or_init_key_info(sion_filedesc);
323 rc=_sion_keyvalue_keymngr_lookup_and_set_pos(keymngr, key, blocknum, posinblock, &offset, &len);
324 DPRINTFP((2, DFUNCTION, -1,
"after first lookup rc=%d offset=%d len=%d\n",rc, (
int)offset, (
int) len ));
326 while( (rc!=SION_SUCCESS) && !_sion_keyvalue_keymngr_is_scan_done(keymngr) ) {
329 DPRINTFP((2, DFUNCTION, -1,
"scan forward to find key %d\n",(
int) key));
330 if (_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_NEXT)==SION_SUCCESS) {
333 rc=_sion_keyvalue_keymngr_lookup_and_set_pos(keymngr, key, blocknum, posinblock, &offset, &len);
334 DPRINTFP((2, DFUNCTION, -1,
"in loop lookup rc=%d offset=%d len=%d\n",rc, (
int)offset, (
int) len ));
341 if( rc==SION_SUCCESS ) {
342 DPRINTFP((2, DFUNCTION, -1,
"move from %ld to new scanpos (%ld) \n",(
long) sion_filedesc->
currentpos,(
long) offset));
343 rc=_sion_move_to_pos(sion_filedesc, offset);
346 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
351 #define DFUNCTION "_sion_key_list_iterator_reset_inline" 352 int _sion_key_list_iterator_reset_inline(
_sion_filedesc *sion_filedesc) {
356 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
359 keymngr=_sion_get_or_init_key_info(sion_filedesc);
361 rc=_sion_keyvalue_keymngr_key_list_iterator_reset(keymngr);
363 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
368 #define DFUNCTION "_sion_iterator_next_inline" 369 int _sion_key_list_iterator_next_inline(
_sion_filedesc *sion_filedesc, uint64_t *keyptr) {
370 int rc=SION_NOT_SUCCESS;
372 sion_table_key_t key=0;
374 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
377 keymngr=_sion_get_or_init_key_info(sion_filedesc);
379 if(_sion_keyvalue_keymngr_key_list_iterator_next(keymngr, &key)==SION_SUCCESS) {
380 *keyptr = (uint64_t) key;
387 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d key=%ld\n",rc,(
long) key));
393 #define DFUNCTION "_sion_key_get_stat_inline" 395 int rc=SION_NOT_SUCCESS;
397 sion_table_key_t key=0;
399 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
402 keymngr=_sion_get_or_init_key_info(sion_filedesc);
404 key= (sion_table_key_t) searchkey;
406 if(_sion_keyvalue_keymngr_key_get_stat(keymngr, key, keystat)==SION_SUCCESS) {
412 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d key=%ld\n",rc,(
long) key));
421 #define DFUNCTION "_sion_scan_forward_to_key" 422 int _sion_scan_forward_to_key(
_sion_filedesc *sion_filedesc, uint64_t key,
int search_mode) {
423 int rc = SION_SUCCESS;
425 sion_table_key_t mkey;
429 size_t bytes_left, lastposinblock, lastposinfile;
430 uint64_t key_and_len[2];
432 size_t bread, bskip, len;
434 DPRINTFP((2, DFUNCTION, -1,
"enter key=%ld\n",(
long) key));
442 if(_sion_keyvalue_keymngr_get_next_scan_pos(keymngr, &scanpos) != SION_SUCCESS) {
445 DPRINTFP((2, DFUNCTION, -1,
"set scanpos to first pos in file pos=%ld\n",(
long) scanpos));
451 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 ));
452 if(scanpos>=lastposinfile) {
453 DPRINTFP((2, DFUNCTION, -1,
"scan is already at end of file (%ld>=%ld) \n",(
long) scanpos, (
long) lastposinfile));
454 _sion_keyvalue_keymngr_set_scan_done(keymngr);
459 if( (sion_filedesc->
currentpos != scanpos) && (!_sion_keyvalue_keymngr_is_scan_done(keymngr)) ) {
460 DPRINTFP((2, DFUNCTION, -1,
"move from %ld to new scanpos (%ld) \n",(
long) sion_filedesc->
currentpos,(
long) scanpos));
461 rc=_sion_move_to_pos(sion_filedesc, scanpos);
465 while ( (!_sion_keyvalue_keymngr_is_scan_done(keymngr)) && (!key_found) ) {
469 bytes_left = lastposinblock - sion_filedesc->
currentpos;
470 DPRINTFP((2, DFUNCTION, -1,
"search loop: lastposinblock=%ld bytes_left=%ld currentpos=%ld\n",(
long) lastposinblock,(
long) bytes_left,(
long) sion_filedesc->
currentpos));
474 if ( bytes_left > 0 ) {
476 bread=_sion_read_data_from_chunks_inline(sion_filedesc, (
void *) key_and_len, (sion_int64)
sizeof(key_and_len));
477 if (bread !=
sizeof(key_and_len)) {
478 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
479 "could not read data (%d bytes) from file ...", (
int)
sizeof(key_and_len)));
484 DPRINTFP((2, DFUNCTION, -1,
"search loop: found next key,len (%ld,%ld)\n",(
long) key_and_len[0],(
long) key_and_len[1]));
487 DPRINTFP((2, DFUNCTION, -1,
"search loop: position is now %ld bytes_left=%ld\n",(
long) sion_filedesc->
currentpos, (
long) bytes_left));
491 DPRINTFP((2, DFUNCTION, -1,
"search loop: data starts in next chunk, moving forward\n"));
492 if(! _sion_move_to_next_chunk(sion_filedesc)) {
493 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
494 "could not move to data section in next block ..."));
498 bytes_left = lastposinblock - sion_filedesc->
currentpos;
499 DPRINTFP((2, DFUNCTION, -1,
"search loop: position is moved to %ld bytes_left=%ld\n",(
long) sion_filedesc->
currentpos, (
long) bytes_left));
505 rc=_sion_keyvalue_keymngr_add_block(keymngr, mkey, (
size_t) sion_filedesc->
currentpos, len);
506 DPRINTFP((2, DFUNCTION, -1,
"search loop: stored new block key=%ld pos=%ld len=%ld\n",(
long) mkey, (
long) sion_filedesc->
currentpos, (
long) len));
510 ( ( (search_mode==SEARCH_TO_KEY) && (key_and_len[0] == key) ) || (search_mode==SEARCH_TO_NEXT) )
511 && ( !(search_mode==SEARCH_TO_END) )
513 DPRINTFP((2, DFUNCTION, -1,
"search loop: found searched key=%ld, leaving\n",(
long) key));
516 scanpos=_sion_compute_next_position_inline(sion_filedesc, len);
518 DPRINTFP((2, DFUNCTION, -1,
"search loop: found another key=%ld <=> %ld, continue\n",(
long) key_and_len[0], (
long) key));
521 DPRINTFP((2, DFUNCTION, -1,
"search loop: found move position forward by %ld bytes\n",(
long) len));
522 bskip=_sion_skip_data_from_chunks_inline(sion_filedesc, (sion_int64) len);
524 if ( bskip == len ) {
529 bytes_left = lastposinblock - sion_filedesc->
currentpos;
533 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
534 "could not skip data section of one block (%d bytes) from file ...", (
int) len));
539 DPRINTFP((2, DFUNCTION, -1,
"search loop: chunk empty, move to next chunk\n"));
540 if(! _sion_move_to_next_chunk(sion_filedesc)) {
541 _sion_keyvalue_keymngr_set_scan_done(keymngr);
542 if(search_mode!=SEARCH_TO_END) {
554 if(! _sion_move_to_next_chunk(sion_filedesc)) {
555 _sion_keyvalue_keymngr_set_scan_done(keymngr);
559 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
560 "unknown data at end of chunk (%d bytes) ...", (
int) bytes_left));
567 if(_sion_keyvalue_keymngr_set_next_scan_pos(keymngr, scanpos) != SION_SUCCESS) {
568 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
569 "internal error set seekpos ..."));
572 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
578 #define DFUNCTION "_sion_get_or_init_key_info" 583 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
586 DPRINTFP((2, DFUNCTION, -1,
"sion_filedesc->keyvalptr == NULL\n"));
587 keymngr =_sion_keyvalue_keymngr_init(TABLE_SIZE);
588 if (keymngr == NULL) {
589 _sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"could not allocate keymngr ...");
592 DPRINTFP((2, DFUNCTION, -1,
"alloc now KEYVALPTR = %x\n",sion_filedesc->
keyvalptr));
595 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
600 #define DFUNCTION "_sion_move_to_next_chunk" 602 int rc = SION_SUCCESS;
604 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
617 DPRINTFP((2, DFUNCTION, -1,
"leave, rc = %d\n", rc));
622 #define DFUNCTION "_sion_move_to_pos" 623 int _sion_move_to_pos(
_sion_filedesc *sion_filedesc,
size_t pos) {
624 int rc = SION_SUCCESS;
625 size_t block_min_pos, block_max_pos;
628 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
633 DPRINTFP((2, DFUNCTION, -1,
"current_chunk: %ld to %ld (pos=%ld)\n", (
long) block_min_pos, (
long) block_max_pos, (
long) pos));
635 if ( (pos>=block_min_pos) && (pos<block_max_pos) ) {
641 DPRINTFP((2, DFUNCTION, -1,
"stay in current chunk: currentpos=%ld\n", (
long) sion_filedesc->
currentpos));
648 block_max_pos = block_min_pos+sion_filedesc->
blocksizes[c];
650 DPRINTFP((2, DFUNCTION, -1,
"check chunk%2d: %ld to %ld (pos=%ld)\n", c, (
long) block_min_pos, (
long) block_max_pos, (
long) pos));
652 if ( (pos>=block_min_pos) && (pos<block_max_pos) ) {
660 DPRINTFP((2, DFUNCTION, -1,
"stay in this chunk: currentpos=%ld\n", (
long) sion_filedesc->
currentpos));
671 DPRINTFP((2, DFUNCTION, -1,
"leave, rc = %d\n", rc));
677 #define DFUNCTION "_sion_write_data_to_chunks_inline" 678 size_t _sion_write_data_to_chunks_inline(
_sion_filedesc *sion_filedesc,
const void *data, sion_int64 bytes_to_write) {
679 sion_int64 btowr, byteswritten, offset;
683 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
687 while(bytes_to_write>0) {
693 btowr=bytes_to_write;
694 if ((byteswritten + btowr) > sion_filedesc->
chunksize) btowr = sion_filedesc->
chunksize - byteswritten;
695 DPRINTFP((2, DFUNCTION, -1,
" bytes_to_write=%ld btowr=%ld chunksize=%ld byteswritten=%ld currentblocknr=%d blsize[%d]=%ld\n",
696 (
long) bytes_to_write, (
long) btowr, (
long) sion_filedesc->
chunksize, (
long) byteswritten, (
int) sion_filedesc->
currentblocknr,
704 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
705 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) btowr, (
int) frc, sion_filedesc->
sid));
710 bytes_to_write -=btowr;
714 if(bytes_to_write>0) {
722 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
728 #define DFUNCTION "_sion_compute_next_position_inline" 729 sion_int64 _sion_compute_next_position_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read) {
730 sion_int64 btord = 0, bytesread = 0, offset = 0;
734 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
740 DPRINTFP((2, DFUNCTION, -1,
" currentpos=%ld bytesread=%ld blocknr=%d bytes_to_read=%ld\n",
741 (
long) sion_filedesc->
currentpos, (
long) bytesread, (
int) blocknr, (
long) bytes_to_read ));
743 DPRINTFP((2, DFUNCTION, -1,
" blocksizes[%d]=%ld\n",
748 offset=sion_filedesc->
currentpos+bytes_to_read;
751 bytes_to_read-=btord;
753 DPRINTFP((2, DFUNCTION, -1,
" skip to next block, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
756 while(bytes_to_read>0) {
759 if (blocknr < sion_filedesc->lastchunknr) { blocknr++; }
else {
760 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"internal error next block not available, but should ..."));
763 DPRINTFP((2, DFUNCTION, -1,
" blocksizes[%d]=%ld\n", (
int) blocknr, (
long) sion_filedesc->
blocksizes[blocknr] ));
764 if ( bytes_to_read > sion_filedesc->
blocksizes[blocknr]) {
766 bytes_to_read-=btord;
767 DPRINTFP((2, DFUNCTION, -1,
"whole block, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
778 if (blocknr < sion_filedesc->lastchunknr) {
781 DPRINTFP((2, DFUNCTION, -1,
" behind end of block, move to next block, blocksizes[%d]=%ld\n", (
int) blocknr, (
long) sion_filedesc->
blocksizes[blocknr] ));
786 DPRINTFP((2, DFUNCTION, -1,
"leave offset=%ld\n",(
long) offset));
792 #define DFUNCTION "_sion_skip_data_from_chunks_inline" 793 size_t _sion_skip_data_from_chunks_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read) {
794 sion_int64 btord, bytesread, offset;
798 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
802 while(bytes_to_read>0) {
810 DPRINTFP((2, DFUNCTION, -1,
" bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
816 bytes_to_read -=btord;
820 if(bytes_to_read>0) {
822 if(! _sion_move_to_next_chunk(sion_filedesc)) {
823 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
824 "could not read data (%d bytes) to file (end of file reached sid=%d) ...", (
int) btord, sion_filedesc->
sid));
835 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
841 #define DFUNCTION "_sion_read_data_from_chunks_inline" 842 size_t _sion_read_data_from_chunks_inline(
_sion_filedesc *sion_filedesc,
void *data, sion_int64 bytes_to_read) {
843 sion_int64 btord, bytesread, offset;
847 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
851 while(bytes_to_read>0) {
855 DPRINTFP((2, DFUNCTION, -1,
"bytesread=%ld, curpos=%ld,startpos=%ld,curblock=%ld,gskip=%ld\n",
862 DPRINTFP((2, DFUNCTION, -1,
"block is split to multiple chunks, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
864 DPRINTFP((2, DFUNCTION, -1,
"block in one chunk, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
872 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
873 "could not read data (%d bytes) to file (frc=%d sid=%d) ...", (
int) btord, (
int) frc, sion_filedesc->
sid));
878 bytes_to_read -=btord;
882 if(bytes_to_read>0) {
884 if(! _sion_move_to_next_chunk(sion_filedesc)) {
885 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
886 "could not read data (%d bytes) to file (end of file reached, frc=%d sid=%d) ...", (
int) btord, (
int) frc, sion_filedesc->
sid));
893 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
899 #define DFUNCTION "_sion_keyval_dup_dataptr_inline" 905 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
912 keymngr =_sion_keyvalue_keymngr_dup(keymngr_orig,new_filedesc->
dup_mode, new_filedesc->
dup_sel_key);
913 if (keymngr == NULL) {
914 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"dup: could not duplicate keymngr ..."));
924 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.
sion_int32 currentblocknr
int _sion_create_new_block(_sion_filedesc *sion_filedesc)
Create a new block for the internal data structure.
void sion_swap(void *target, void *source, int size, int n, int aflag)