20 #include <sys/types.h> 40 #define TABLE_SIZE 127 42 #define SEARCH_TO_KEY 0 43 #define SEARCH_TO_NEXT 1 44 #define SEARCH_TO_END 2 49 int _sion_scan_forward_to_key(
_sion_filedesc *sion_filedesc, uint64_t key,
int search_mode);
51 size_t _sion_write_data_to_chunks_inline(
_sion_filedesc *sion_filedesc,
const void *data, sion_int64 bytes_to_write);
52 sion_int64 _sion_compute_next_position_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read);
53 size_t _sion_skip_data_from_chunks_inline(
_sion_filedesc *sion_filedesc, sion_int64 bytes_to_read);
54 size_t _sion_read_data_from_chunks_inline(
_sion_filedesc *sion_filedesc,
void *data, sion_int64 bytes_to_read);
63 #define DFUNCTION "_sion_store_and_write_key_and_len_inline" 64 size_t _sion_store_and_write_key_and_len_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
size_t len) {
65 sion_int64 bytes_to_write;
67 size_t rc=SION_SUCCESS, frc;
70 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
75 buffer[0]=(sion_int64) key;
76 buffer[1]=(sion_int64) len;
77 bytes_to_write=2*
sizeof(sion_int64);
79 frc=_sion_write_data_to_chunks_inline(sion_filedesc, (
const void *) buffer, (sion_int64) bytes_to_write);
82 if(frc != bytes_to_write) {
83 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
84 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) bytes_to_write, (
int) frc, sion_filedesc->
sid));
87 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
92 #define DFUNCTION "_sion_write_value_inline" 93 size_t _sion_write_value_inline(
_sion_filedesc *sion_filedesc,
const void *data, uint64_t key,
size_t len) {
95 sion_int64 bytes_to_write;
96 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
100 frc=_sion_write_data_to_chunks_inline(sion_filedesc, data, (sion_int64) bytes_to_write);
101 if(frc != bytes_to_write) {
102 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
103 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) bytes_to_write, (
int) frc, sion_filedesc->
sid));
106 rc=(size_t) bytes_to_write;
108 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
118 #define DFUNCTION "_sion_find_and_read_key_and_len_inline" 119 int _sion_find_and_read_key_and_len_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
size_t len,
size_t *datalen) {
121 int rc = SION_SUCCESS;
122 int position_found=0;
123 sion_table_key_t mkey;
124 size_t key_current_pos = (size_t) -1, key_bytes_left = (
size_t) -1;
126 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
129 keymngr=_sion_get_or_init_key_info(sion_filedesc);
140 rc=_sion_keyvalue_keymngr_lookup(keymngr, mkey, &key_current_pos, &key_bytes_left);
141 if(rc!=SION_SUCCESS) {
142 DPRINTFP((2, DFUNCTION, -1,
"key %ld is not found in keymngr, scan forward\n", (
long)mkey));
145 rc=_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_KEY);
148 if(rc==SION_SUCCESS) {
149 DPRINTFP((2, DFUNCTION, -1,
"scan forward found key %ld, get info \n", (
long)mkey));
150 rc=_sion_keyvalue_keymngr_lookup(keymngr, mkey, &key_current_pos, &key_bytes_left);
151 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 ));
154 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 ));
156 if(rc==SION_SUCCESS) {
159 if(len<=key_bytes_left) {
163 *datalen=key_bytes_left;
168 DPRINTFP((2, DFUNCTION, -1,
"no more data for key %ld\n", (
long)mkey ));
172 DPRINTFP((2, DFUNCTION, -1,
"check position: current_pos %ld, key_current_pos=%ld len=%ld key_bytes_left=%ld\n",
173 (
long) sion_filedesc->
currentpos, (
long) key_current_pos, (
long) len, (
long) key_bytes_left ));
175 if(key_current_pos!=sion_filedesc->
currentpos) {
176 rc=_sion_move_to_pos(sion_filedesc, key_current_pos);
181 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n", rc));
186 #define DFUNCTION "_sion_read_value_inline" 187 size_t _sion_read_value_inline(
_sion_filedesc *sion_filedesc,
void *data, uint64_t key,
size_t len) {
190 sion_table_key_t mkey;
192 sion_int64 bytes_to_read;
195 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
198 keymngr=_sion_get_or_init_key_info(sion_filedesc);
199 mkey = (sion_table_key_t) key;
208 bread=_sion_read_data_from_chunks_inline(sion_filedesc, (
void *) out, (sion_int64) bytes_to_read);
209 if (bread != bytes_to_read) {
210 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
211 "could not read data (%d bytes) from file ...", (
int) bytes_to_read));
214 DPRINTFP((2, DFUNCTION, -1,
"first value = %3hhu | %c\n", out[0], out[0]));
217 _sion_keyvalue_keymngr_update_read_pos(keymngr, mkey, (
size_t) bread, (sion_int64) sion_filedesc->
currentpos);
221 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",(
int) rc));
227 #define DFUNCTION "_sion_key_full_scan_inline" 229 int rc=SION_NOT_SUCCESS;
231 sion_table_key_t key=0;
233 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
236 keymngr=_sion_get_or_init_key_info(sion_filedesc);
238 if(!_sion_keyvalue_keymngr_is_scan_done(keymngr)) {
239 rc=_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_END);
245 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
251 #define DFUNCTION "_sion_iterator_reset_inline" 256 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
259 keymngr=_sion_get_or_init_key_info(sion_filedesc);
261 rc=_sion_keyvalue_keymngr_iterator_reset(keymngr);
263 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
268 #define DFUNCTION "_sion_iterator_next_inline" 269 int _sion_iterator_next_inline(
_sion_filedesc *sion_filedesc, uint64_t *keyptr,
size_t *sizeptr) {
270 int rc=SION_NOT_SUCCESS;
272 sion_table_key_t key=0;
273 size_t current_pos, offset, len;
275 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
278 keymngr=_sion_get_or_init_key_info(sion_filedesc);
280 if(_sion_keyvalue_keymngr_iterator_next(keymngr, &key, ¤t_pos, &offset, &len)==SION_SUCCESS) {
285 if (_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_NEXT)==SION_SUCCESS) {
287 if(_sion_keyvalue_keymngr_iterator_next(keymngr, &key, ¤t_pos, &offset, &len)==SION_SUCCESS) {
290 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN, sion_filedesc->
rank,
291 "internal error: block could not be find at end of block list ..."));
300 if(rc==SION_SUCCESS) {
301 *keyptr = (uint64_t) key;
302 *sizeptr = (size_t) len;
305 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
310 #define DFUNCTION "_sion_seek_key_inline" 311 int _sion_seek_key_inline(
_sion_filedesc *sion_filedesc, uint64_t key,
int blocknum, sion_int64 posinblock) {
312 int rc=SION_NOT_SUCCESS;
316 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
319 keymngr=_sion_get_or_init_key_info(sion_filedesc);
322 rc=_sion_keyvalue_keymngr_lookup_and_set_pos(keymngr, key, blocknum, posinblock, &offset, &len);
323 DPRINTFP((2, DFUNCTION, -1,
"after first lookup rc=%d offset=%d len=%d\n",rc, (
int)offset, (
int) len ));
325 while( (rc!=SION_SUCCESS) && !_sion_keyvalue_keymngr_is_scan_done(keymngr) ) {
328 DPRINTFP((2, DFUNCTION, -1,
"scan forward to find key %d\n",(
int) key));
329 if (_sion_scan_forward_to_key(sion_filedesc, key, SEARCH_TO_NEXT)==SION_SUCCESS) {
332 rc=_sion_keyvalue_keymngr_lookup_and_set_pos(keymngr, key, blocknum, posinblock, &offset, &len);
333 DPRINTFP((2, DFUNCTION, -1,
"in loop lookup rc=%d offset=%d len=%d\n",rc, (
int)offset, (
int) len ));
340 if( rc==SION_SUCCESS ) {
341 DPRINTFP((2, DFUNCTION, -1,
"move from %ld to new scanpos (%ld) \n",(
long) sion_filedesc->
currentpos,(
long) offset));
342 rc=_sion_move_to_pos(sion_filedesc, offset);
345 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
350 #define DFUNCTION "_sion_key_list_iterator_reset_inline" 351 int _sion_key_list_iterator_reset_inline(
_sion_filedesc *sion_filedesc) {
355 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
358 keymngr=_sion_get_or_init_key_info(sion_filedesc);
360 rc=_sion_keyvalue_keymngr_key_list_iterator_reset(keymngr);
362 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
367 #define DFUNCTION "_sion_iterator_next_inline" 368 int _sion_key_list_iterator_next_inline(
_sion_filedesc *sion_filedesc, uint64_t *keyptr) {
369 int rc=SION_NOT_SUCCESS;
371 sion_table_key_t key=0;
373 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
376 keymngr=_sion_get_or_init_key_info(sion_filedesc);
378 if(_sion_keyvalue_keymngr_key_list_iterator_next(keymngr, &key)==SION_SUCCESS) {
379 *keyptr = (uint64_t) key;
386 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d key=%ld\n",rc,(
long) key));
392 #define DFUNCTION "_sion_key_get_stat_inline" 394 int rc=SION_NOT_SUCCESS;
396 sion_table_key_t key=0;
398 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
401 keymngr=_sion_get_or_init_key_info(sion_filedesc);
403 key= (sion_table_key_t) searchkey;
405 if(_sion_keyvalue_keymngr_key_get_stat(keymngr, key, keystat)==SION_SUCCESS) {
411 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d key=%ld\n",rc,(
long) key));
420 #define DFUNCTION "_sion_scan_forward_to_key" 421 int _sion_scan_forward_to_key(
_sion_filedesc *sion_filedesc, uint64_t key,
int search_mode) {
422 int rc = SION_SUCCESS;
424 sion_table_key_t mkey;
428 size_t bytes_left, lastposinblock, lastposinfile;
429 uint64_t key_and_len[2];
431 size_t bread, bskip, len;
433 DPRINTFP((2, DFUNCTION, -1,
"enter key=%ld\n",(
long) key));
441 if(_sion_keyvalue_keymngr_get_next_scan_pos(keymngr, &scanpos) != SION_SUCCESS) {
444 DPRINTFP((2, DFUNCTION, -1,
"set scanpos to first pos in file pos=%ld\n",(
long) scanpos));
450 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 ));
451 if(scanpos>=lastposinfile) {
452 DPRINTFP((2, DFUNCTION, -1,
"scan is already at end of file (%ld>=%ld) \n",(
long) scanpos, (
long) lastposinfile));
453 _sion_keyvalue_keymngr_set_scan_done(keymngr);
458 if( (sion_filedesc->
currentpos != scanpos) && (!_sion_keyvalue_keymngr_is_scan_done(keymngr)) ) {
459 DPRINTFP((2, DFUNCTION, -1,
"move from %ld to new scanpos (%ld) \n",(
long) sion_filedesc->
currentpos,(
long) scanpos));
460 rc=_sion_move_to_pos(sion_filedesc, scanpos);
464 while ( (!_sion_keyvalue_keymngr_is_scan_done(keymngr)) && (!key_found) ) {
468 bytes_left = lastposinblock - sion_filedesc->
currentpos;
469 DPRINTFP((2, DFUNCTION, -1,
"search loop: lastposinblock=%ld bytes_left=%ld currentpos=%ld\n",(
long) lastposinblock,(
long) bytes_left,(
long) sion_filedesc->
currentpos));
473 if ( bytes_left > 0 ) {
475 bread=_sion_read_data_from_chunks_inline(sion_filedesc, (
void *) key_and_len, (sion_int64)
sizeof(key_and_len));
476 if (bread !=
sizeof(key_and_len)) {
477 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
478 "could not read data (%d bytes) from file ...", (
int)
sizeof(key_and_len)));
483 DPRINTFP((2, DFUNCTION, -1,
"search loop: found next key,len (%ld,%ld)\n",(
long) key_and_len[0],(
long) key_and_len[1]));
486 DPRINTFP((2, DFUNCTION, -1,
"search loop: position is now %ld bytes_left=%ld\n",(
long) sion_filedesc->
currentpos, (
long) bytes_left));
490 DPRINTFP((2, DFUNCTION, -1,
"search loop: data starts in next chunk, moving forward\n"));
491 if(! _sion_move_to_next_chunk(sion_filedesc)) {
492 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
493 "could not move to data section in next block ..."));
497 bytes_left = lastposinblock - sion_filedesc->
currentpos;
498 DPRINTFP((2, DFUNCTION, -1,
"search loop: position is moved to %ld bytes_left=%ld\n",(
long) sion_filedesc->
currentpos, (
long) bytes_left));
504 rc=_sion_keyvalue_keymngr_add_block(keymngr, mkey, (
size_t) sion_filedesc->
currentpos, len);
505 DPRINTFP((2, DFUNCTION, -1,
"search loop: stored new block key=%ld pos=%ld len=%ld\n",(
long) mkey, (
long) sion_filedesc->
currentpos, (
long) len));
509 ( ( (search_mode==SEARCH_TO_KEY) && (key_and_len[0] == key) ) || (search_mode==SEARCH_TO_NEXT) )
510 && ( !(search_mode==SEARCH_TO_END) )
512 DPRINTFP((2, DFUNCTION, -1,
"search loop: found searched key=%ld, leaving\n",(
long) key));
515 scanpos=_sion_compute_next_position_inline(sion_filedesc, len);
517 DPRINTFP((2, DFUNCTION, -1,
"search loop: found another key=%ld <=> %ld, continue\n",(
long) key_and_len[0], (
long) key));
520 DPRINTFP((2, DFUNCTION, -1,
"search loop: found move position forward by %ld bytes\n",(
long) len));
521 bskip=_sion_skip_data_from_chunks_inline(sion_filedesc, (sion_int64) len);
523 if ( bskip == len ) {
528 bytes_left = lastposinblock - sion_filedesc->
currentpos;
532 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
533 "could not skip data section of one block (%d bytes) from file ...", (
int) len));
538 DPRINTFP((2, DFUNCTION, -1,
"search loop: chunk empty, move to next chunk\n"));
539 if(! _sion_move_to_next_chunk(sion_filedesc)) {
540 _sion_keyvalue_keymngr_set_scan_done(keymngr);
541 if(search_mode!=SEARCH_TO_END) {
553 if(! _sion_move_to_next_chunk(sion_filedesc)) {
554 _sion_keyvalue_keymngr_set_scan_done(keymngr);
558 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
559 "unknown data at end of chunk (%d bytes) ...", (
int) bytes_left));
566 if(_sion_keyvalue_keymngr_set_next_scan_pos(keymngr, scanpos) != SION_SUCCESS) {
567 return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->
rank,
568 "internal error set seekpos ..."));
571 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
577 #define DFUNCTION "_sion_get_or_init_key_info" 582 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
585 DPRINTFP((2, DFUNCTION, -1,
"sion_filedesc->keyvalptr == NULL\n"));
586 keymngr =_sion_keyvalue_keymngr_init(TABLE_SIZE);
587 if (keymngr == NULL) {
588 _sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
"could not allocate keymngr ...");
591 DPRINTFP((2, DFUNCTION, -1,
"alloc now KEYVALPTR = %x\n",sion_filedesc->
keyvalptr));
594 DPRINTFP((2, DFUNCTION, -1,
"leave\n"));
599 #define DFUNCTION "_sion_move_to_next_chunk" 601 int rc = SION_SUCCESS;
603 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
616 DPRINTFP((2, DFUNCTION, -1,
"leave, rc = %d\n", rc));
621 #define DFUNCTION "_sion_move_to_pos" 622 int _sion_move_to_pos(
_sion_filedesc *sion_filedesc,
size_t pos) {
623 int rc = SION_SUCCESS;
624 size_t block_min_pos, block_max_pos;
627 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
632 DPRINTFP((2, DFUNCTION, -1,
"current_chunk: %ld to %ld (pos=%ld)\n", (
long) block_min_pos, (
long) block_max_pos, (
long) pos));
634 if ( (pos>=block_min_pos) && (pos<block_max_pos) ) {
640 DPRINTFP((2, DFUNCTION, -1,
"stay in current chunk: currentpos=%ld\n", (
long) sion_filedesc->
currentpos));
647 block_max_pos = block_min_pos+sion_filedesc->
blocksizes[c];
649 DPRINTFP((2, DFUNCTION, -1,
"check chunk%2d: %ld to %ld (pos=%ld)\n", c, (
long) block_min_pos, (
long) block_max_pos, (
long) pos));
651 if ( (pos>=block_min_pos) && (pos<block_max_pos) ) {
659 DPRINTFP((2, DFUNCTION, -1,
"stay in this chunk: currentpos=%ld\n", (
long) sion_filedesc->
currentpos));
670 DPRINTFP((2, DFUNCTION, -1,
"leave, rc = %d\n", rc));
676 #define DFUNCTION "_sion_write_data_to_chunks_inline" 677 size_t _sion_write_data_to_chunks_inline(
_sion_filedesc *sion_filedesc,
const void *data, sion_int64 bytes_to_write) {
678 sion_int64 btowr, byteswritten, offset;
682 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
686 while(bytes_to_write>0) {
692 btowr=bytes_to_write;
693 if ((byteswritten + btowr) > sion_filedesc->
chunksize) btowr = sion_filedesc->
chunksize - byteswritten;
694 DPRINTFP((2, DFUNCTION, -1,
" bytes_to_write=%ld btowr=%ld chunksize=%ld byteswritten=%ld currentblocknr=%d blsize[%d]=%ld\n",
695 (
long) bytes_to_write, (
long) btowr, (
long) sion_filedesc->
chunksize, (
long) byteswritten, (
int) sion_filedesc->
currentblocknr,
703 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
704 "could not write data (%d bytes) to file (frc=%d sid=%d) ...", (
int) btowr, (
int) frc, sion_filedesc->
sid));
709 byteswritten +=btowr;
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, bytesread, offset;
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 ));
817 bytes_to_read -=btord;
821 if(bytes_to_read>0) {
823 if(! _sion_move_to_next_chunk(sion_filedesc)) {
824 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
825 "could not read data (%d bytes) to file (end of file reached sid=%d) ...", (
int) btord, sion_filedesc->
sid));
836 DPRINTFP((2, DFUNCTION, -1,
"leave rc=%d\n",rc));
842 #define DFUNCTION "_sion_read_data_from_chunks_inline" 843 size_t _sion_read_data_from_chunks_inline(
_sion_filedesc *sion_filedesc,
void *data, sion_int64 bytes_to_read) {
844 sion_int64 btord, bytesread, offset;
848 DPRINTFP((2, DFUNCTION, -1,
"enter\n"));
852 while(bytes_to_read>0) {
856 DPRINTFP((2, DFUNCTION, -1,
"bytesread=%ld, curpos=%ld,startpos=%ld,curblock=%ld,gskip=%ld\n",
863 DPRINTFP((2, DFUNCTION, -1,
"block is split to multiple chunks, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
865 DPRINTFP((2, DFUNCTION, -1,
"block in one chunk, bytes_to_read=%ld btord=%ld\n",(
long) bytes_to_read, (
long) btord ));
873 return(_sion_errorprint_on_rank(-1,_SION_ERROR_RETURN,sion_filedesc->
rank,
874 "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.
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)