.gear/0001-Allow-leveldbjni-build.patch | 17 +++ ...SuspendCompations-and-DB-ResumeCompaction.patch | 118 +++++++++++++++ ...Get-calls-to-avoid-copies-into-std-string.patch | 165 +++++++++++++++++++++ ...04-bloom_test-failure-on-big-endian-archs.patch | 27 ++++ .gear/0006-revert-no-rtti.patch | 15 ++ .gear/libleveldb.spec | 124 ++++++++++++++++ .gear/rules | 4 + .gear/tags/list | 1 + .gear/upstream/remotes | 3 + 9 files changed, 474 insertions(+) diff --git a/.gear/0001-Allow-leveldbjni-build.patch b/.gear/0001-Allow-leveldbjni-build.patch new file mode 100644 index 0000000..e7b2f9a --- /dev/null +++ b/.gear/0001-Allow-leveldbjni-build.patch @@ -0,0 +1,17 @@ +From: Hiram Chirino +Date: Fri, 5 Jul 2013 18:32:28 +0400 +Subject: [PATCH] Allow leveldbjni build + + +diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h +index 2df417d..1af5635 100644 +--- a/include/leveldb/slice.h ++++ b/include/leveldb/slice.h +@@ -86,7 +86,6 @@ class LEVELDB_EXPORT Slice { + return ((size_ >= x.size_) && (memcmp(data_, x.data_, x.size_) == 0)); + } + +- private: + const char* data_; + size_t size_; + }; diff --git a/.gear/0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch b/.gear/0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch new file mode 100644 index 0000000..8823708 --- /dev/null +++ b/.gear/0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch @@ -0,0 +1,118 @@ +From: Hiram Chirino +Date: Tue, 30 Oct 2012 16:56:52 -0400 +Subject: [PATCH] Added a DB:SuspendCompations() and DB:ResumeCompactions() + methods. Fixes issue #184 + +https://code.google.com/p/leveldb/issues/detail?id=184 + +diff --git a/db/db_impl.cc b/db/db_impl.cc +index 1a4e459..ae7b96d 100644 +--- a/db/db_impl.cc ++++ b/db/db_impl.cc +@@ -135,6 +135,9 @@ DBImpl::DBImpl(const Options& raw_options, const std::string& dbname) + table_cache_(new TableCache(dbname_, options_, TableCacheSize(options_))), + db_lock_(nullptr), + shutting_down_(false), ++ suspend_cv(&suspend_mutex), ++ suspend_count(0), ++ suspended(false), + background_work_finished_signal_(&mutex_), + mem_(nullptr), + imm_(nullptr), +@@ -1464,6 +1467,39 @@ void DBImpl::GetApproximateSizes(const Range* range, int n, uint64_t* sizes) { + v->Unref(); + } + ++void DBImpl::SuspendCompactions() { ++ MutexLock l(& suspend_mutex); ++ env_->Schedule(&SuspendWork, this); ++ suspend_count++; ++ while( !suspended ) { ++ suspend_cv.Wait(); ++ } ++} ++void DBImpl::SuspendWork(void* db) { ++ reinterpret_cast(db)->SuspendCallback(); ++} ++void DBImpl::SuspendCallback() { ++ MutexLock l(&suspend_mutex); ++ Log(options_.info_log, "Compactions suspended"); ++ suspended = true; ++ suspend_cv.SignalAll(); ++ while( suspend_count > 0 ) { ++ suspend_cv.Wait(); ++ } ++ suspended = false; ++ suspend_cv.SignalAll(); ++ Log(options_.info_log, "Compactions resumed"); ++} ++void DBImpl::ResumeCompactions() { ++ MutexLock l(&suspend_mutex); ++ suspend_count--; ++ suspend_cv.SignalAll(); ++ while( suspended ) { ++ suspend_cv.Wait(); ++ } ++} ++ ++ + // Default implementations of convenience methods that subclasses of DB + // can call if they wish + Status DB::Put(const WriteOptions& opt, const Slice& key, const Slice& value) { +diff --git a/db/db_impl.h b/db/db_impl.h +index c7b0172..d955c2a 100644 +--- a/db/db_impl.h ++++ b/db/db_impl.h +@@ -48,6 +48,8 @@ class DBImpl : public DB { + bool GetProperty(const Slice& property, std::string* value) override; + void GetApproximateSizes(const Range* range, int n, uint64_t* sizes) override; + void CompactRange(const Slice* begin, const Slice* end) override; ++ void SuspendCompactions() override; ++ void ResumeCompactions() override; + + // Extra methods (for testing) that are not in the public DB interface + +@@ -170,6 +172,13 @@ class DBImpl : public DB { + // Lock over the persistent DB state. Non-null iff successfully acquired. + FileLock* db_lock_; + ++ port::Mutex suspend_mutex; ++ port::CondVar suspend_cv; ++ int suspend_count; ++ bool suspended; ++ static void SuspendWork(void* db); ++ void SuspendCallback(); ++ + // State below is protected by mutex_ + port::Mutex mutex_; + std::atomic shutting_down_; +diff --git a/db/db_test.cc b/db/db_test.cc +index 908b41d..2e65370 100644 +--- a/db/db_test.cc ++++ b/db/db_test.cc +@@ -2051,6 +2051,8 @@ class ModelDB : public DB { + }; + + explicit ModelDB(const Options& options) : options_(options) {} ++ virtual void SuspendCompactions() override {} ++ virtual void ResumeCompactions() override {} + ~ModelDB() override = default; + Status Put(const WriteOptions& o, const Slice& k, const Slice& v) override { + return DB::Put(o, k, v); +diff --git a/include/leveldb/db.h b/include/leveldb/db.h +index a13d147..61c29c0 100644 +--- a/include/leveldb/db.h ++++ b/include/leveldb/db.h +@@ -145,6 +145,12 @@ class LEVELDB_EXPORT DB { + // Therefore the following call will compact the entire database: + // db->CompactRange(nullptr, nullptr); + virtual void CompactRange(const Slice* begin, const Slice* end) = 0; ++ ++ // Suspends the background compaction thread. This methods ++ // returns once suspended. ++ virtual void SuspendCompactions() = 0; ++ // Resumes a suspended background compation thread. ++ virtual void ResumeCompactions() = 0; + }; + + // Destroy the contents of the specified database. diff --git a/.gear/0003-allow-Get-calls-to-avoid-copies-into-std-string.patch b/.gear/0003-allow-Get-calls-to-avoid-copies-into-std-string.patch new file mode 100644 index 0000000..498f81e --- /dev/null +++ b/.gear/0003-allow-Get-calls-to-avoid-copies-into-std-string.patch @@ -0,0 +1,165 @@ +From: Steve Vinoski +Date: Thu, 20 Dec 2012 16:14:11 -0500 +Subject: [PATCH] allow Get() calls to avoid copies into std::string + +Add a new abstract base class leveldb::Value that applications can easily +derive from to supply their own memory management for values retrieved via +Get(). Add an internal class derived from Value that provides std::string +management to preserve backward compatibility. Overload DBImpl::Get() to +accept a Value*, and to preserve backward compatibility also keep the +original version taking a std::string*. + +diff --git a/db/db_impl.cc b/db/db_impl.cc +index ae7b96d..5c3a05c 100644 +--- a/db/db_impl.cc ++++ b/db/db_impl.cc +@@ -85,6 +85,22 @@ struct DBImpl::CompactionState { + uint64_t total_bytes; + }; + ++Value::~Value() {} ++ ++class StringValue : public Value { ++ public: ++ explicit StringValue(std::string& val) : value_(val) {} ++ ~StringValue() {} ++ ++ StringValue& assign(const char* data, size_t size) { ++ value_.assign(data, size); ++ return *this; ++ } ++ ++ private: ++ std::string& value_; ++}; ++ + // Fix user-supplied options to be reasonable + template + static void ClipToRange(T* ptr, V minvalue, V maxvalue) { +@@ -1117,6 +1133,13 @@ int64_t DBImpl::TEST_MaxNextLevelOverlappingBytes() { + + Status DBImpl::Get(const ReadOptions& options, const Slice& key, + std::string* value) { ++ StringValue stringvalue(*value); ++ return DBImpl::Get(options, key, &stringvalue); ++} ++ ++Status DBImpl::Get(const ReadOptions& options, ++ const Slice& key, ++ Value* value) { + Status s; + MutexLock l(&mutex_); + SequenceNumber snapshot; +diff --git a/db/db_impl.h b/db/db_impl.h +index d955c2a..3127110 100644 +--- a/db/db_impl.h ++++ b/db/db_impl.h +@@ -42,6 +42,9 @@ class DBImpl : public DB { + Status Write(const WriteOptions& options, WriteBatch* updates) override; + Status Get(const ReadOptions& options, const Slice& key, + std::string* value) override; ++ virtual Status Get(const ReadOptions& options, ++ const Slice& key, ++ Value* value); + Iterator* NewIterator(const ReadOptions&) override; + const Snapshot* GetSnapshot() override; + void ReleaseSnapshot(const Snapshot* snapshot) override; +diff --git a/db/db_test.cc b/db/db_test.cc +index 2e65370..db778d9 100644 +--- a/db/db_test.cc ++++ b/db/db_test.cc +@@ -2065,6 +2065,11 @@ class ModelDB : public DB { + assert(false); // Not implemented + return Status::NotFound(key); + } ++ Status Get(const ReadOptions& options, ++ const Slice& key, Value* value) override { ++ assert(false); // Not implemented ++ return Status::NotFound(key); ++ } + Iterator* NewIterator(const ReadOptions& options) override { + if (options.snapshot == nullptr) { + KVMap* saved = new KVMap; +diff --git a/db/memtable.cc b/db/memtable.cc +index f42774d..4689e2d 100644 +--- a/db/memtable.cc ++++ b/db/memtable.cc +@@ -98,7 +98,7 @@ void MemTable::Add(SequenceNumber s, ValueType type, const Slice& key, + table_.Insert(buf); + } + +-bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) { ++bool MemTable::Get(const LookupKey& key, Value* value, Status* s) { + Slice memkey = key.memtable_key(); + Table::Iterator iter(&table_); + iter.Seek(memkey.data()); +diff --git a/db/memtable.h b/db/memtable.h +index 9d986b1..85c4cce 100644 +--- a/db/memtable.h ++++ b/db/memtable.h +@@ -60,7 +60,7 @@ class MemTable { + // If memtable contains a deletion for key, store a NotFound() error + // in *status and return true. + // Else, return false. +- bool Get(const LookupKey& key, std::string* value, Status* s); ++ bool Get(const LookupKey& key, Value* value, Status* s); + + private: + friend class MemTableIterator; +diff --git a/db/version_set.cc b/db/version_set.cc +index 1963353..c83a4d2 100644 +--- a/db/version_set.cc ++++ b/db/version_set.cc +@@ -256,7 +256,7 @@ struct Saver { + SaverState state; + const Comparator* ucmp; + Slice user_key; +- std::string* value; ++ Value* value; + }; + } // namespace + static void SaveValue(void* arg, const Slice& ikey, const Slice& v) { +@@ -322,7 +322,7 @@ void Version::ForEachOverlapping(Slice user_key, Slice internal_key, void* arg, + } + + Status Version::Get(const ReadOptions& options, const LookupKey& k, +- std::string* value, GetStats* stats) { ++ Value* value, GetStats* stats) { + stats->seek_file = nullptr; + stats->seek_file_level = -1; + +diff --git a/db/version_set.h b/db/version_set.h +index 69f3d70..0f0a463 100644 +--- a/db/version_set.h ++++ b/db/version_set.h +@@ -72,7 +72,7 @@ class Version { + // REQUIRES: This version has been saved (see VersionSet::SaveTo) + void AddIterators(const ReadOptions&, std::vector* iters); + +- Status Get(const ReadOptions&, const LookupKey& key, std::string* val, ++ Status Get(const ReadOptions&, const LookupKey& key, Value* val, + GetStats* stats); + + // Adds "stats" into the current state. Returns true if a new +diff --git a/include/leveldb/db.h b/include/leveldb/db.h +index 61c29c0..1a93feb 100644 +--- a/include/leveldb/db.h ++++ b/include/leveldb/db.h +@@ -40,6 +40,17 @@ struct LEVELDB_EXPORT Range { + Slice limit; // Not included in the range + }; + ++// Abstract holder for a DB value. ++// This allows callers to manage their own value buffers and have ++// DB values copied directly into those buffers. ++class Value { ++ public: ++ virtual Value& assign(const char* data, size_t size) = 0; ++ ++ protected: ++ virtual ~Value(); ++}; ++ + // A DB is a persistent ordered map from keys to values. + // A DB is safe for concurrent access from multiple threads without + // any external synchronization. diff --git a/.gear/0004-bloom_test-failure-on-big-endian-archs.patch b/.gear/0004-bloom_test-failure-on-big-endian-archs.patch new file mode 100644 index 0000000..cb679b6 --- /dev/null +++ b/.gear/0004-bloom_test-failure-on-big-endian-archs.patch @@ -0,0 +1,27 @@ +From: Yehuda Sadeh +Date: Mon, 2 Jul 2012 14:29:06 -0700 +Subject: [PATCH] bloom_test failure on big endian archs + +When running bloom_test on big endian machines it fails due to unacceptable +false positive rate. I've looked into the issue and it seems that the +reason for that is that it passes a different input than when it runs on +little endian. When transforming the input to be little endian it behaves +as expected. +This issue holds up inclusion of ceph to debian due to ceph's use of +leveldb. The fix can be to bump up the acceptable false positives. + +https://groups.google.com/d/topic/leveldb/SbVPvl4j4vU/discussion + +diff --git a/util/bloom_test.cc b/util/bloom_test.cc +index 520473e..e4053e6 100644 +--- a/util/bloom_test.cc ++++ b/util/bloom_test.cc +@@ -136,7 +136,7 @@ TEST_F(BloomTest, VaryingLengths) { + "False positives: %5.2f%% @ length = %6d ; bytes = %6d\n", + rate * 100.0, length, static_cast(FilterSize())); + } +- ASSERT_LE(rate, 0.02); // Must not be over 2% ++ ASSERT_LE(rate, 0.03); // Must not be over 3% + if (rate > 0.0125) + mediocre_filters++; // Allowed, but not too often + else diff --git a/.gear/0006-revert-no-rtti.patch b/.gear/0006-revert-no-rtti.patch new file mode 100644 index 0000000..d6937ff --- /dev/null +++ b/.gear/0006-revert-no-rtti.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f8285b8..7ab9fe1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -70,10 +70,6 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Disable C++ exceptions. + string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") +- +- # Disable RTTI. +- string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") + endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + # Test whether -Wthread-safety is available. See diff --git a/.gear/libleveldb.spec b/.gear/libleveldb.spec new file mode 100644 index 0000000..e3c49d8 --- /dev/null +++ b/.gear/libleveldb.spec @@ -0,0 +1,124 @@ +Name: libleveldb +Version: 1.23 +Release: alt1 + +Summary: A fast and lightweight key/value database library by Google + +License: BSD +Group: Development/Databases +Url: https://github.com/google/leveldb + +Packager: Alexei Takaseev + +Source: %name-%version.tar +Patch0: %name-%version-%release.patch + +## patches from Fedora +Patch0001: 0001-Allow-leveldbjni-build.patch +Patch0002: 0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch +Patch0003: 0003-allow-Get-calls-to-avoid-copies-into-std-string.patch +Patch0004: 0004-bloom_test-failure-on-big-endian-archs.patch +Patch0006: 0006-revert-no-rtti.patch + +BuildRequires(pre): rpm-macros-cmake +BuildRequires: gcc-c++ +BuildRequires: cmake +BuildRequires: libsnappy-devel +# Can't build ceph with external crc32c libs +#BuildRequires: libcrc32c-devel + +%description +LevelDB is a fast key-value storage library written at Google that provides an +ordered mapping from string keys to string values. + +%package devel +Summary: The development files for %name +Group: Development/Databases +Requires: %name = %version-%release + +%description devel +Additional header files for development with %name. + +%prep +%setup +%autopatch -p1 + +cat > leveldb.pc << EOF +prefix=%prefix +exec_prefix=%prefix +libdir=%_libdir +includedir=%_includedir + +Name: leveldb +Description: %summary +Version: %version +Libs: -lleveldb +EOF + +%build +%cmake \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DLEVELDB_BUILD_TESTS:BOOL=OFF \ + -DLEVELDB_BUILD_BENCHMARKS:BOOL=OFF +%cmake_build + +%install +%cmakeinstall_std + +mkdir -p %buildroot%_pkgconfigdir +cp -a leveldb.pc %buildroot%_pkgconfigdir/ + +%files +%doc AUTHORS LICENSE README.md +%_libdir/%name.so.* + +%files devel +%doc doc +%_includedir/leveldb +%_libdir/%name.so +%_pkgconfigdir/* +%_libdir/cmake/leveldb + +%changelog +* Thu Oct 07 2021 Alexey Shabalin 1.23-alt1 +- 1.23 + +* Tue May 07 2019 Alexei Takaseev 1.22-alt2 +- Fix leveldb.pc file + +* Mon May 06 2019 Alexei Takaseev 1.22-alt1 +- 1.22 +- Remove unneeded patch leveldb-0002-Add-memory-barrier-on-PowerPC.patch +- Re-applay Fedore patches: + * leveldb-0003-bloom_test-failure-on-big-endian-archs.patch + * leveldb-0004-Allow-leveldbjni-build.patch + * leveldb-0005-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch + * leveldb-0006-allow-Get-calls-to-avoid-copies-into-std-string.patch +- Use CMAKE build system + +* Mon Sep 25 2017 Alexei Takaseev 1.20-alt1 +- 1.20 (ALT#33915) + +* Fri Aug 12 2016 Alexei Takaseev 1.19-alt1 +- 1.19 + +* Sat May 28 2016 Alexei Takaseev 1.18-alt1 +- 1.18 + +* Thu Feb 11 2016 Igor Vlasenko 1.17-alt3 +- NMU: added fedora patches for + * leveldbjni support + * arm/ppc support + +* Thu May 28 2015 Alexei Takaseev 1.17-alt2 +- rebuild with gcc-c++ 5.1 + +* Fri May 02 2014 Alexei Takaseev 1.17-alt1 +- 1.17 + +* Tue Mar 04 2014 Alexei Takaseev 1.16-alt1 +- 1.16 + +* Tue Apr 16 2013 Alexei Takaseev 1.9.0-alt1 +- Initial build for Sisyphus diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000..0246f97 --- /dev/null +++ b/.gear/rules @@ -0,0 +1,4 @@ +spec: .gear/libleveldb.spec +copy?: .gear/*.patch +tar: @version@:. +diff: @version@:. . diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 0000000..d9921d3 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +99b3c03b3284f5886f9ef9a4ef703d57373e61be 1.23 diff --git a/.gear/upstream/remotes b/.gear/upstream/remotes new file mode 100644 index 0000000..49b6034 --- /dev/null +++ b/.gear/upstream/remotes @@ -0,0 +1,3 @@ +[remote "upstream"] + url = https://github.com/google/leveldb.git + fetch = +refs/heads/*:refs/remotes/upstream/*