Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdae98db

Browse files
committed
add: compression and decompression of ptrack.map
1 parent168ce31 commitdae98db

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

‎src/data.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
14051405
constchar*errormsg=NULL;
14061406
buffer=slurpFile(to_fullpath,"",&size, false,FIO_DB_HOST);// not sure about to_location
14071407

1408-
size_tdecompressed_size=tmp_file->size*3;// is there a smarter way?
1408+
size_tdecompressed_size=tmp_file->size*2;
14091409
void*decompressed=pg_malloc(decompressed_size);
14101410

14111411
intrc=do_decompress(decompressed,decompressed_size,buffer,size,tmp_backup->compress_alg,&errormsg);

‎src/util.c‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -493,45 +493,47 @@ writePtrackMap(const char *ptrackMap, const size_t ptrackmap_size,
493493
/*
494494
* Copy ptrack.map file to backup. We do apply compression to this file.
495495
*/
496-
void
497-
copy_ptrackmap_file(constchar*from_fullpath,fio_locationfrom_location,
498-
constchar*to_fullpath,fio_locationto_location,pgFile*file)
499-
{
496+
voidcopy_ptrackmap_file(constchar*from_fullpath,fio_locationfrom_location,
497+
constchar*to_fullpath,fio_locationto_location,
498+
pgFile*file) {
500499
char*buffer;
501500
size_tsize;
502501

502+
boolmissing_ok= true;
503+
booluse_crc32c= true;
504+
503505
constchar*errormsg=NULL;
504506

505507
buffer=slurpFile(from_fullpath,"",&size, false,from_location);
506508

507509
size_tcompressed_size=size;
508-
void*compressed=pg_malloc(compressed_size);
509-
510-
intrc=do_compress(compressed,compressed_size,buffer,size,current.compress_alg,current.compress_level,&errormsg);
510+
void*compressed=pg_malloc(compressed_size);
511511

512-
/* Something went wrong and errormsg was assigned, throw a warning */
513-
if (rc<0&&errormsg!=NULL)
514-
elog(WARNING,"An error occured during compressing ptrack.map: %s",errormsg);
512+
intrc=do_compress(compressed,compressed_size,buffer,size,
513+
current.compress_alg,current.compress_level,&errormsg);
515514

516-
/* compression didn`t worked */
517-
if (rc <=0||rc >=size)
518-
{
519-
/* Do not compress ptrack.map */
520-
memcpy(compressed,buffer,size);
521-
}
522-
else {
523-
compressed_size=rc;
524-
}
525-
526-
// file->crc = Ptrack.crc; // how to make it?
527-
file->size=compressed_size;
528-
file->read_size=size;
529-
file->write_size=compressed_size;
530-
file->uncompressed_size=size;
531-
file->compress_alg=current.compress_alg;
515+
/* Something went wrong and errormsg was assigned, throw a warning */
516+
if (rc<0&&errormsg!=NULL)
517+
elog(WARNING,"An error occured during compressing ptrack.map: %s",
518+
errormsg);
519+
520+
/* compression didn`t worked */
521+
if (rc <=0||rc >=size) {
522+
/* Do not compress ptrack.map */
523+
memcpy(compressed,buffer,size);
524+
}else {
525+
compressed_size=rc;
526+
}
532527

533528
writePtrackMap(compressed,compressed_size,to_fullpath,to_location);
534529

530+
file->crc=pgFileGetCRCgz(to_fullpath,use_crc32c,missing_ok);;
531+
file->size=compressed_size;
532+
file->read_size=size;
533+
file->write_size=compressed_size;
534+
file->uncompressed_size=size;
535+
file->compress_alg=current.compress_alg;
536+
535537
pg_free(compressed);
536538
pg_free(buffer);
537539
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp