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_input_files = 0;
18   num_input_files_at_output_level = 0;
19 
20   num_output_records = 0;
21   num_output_files = 0;
22 
23   is_manual_compaction = 0;
24 
25   total_input_bytes = 0;
26   total_output_bytes = 0;
27 
28   num_records_replaced = 0;
29 
30   total_input_raw_key_bytes = 0;
31   total_input_raw_value_bytes = 0;
32 
33   num_input_deletion_records = 0;
34   num_expired_deletion_records = 0;
35 
36   num_corrupt_keys = 0;
37 
38   file_write_nanos = 0;
39   file_range_sync_nanos = 0;
40   file_fsync_nanos = 0;
41   file_prepare_write_nanos = 0;
42 
43   smallest_output_key_prefix.clear();
44   largest_output_key_prefix.clear();
45 
46   num_single_del_fallthru = 0;
47   num_single_del_mismatch = 0;
48 }
49 
Add(const CompactionJobStats & stats)50 void CompactionJobStats::Add(const CompactionJobStats& stats) {
51   elapsed_micros += stats.elapsed_micros;
52   cpu_micros += stats.cpu_micros;
53 
54   num_input_records += stats.num_input_records;
55   num_input_files += stats.num_input_files;
56   num_input_files_at_output_level += stats.num_input_files_at_output_level;
57 
58   num_output_records += stats.num_output_records;
59   num_output_files += stats.num_output_files;
60 
61   total_input_bytes += stats.total_input_bytes;
62   total_output_bytes += stats.total_output_bytes;
63 
64   num_records_replaced += stats.num_records_replaced;
65 
66   total_input_raw_key_bytes += stats.total_input_raw_key_bytes;
67   total_input_raw_value_bytes += stats.total_input_raw_value_bytes;
68 
69   num_input_deletion_records += stats.num_input_deletion_records;
70   num_expired_deletion_records += stats.num_expired_deletion_records;
71 
72   num_corrupt_keys += stats.num_corrupt_keys;
73 
74   file_write_nanos += stats.file_write_nanos;
75   file_range_sync_nanos += stats.file_range_sync_nanos;
76   file_fsync_nanos += stats.file_fsync_nanos;
77   file_prepare_write_nanos += stats.file_prepare_write_nanos;
78 
79   num_single_del_fallthru += stats.num_single_del_fallthru;
80   num_single_del_mismatch += stats.num_single_del_mismatch;
81 }
82 
83 #else
84 
85 void CompactionJobStats::Reset() {}
86 
87 void CompactionJobStats::Add(const CompactionJobStats& /*stats*/) {}
88 
89 #endif  // !ROCKSDB_LITE
90 
91 }  // namespace ROCKSDB_NAMESPACE
92