1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 #include "rocksdb/compaction_job_stats.h"
7 
8 namespace ROCKSDB_NAMESPACE {
9 
10 #ifndef ROCKSDB_LITE
11 
Reset()12 void CompactionJobStats::Reset() {
13   elapsed_micros = 0;
14   cpu_micros = 0;
15 
16   num_input_records = 0;
17   num_blobs_read = 0;
18   num_input_files = 0;
19   num_input_files_at_output_level = 0;
20 
21   num_output_records = 0;
22   num_output_files = 0;
23   num_output_files_blob = 0;
24 
25   is_full_compaction = false;
26   is_manual_compaction = false;
27 
28   total_input_bytes = 0;
29   total_blob_bytes_read = 0;
30   total_output_bytes = 0;
31   total_output_bytes_blob = 0;
32 
33   num_records_replaced = 0;
34 
35   total_input_raw_key_bytes = 0;
36   total_input_raw_value_bytes = 0;
37 
38   num_input_deletion_records = 0;
39   num_expired_deletion_records = 0;
40 
41   num_corrupt_keys = 0;
42 
43   file_write_nanos = 0;
44   file_range_sync_nanos = 0;
45   file_fsync_nanos = 0;
46   file_prepare_write_nanos = 0;
47 
48   smallest_output_key_prefix.clear();
49   largest_output_key_prefix.clear();
50 
51   num_single_del_fallthru = 0;
52   num_single_del_mismatch = 0;
53 }
54 
Add(const CompactionJobStats & stats)55 void CompactionJobStats::Add(const CompactionJobStats& stats) {
56   elapsed_micros += stats.elapsed_micros;
57   cpu_micros += stats.cpu_micros;
58 
59   num_input_records += stats.num_input_records;
60   num_blobs_read += stats.num_blobs_read;
61   num_input_files += stats.num_input_files;
62   num_input_files_at_output_level += stats.num_input_files_at_output_level;
63 
64   num_output_records += stats.num_output_records;
65   num_output_files += stats.num_output_files;
66   num_output_files_blob += stats.num_output_files_blob;
67 
68   total_input_bytes += stats.total_input_bytes;
69   total_blob_bytes_read += stats.total_blob_bytes_read;
70   total_output_bytes += stats.total_output_bytes;
71   total_output_bytes_blob += stats.total_output_bytes_blob;
72 
73   num_records_replaced += stats.num_records_replaced;
74 
75   total_input_raw_key_bytes += stats.total_input_raw_key_bytes;
76   total_input_raw_value_bytes += stats.total_input_raw_value_bytes;
77 
78   num_input_deletion_records += stats.num_input_deletion_records;
79   num_expired_deletion_records += stats.num_expired_deletion_records;
80 
81   num_corrupt_keys += stats.num_corrupt_keys;
82 
83   file_write_nanos += stats.file_write_nanos;
84   file_range_sync_nanos += stats.file_range_sync_nanos;
85   file_fsync_nanos += stats.file_fsync_nanos;
86   file_prepare_write_nanos += stats.file_prepare_write_nanos;
87 
88   num_single_del_fallthru += stats.num_single_del_fallthru;
89   num_single_del_mismatch += stats.num_single_del_mismatch;
90 }
91 
92 #else
93 
94 void CompactionJobStats::Reset() {}
95 
96 void CompactionJobStats::Add(const CompactionJobStats& /*stats*/) {}
97 
98 #endif  // !ROCKSDB_LITE
99 
100 }  // namespace ROCKSDB_NAMESPACE
101