From 55bbd38105e9947c5f37706b6fcce701eb5974ed Mon Sep 17 00:00:00 2001 From: liuyihua Date: Thu, 23 May 2024 06:54:10 +0000 Subject: [PATCH] fix format error --- db/c.cc | 101 +++++++++++++++++++++++--------------------- include/rocksdb/c.h | 44 ++++++++++--------- 2 files changed, 76 insertions(+), 69 deletions(-) diff --git a/db/c.cc b/db/c.cc index 57b25cfbd2f..c65229f1f11 100644 --- a/db/c.cc +++ b/db/c.cc @@ -65,10 +65,10 @@ using ROCKSDB_NAMESPACE::ColumnFamilyDescriptor; using ROCKSDB_NAMESPACE::ColumnFamilyHandle; using ROCKSDB_NAMESPACE::ColumnFamilyMetaData; using ROCKSDB_NAMESPACE::ColumnFamilyOptions; +using ROCKSDB_NAMESPACE::CompactRangeOptions; using ROCKSDB_NAMESPACE::CompactionFilter; using ROCKSDB_NAMESPACE::CompactionFilterFactory; using ROCKSDB_NAMESPACE::CompactionOptionsFIFO; -using ROCKSDB_NAMESPACE::CompactRangeOptions; using ROCKSDB_NAMESPACE::Comparator; using ROCKSDB_NAMESPACE::CompressionType; using ROCKSDB_NAMESPACE::ConfigOptions; @@ -90,10 +90,10 @@ using ROCKSDB_NAMESPACE::ImportColumnFamilyOptions; using ROCKSDB_NAMESPACE::InfoLogLevel; using ROCKSDB_NAMESPACE::IngestExternalFileOptions; using ROCKSDB_NAMESPACE::Iterator; +using ROCKSDB_NAMESPACE::LRUCacheOptions; using ROCKSDB_NAMESPACE::LevelMetaData; using ROCKSDB_NAMESPACE::LiveFileMetaData; using ROCKSDB_NAMESPACE::Logger; -using ROCKSDB_NAMESPACE::LRUCacheOptions; using ROCKSDB_NAMESPACE::MemoryAllocator; using ROCKSDB_NAMESPACE::MemoryUtil; using ROCKSDB_NAMESPACE::MergeOperator; @@ -881,9 +881,13 @@ void rocksdb_checkpoint_create(rocksdb_checkpoint_t* checkpoint, std::string(checkpoint_dir), log_size_for_flush)); } -struct rocksdb_export_import_files_metadata_t { ExportImportFilesMetaData* rep; }; +struct rocksdb_export_import_files_metadata_t { + ExportImportFilesMetaData* rep; +}; -struct rocksdb_live_file_metadata { LiveFileMetaData* rep; }; +struct rocksdb_live_file_metadata { + LiveFileMetaData* rep; +}; rocksdb_export_import_files_metadata_t* rocksdb_column_family_export( rocksdb_checkpoint_t* checkpoint, rocksdb_column_family_handle_t* handle, @@ -914,16 +918,15 @@ const char* rocksdb_marshal_export_import_files_metadata( const char hex_digits[] = "0123456789abcdef"; std::string result; - + if (s.empty()) { return result; } result.reserve(s.length() * 2); - for (unsigned char c : s) - { - result.push_back(hex_digits[c >> 4]); - result.push_back(hex_digits[c & 15]); + for (unsigned char c : s) { + result.push_back(hex_digits[c >> 4]); + result.push_back(hex_digits[c & 15]); } return result; }; @@ -974,7 +977,7 @@ const char* rocksdb_marshal_export_import_files_metadata( json.append(",\"num_deletions\":"); json.append(std::to_string(file.num_deletions)); json.append(",\"temperature\":"), - json.append(std::to_string(uint8_t(file.temperature))); + json.append(std::to_string(uint8_t(file.temperature))); json.append(",\"oldest_blob_file_number\":"); json.append(std::to_string(file.oldest_blob_file_number)); json.append(",\"oldest_ancester_time\":"); @@ -1000,9 +1003,10 @@ const char* rocksdb_marshal_export_import_files_metadata( return result; } -rocksdb_export_import_files_metadata_t* rocksdb_new_export_import_files_metadata( - const char* db_comparator_name, rocksdb_live_file_metadata** files, - int file_size, char** errptr) { +rocksdb_export_import_files_metadata_t* +rocksdb_new_export_import_files_metadata(const char* db_comparator_name, + rocksdb_live_file_metadata** files, + int file_size, char** errptr) { std::vector live_files; for (int i = 0; i < file_size; i++) { auto live_file = files[i]->rep; @@ -1021,45 +1025,45 @@ rocksdb_live_file_metadata* rocksdb_new_live_file_metadata( const char* column_family_name, int level, const char* relative_filename, const char* name, uint64_t file_number, int file_type, const char* directory, const char* db_path, int32_t size, - uint64_t smallest_seqno, uint64_t largest_seqno, const char* hex_smallestkey, - const char* hex_largestkey, uint64_t num_reads_sampled, int32_t being_compacted, - uint64_t num_entries, uint64_t num_deletions, uint8_t temperature, + uint64_t smallest_seqno, uint64_t largest_seqno, + const char* hex_smallestkey, const char* hex_largestkey, + uint64_t num_reads_sampled, int32_t being_compacted, uint64_t num_entries, + uint64_t num_deletions, uint8_t temperature, uint64_t oldest_blob_file_number, uint64_t oldest_ancester_time, uint64_t file_creation_time, const char* file_checksum, - const char* file_checksum_func_name, uint64_t epoch_number, + const char* file_checksum_func_name, uint64_t epoch_number, const char* hex_smallest, const char* hex_largest, char** errptr) { auto hex_to_string = [](std::string hex) -> std::string { const signed char hex_values[256] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, + 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, }; const auto len = hex.length(); std::string result; result.reserve(len / 2); - for (auto it = hex.begin(); it != hex.end(); ) { - int hi = hex_values[int(*it++)]; - int lo = hex_values[int(*it++)]; - result.push_back(hi << 4 | lo); + for (auto it = hex.begin(); it != hex.end();) { + int hi = hex_values[int(*it++)]; + int lo = hex_values[int(*it++)]; + result.push_back(hi << 4 | lo); } return result; - }; - + }; + LiveFileMetaData* metadata = new LiveFileMetaData; metadata->column_family_name = std::string(column_family_name); metadata->level = level; @@ -2132,9 +2136,7 @@ unsigned char rocksdb_iter_valid(const rocksdb_iterator_t* iter) { return iter->rep->Valid(); } -void rocksdb_iter_refresh(rocksdb_iterator_t* iter) { - iter->rep->Refresh(); -} +void rocksdb_iter_refresh(rocksdb_iterator_t* iter) { iter->rep->Refresh(); } void rocksdb_iter_seek_to_first(rocksdb_iterator_t* iter) { iter->rep->SeekToFirst(); @@ -5425,7 +5427,8 @@ rocksdb_fifo_compaction_options_t* rocksdb_fifo_compaction_options_create() { } void rocksdb_fifo_compaction_options_set_allow_compaction( - rocksdb_fifo_compaction_options_t* fifo_opts, unsigned char allow_compaction) { + rocksdb_fifo_compaction_options_t* fifo_opts, + unsigned char allow_compaction) { fifo_opts->rep.allow_compaction = allow_compaction; } @@ -6770,7 +6773,8 @@ void rocksdb_enable_manual_compaction(rocksdb_t* db) { db->rep->EnableManualCompaction(); } -char* rocksdb_flush_job_info_cf_name(rocksdb_flush_job_info_t* info, size_t* name_len) { +char* rocksdb_flush_job_info_cf_name(rocksdb_flush_job_info_t* info, + size_t* name_len) { auto name = info->rep.cf_name; *name_len = name.size(); return CopyString(name); @@ -6801,7 +6805,7 @@ void rocksdb_options_add_event_listener(rocksdb_options_t* opt, } void rocksdb_options_set_periodic_compaction_seconds(rocksdb_options_t* opt, - uint64_t n) { + uint64_t n) { opt->rep.periodic_compaction_seconds = n; } @@ -6811,12 +6815,13 @@ rocksdb_sstfilemanager_t* rocksdb_sstfilemanager_create() { return sst_file_manager; } -void rocksdb_sstfilemanager_destroy(rocksdb_sstfilemanager_t* sst_file_manager) { +void rocksdb_sstfilemanager_destroy( + rocksdb_sstfilemanager_t* sst_file_manager) { delete sst_file_manager; } -void rocksdb_options_set_sstfilemanager(rocksdb_options_t* opt, - rocksdb_sstfilemanager_t* sst_file_manager) { +void rocksdb_options_set_sstfilemanager( + rocksdb_options_t* opt, rocksdb_sstfilemanager_t* sst_file_manager) { if (sst_file_manager) { opt->rep.sst_file_manager = sst_file_manager->rep; } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index eb9d593dae7..47a83e51476 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -137,7 +137,8 @@ typedef struct rocksdb_wal_iterator_t rocksdb_wal_iterator_t; typedef struct rocksdb_wal_readoptions_t rocksdb_wal_readoptions_t; typedef struct rocksdb_memory_consumers_t rocksdb_memory_consumers_t; typedef struct rocksdb_memory_usage_t rocksdb_memory_usage_t; -typedef struct rocksdb_export_import_files_metadata_t rocksdb_export_import_files_metadata_t; +typedef struct rocksdb_export_import_files_metadata_t + rocksdb_export_import_files_metadata_t; typedef struct rocksdb_live_file_metadata rocksdb_live_file_metadata; typedef struct rocksdb_flush_job_info_t rocksdb_flush_job_info_t; typedef struct rocksdb_event_listener_t rocksdb_event_listener_t; @@ -369,8 +370,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_checkpoint_create( extern ROCKSDB_LIBRARY_API rocksdb_export_import_files_metadata_t* rocksdb_column_family_export(rocksdb_checkpoint_t* checkpoint, - rocksdb_column_family_handle_t* handle, - const char* export_dir, char** errptr); + rocksdb_column_family_handle_t* handle, + const char* export_dir, char** errptr); extern ROCKSDB_LIBRARY_API void rocksdb_checkpoint_object_destroy( rocksdb_checkpoint_t* checkpoint); @@ -428,7 +429,8 @@ rocksdb_create_column_family_with_import( const char* column_family_name, const rocksdb_export_import_files_metadata_t* metadata, char** errptr); -extern ROCKSDB_LIBRARY_API const char* rocksdb_marshal_export_import_files_metadata( +extern ROCKSDB_LIBRARY_API const char* +rocksdb_marshal_export_import_files_metadata( rocksdb_export_import_files_metadata_t* metadata, char** errptr); extern ROCKSDB_LIBRARY_API rocksdb_export_import_files_metadata_t* @@ -437,19 +439,18 @@ rocksdb_new_export_import_files_metadata(const char* db_comparator_name, int file_size, char** errptr); extern ROCKSDB_LIBRARY_API rocksdb_live_file_metadata* -rocksdb_new_live_file_metadata(const char* column_family_name, int level, - const char* relative_filename, const char* name, - uint64_t file_number, int file_type, - const char* directory, const char* db_path, int32_t size, - uint64_t smallest_seqno, uint64_t largest_seqno, - const char* hex_smallestkey, const char* hex_largestkey, - uint64_t num_reads_sampled, int32_t being_compacted, - uint64_t num_entries, uint64_t num_deletions, - uint8_t temperature, uint64_t oldest_blob_file_number, - uint64_t oldest_ancester_time, uint64_t file_creation_time, - const char* file_checksum, const char* file_checksum_func_name, - uint64_t epoch_number, const char* hex_smallest, const char* hex_largest, - char** errptr); +rocksdb_new_live_file_metadata( + const char* column_family_name, int level, const char* relative_filename, + const char* name, uint64_t file_number, int file_type, + const char* directory, const char* db_path, int32_t size, + uint64_t smallest_seqno, uint64_t largest_seqno, + const char* hex_smallestkey, const char* hex_largestkey, + uint64_t num_reads_sampled, int32_t being_compacted, uint64_t num_entries, + uint64_t num_deletions, uint8_t temperature, + uint64_t oldest_blob_file_number, uint64_t oldest_ancester_time, + uint64_t file_creation_time, const char* file_checksum, + const char* file_checksum_func_name, uint64_t epoch_number, + const char* hex_smallest, const char* hex_largest, char** errptr); extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* rocksdb_create_column_family_with_ttl( @@ -1697,7 +1698,7 @@ extern ROCKSDB_LIBRARY_API void rocksdb_ratelimiter_destroy( /* SstFileManager */ extern ROCKSDB_LIBRARY_API rocksdb_sstfilemanager_t* - rocksdb_sstfilemanager_create(); +rocksdb_sstfilemanager_create(); extern ROCKSDB_LIBRARY_API void rocksdb_sstfilemanager_destroy( rocksdb_sstfilemanager_t* sst_file_manager); @@ -2304,7 +2305,8 @@ extern ROCKSDB_LIBRARY_API rocksdb_fifo_compaction_options_t* rocksdb_fifo_compaction_options_create(void); extern ROCKSDB_LIBRARY_API void rocksdb_fifo_compaction_options_set_allow_compaction( - rocksdb_fifo_compaction_options_t* fifo_opts, unsigned char allow_compaction); + rocksdb_fifo_compaction_options_t* fifo_opts, + unsigned char allow_compaction); extern ROCKSDB_LIBRARY_API unsigned char rocksdb_fifo_compaction_options_get_allow_compaction( rocksdb_fifo_compaction_options_t* fifo_opts); @@ -2908,8 +2910,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_disable_manual_compaction( extern ROCKSDB_LIBRARY_API void rocksdb_enable_manual_compaction(rocksdb_t* db); -extern ROCKSDB_LIBRARY_API void - rocksdb_options_set_periodic_compaction_seconds(rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_periodic_compaction_seconds( + rocksdb_options_t*, uint64_t); #ifdef __cplusplus } /* end extern "C" */