GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/ingestion/task_compress.cc
Date: 2025-11-23 02:35:30
Exec Total Coverage
Lines: 41 42 97.6%
Branches: 43 72 59.7%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5
6 #include "task_compress.h"
7
8 #include <cstdlib>
9
10 #include "compression/compression.h"
11 #include "util/logging.h"
12 #include "util/smalloc.h"
13
14
15 /**
16 * The data payload of the blocks is replaced by their compressed counterparts.
17 * The block tags stay the same.
18 * TODO(jblomer): avoid memory copy with EchoCompressor
19 */
20 26520555 void TaskCompress::Process(BlockItem *input_block) {
21
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 26508503 times.
26520555 assert(input_block->chunk_item() != NULL);
22
23
1/2
✓ Branch 2 taken 26599629 times.
✗ Branch 3 not taken.
26508503 zlib::Compressor *compressor = input_block->chunk_item()->GetCompressor();
24 26599629 const int64_t tag = input_block->tag();
25 26581965 const bool flush = input_block->type() == BlockItem::kBlockStop;
26 26594523 unsigned char *input_data = input_block->data();
27 26592269 size_t remaining_in_input = input_block->size();
28
29 26602987 BlockItem *output_block = NULL;
30
3/4
✓ Branch 1 taken 26666881 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11493908 times.
✓ Branch 4 taken 15172973 times.
26602987 if (!tag_map_.Lookup(tag, &output_block)) {
31 // So far unseen chunk, start new stream of compressed blocks
32
2/4
✓ Branch 1 taken 11494506 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11468286 times.
✗ Branch 5 not taken.
11493908 output_block = new BlockItem(tag, allocator_);
33
1/2
✓ Branch 2 taken 11461662 times.
✗ Branch 3 not taken.
11468286 output_block->SetFileItem(input_block->file_item());
34
1/2
✓ Branch 2 taken 11466124 times.
✗ Branch 3 not taken.
11461662 output_block->SetChunkItem(input_block->chunk_item());
35
1/2
✓ Branch 1 taken 11513734 times.
✗ Branch 2 not taken.
11466124 output_block->MakeData(kCompressedBlockSize);
36
1/2
✓ Branch 1 taken 11545106 times.
✗ Branch 2 not taken.
11513734 tag_map_.Insert(tag, output_block);
37 }
38
39 26718079 bool done = false;
40 do {
41 29860511 unsigned char *output_data = output_block->data() + output_block->size();
42
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 29812855 times.
29822883 assert(!output_block->IsFull());
43 29812855 size_t remaining_in_output = output_block->capacity()
44 29809313 - output_block->size();
45
46
1/2
✓ Branch 1 taken 29857659 times.
✗ Branch 2 not taken.
29803977 done = compressor->Deflate(flush, &input_data, &remaining_in_input,
47 &output_data, &remaining_in_output);
48 // remaining_in_output is now number of consumed bytes
49 29857659 output_block->set_size(output_block->size() + remaining_in_output);
50
51
2/2
✓ Branch 1 taken 6232116 times.
✓ Branch 2 taken 23582579 times.
29839121 if (output_block->IsFull()) {
52
1/2
✓ Branch 1 taken 6233128 times.
✗ Branch 2 not taken.
6232116 tubes_out_->Dispatch(output_block);
53
2/4
✓ Branch 1 taken 6233450 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6228850 times.
✗ Branch 5 not taken.
6233128 output_block = new BlockItem(tag, allocator_);
54
1/2
✓ Branch 2 taken 6227562 times.
✗ Branch 3 not taken.
6228850 output_block->SetFileItem(input_block->file_item());
55
1/2
✓ Branch 2 taken 6227240 times.
✗ Branch 3 not taken.
6227562 output_block->SetChunkItem(input_block->chunk_item());
56
1/2
✓ Branch 1 taken 6237774 times.
✗ Branch 2 not taken.
6227240 output_block->MakeData(kCompressedBlockSize);
57
1/2
✓ Branch 1 taken 6236486 times.
✗ Branch 2 not taken.
6237774 tag_map_.Insert(tag, output_block);
58 }
59
6/6
✓ Branch 0 taken 3121128 times.
✓ Branch 1 taken 26697937 times.
✓ Branch 2 taken 11515810 times.
✓ Branch 3 taken 15182127 times.
✓ Branch 4 taken 21304 times.
✓ Branch 5 taken 11494506 times.
29819065 } while ((remaining_in_input > 0) || (flush && !done));
60
61
2/2
✓ Branch 0 taken 11492666 times.
✓ Branch 1 taken 15183967 times.
26676633 if (flush) {
62
1/2
✓ Branch 2 taken 11496438 times.
✗ Branch 3 not taken.
11492666 input_block->chunk_item()->ReleaseCompressor();
63
64
1/2
✓ Branch 1 taken 11493836 times.
✗ Branch 2 not taken.
11496438 if (output_block->size() > 0)
65
1/2
✓ Branch 1 taken 11480358 times.
✗ Branch 2 not taken.
11493836 tubes_out_->Dispatch(output_block);
66 else
67 delete output_block;
68
1/2
✓ Branch 1 taken 11470126 times.
✗ Branch 2 not taken.
11480292 tag_map_.Erase(tag);
69
70
2/4
✓ Branch 1 taken 11471966 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11462168 times.
✗ Branch 5 not taken.
11470126 BlockItem *stop_block = new BlockItem(tag, allocator_);
71
1/2
✓ Branch 1 taken 11463134 times.
✗ Branch 2 not taken.
11462168 stop_block->MakeStop();
72
1/2
✓ Branch 2 taken 11462536 times.
✗ Branch 3 not taken.
11463134 stop_block->SetFileItem(input_block->file_item());
73
1/2
✓ Branch 2 taken 11461800 times.
✗ Branch 3 not taken.
11462536 stop_block->SetChunkItem(input_block->chunk_item());
74
1/2
✓ Branch 1 taken 11464422 times.
✗ Branch 2 not taken.
11461800 tubes_out_->Dispatch(stop_block);
75 }
76
77
2/2
✓ Branch 0 taken 26640109 times.
✓ Branch 1 taken 8280 times.
26648389 delete input_block;
78 26698897 }
79