diff --git a/db/c.cc b/db/c.cc index 98a8f2ce1495..9af39c1d2583 100644 --- a/db/c.cc +++ b/db/c.cc @@ -1939,6 +1939,26 @@ void rocksdb_approximate_sizes_cf( delete[] ranges; } +void rocksdb_approximate_sizes_cf_with_options( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + int num_ranges, const char* const* range_start_key, + const size_t* range_start_key_len, const char* const* range_limit_key, + const size_t* range_limit_key_len, uint64_t* sizes, bool include_memtables, + bool include_files, double files_size_error_margin, char** errptr) { + Range* ranges = new Range[num_ranges]; + for (int i = 0; i < num_ranges; i++) { + ranges[i].start = Slice(range_start_key[i], range_start_key_len[i]); + ranges[i].limit = Slice(range_limit_key[i], range_limit_key_len[i]); + } + Status s = db->rep->GetApproximateSizesWithOptions( + column_family->rep, ranges, num_ranges, sizes, include_memtables, + include_files, files_size_error_margin); + if (!s.ok()) { + SaveError(errptr, s); + } + delete[] ranges; +} + void rocksdb_delete_file(rocksdb_t* db, const char* name) { db->rep->DeleteFile(name); } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index fd552f531a0c..3728c858f494 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -658,6 +658,13 @@ extern ROCKSDB_LIBRARY_API void rocksdb_approximate_sizes_cf( const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_approximate_sizes_cf_with_options( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + int num_ranges, const char* const* range_start_key, + const size_t* range_start_key_len, const char* const* range_limit_key, + const size_t* range_limit_key_len, uint64_t* sizes, bool include_memtables, + bool include_files, double files_size_error_margin, char** errptr); + extern ROCKSDB_LIBRARY_API void rocksdb_compact_range(rocksdb_t* db, const char* start_key, size_t start_key_len, diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index 6539eb8aeb4e..c4159426da1d 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -1310,6 +1310,19 @@ class DB { include_flags); } + virtual Status GetApproximateSizesWithOptions( + ColumnFamilyHandle* column_family, const Range* ranges, int n, + uint64_t* sizes, bool include_memtables, bool include_files, + double files_size_error_margin); + + virtual Status GetApproximateSizesWithOptions( + const Range* ranges, int n, uint64_t* sizes, bool include_memtables, + bool include_files, double files_size_error_margin) { + return GetApproximateSizesWithOptions( + DefaultColumnFamily(), ranges, n, sizes, include_memtables, + include_files, files_size_error_margin); + } + // The method is similar to GetApproximateSizes, except it // returns approximate number of records in memtables. virtual void GetApproximateMemTableStats(ColumnFamilyHandle* column_family, @@ -1929,6 +1942,17 @@ inline Status DB::GetApproximateSizes(ColumnFamilyHandle* column_family, return GetApproximateSizes(options, column_family, ranges, n, sizes); } +inline Status DB::GetApproximateSizesWithOptions( + ColumnFamilyHandle* column_family, const Range* ranges, int n, + uint64_t* sizes, bool include_memtables, bool include_files, + double files_size_error_margin) { + SizeApproximationOptions options; + options.include_memtables = include_memtables; + options.include_files = include_files; + options.files_size_error_margin = files_size_error_margin; + return GetApproximateSizes(options, column_family, ranges, n, sizes); +} + // Destroy the contents of the specified database. // Be very careful using this method. Status DestroyDB(const std::string& name, const Options& options, diff --git a/memory/arena.h b/memory/arena.h index 39399aa71b4f..e8211f5c720f 100644 --- a/memory/arena.h +++ b/memory/arena.h @@ -12,9 +12,15 @@ // size, it uses malloc to directly get the requested size. #pragma once +#ifndef OS_WIN +#include +#endif +#include +#include +#include #include -#include +#include #include "memory/allocator.h" #include "port/mmap.h" @@ -88,7 +94,8 @@ class Arena : public Allocator { static size_t OptimizeBlockSize(size_t block_size); private: - alignas(std::max_align_t) char inline_block_[kInlineSize]; + char inline_block_[kInlineSize] + __attribute__((__aligned__(alignof(max_align_t)))); // Number of bytes allocated in one block const size_t kBlockSize; // Allocated memory blocks