github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/row_counter.h (about) 1 // Copyright 2016 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License included 4 // in the file licenses/BSL.txt and at www.mariadb.com/bsl11. 5 // 6 // Change Date: 2022-10-01 7 // 8 // On the date above, in accordance with the Business Source License, use 9 // of this software will be governed by the Apache License, Version 2.0, 10 // included in the file licenses/APL.txt and at 11 // https://www.apache.org/licenses/LICENSE-2.0 12 13 #pragma once 14 15 #include <libroach.h> 16 #include "db.h" 17 #include "protos/roachpb/api.pb.h" 18 19 // MaxReservedDescID is the maximum value of reserved descriptor IDs. Reserved 20 // IDs are used by namespaces and tables used internally by cockroach. 21 const int MaxReservedDescID = 49; 22 23 // RowCounter counts how many distinct rows appear in the KVs that is is shown 24 // via `Count`. Note: the `DataSize` field of the BulkOpSummary is *not* 25 // populated by this and should be set separately. 26 struct RowCounter { 27 RowCounter(cockroach::roachpb::BulkOpSummary* summary) : summary(summary) {} 28 bool Count(const rocksdb::Slice& key); 29 30 private: 31 void EnsureSafeSplitKey(rocksdb::Slice* key); 32 int GetRowPrefixLength(rocksdb::Slice* key); 33 cockroach::roachpb::BulkOpSummary* summary; 34 std::string prev_key; 35 rocksdb::Slice prev; 36 };