diff --git a/0001-Allow-leveldbjni-build.patch b/0001-Allow-leveldbjni-build.patch new file mode 100644 index 0000000000000000000000000000000000000000..e7b2f9a503a246a5aed020be372eb0b8c3c80f35 --- /dev/null +++ b/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/0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch b/0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f0d5047b15f59de0237a1fe023c4259bc40eb42 --- /dev/null +++ b/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 761ebf6..da4e160 100644 +--- a/db/db_impl.cc ++++ b/db/db_impl.cc +@@ -136,6 +136,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), +@@ -1455,6 +1458,39 @@ void DBImpl::GetApproximateSizes(const Range* range, int n, uint64_t* sizes) { + } + } + ++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 ae87d6e..6213ccd 100644 +--- a/db/db_impl.h ++++ b/db/db_impl.h +@@ -47,6 +47,8 @@ class DBImpl : public DB { + virtual bool GetProperty(const Slice& property, std::string* value); + virtual void GetApproximateSizes(const Range* range, int n, uint64_t* sizes); + virtual void CompactRange(const Slice* begin, const Slice* end); ++ virtual void SuspendCompactions(); ++ virtual void ResumeCompactions(); + + // Extra methods (for testing) that are not in the public DB interface + +@@ -169,6 +171,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 78296d5..9a9c613 100644 +--- a/db/db_test.cc ++++ b/db/db_test.cc +@@ -2024,6 +2024,8 @@ class ModelDB : public DB { + }; + + explicit ModelDB(const Options& options) : options_(options) {} ++ virtual void SuspendCompactions() {} ++ virtual void ResumeCompactions() {} + ~ModelDB() {} + virtual Status Put(const WriteOptions& o, const Slice& k, const Slice& v) { + return DB::Put(o, k, v); +diff --git a/include/leveldb/db.h b/include/leveldb/db.h +index ea3d9e5..bd039c4 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/0003-allow-Get-calls-to-avoid-copies-into-std-string.patch b/0003-allow-Get-calls-to-avoid-copies-into-std-string.patch new file mode 100644 index 0000000000000000000000000000000000000000..5cf6f975c56f44bd747f535771d29acaa687afde --- /dev/null +++ b/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 761ebf6..16af7e2 100644 +--- a/db/db_impl.cc ++++ b/db/db_impl.cc +@@ -86,6 +86,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) { +@@ -1099,6 +1115,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 ae87d6e..ab96bc7 100644 +--- a/db/db_impl.h ++++ b/db/db_impl.h +@@ -41,6 +41,9 @@ class DBImpl : public DB { + virtual Status Write(const WriteOptions& options, WriteBatch* updates); + virtual Status Get(const ReadOptions& options, const Slice& key, + std::string* value); ++ virtual Status Get(const ReadOptions& options, ++ const Slice& key, ++ Value* value); + virtual Iterator* NewIterator(const ReadOptions&); + virtual const Snapshot* GetSnapshot(); + virtual void ReleaseSnapshot(const Snapshot* snapshot); +diff --git a/db/db_test.cc b/db/db_test.cc +index 78296d5..cc98ea2 100644 +--- a/db/db_test.cc ++++ b/db/db_test.cc +@@ -2036,6 +2036,11 @@ class ModelDB : public DB { + assert(false); // Not implemented + return Status::NotFound(key); + } ++ virtual Status Get(const ReadOptions& options, ++ const Slice& key, Value* value) { ++ assert(false); // Not implemented ++ return Status::NotFound(key); ++ } + virtual Iterator* NewIterator(const ReadOptions& options) { + if (options.snapshot == nullptr) { + KVMap* saved = new KVMap; +diff --git a/db/memtable.cc b/db/memtable.cc +index c91405c..382e15b 100644 +--- a/db/memtable.cc ++++ b/db/memtable.cc +@@ -97,7 +97,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 96a92cc..6037878 100644 +--- a/db/version_set.cc ++++ b/db/version_set.cc +@@ -257,7 +257,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) { +@@ -324,7 +324,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) { + Slice ikey = k.internal_key(); + Slice user_key = k.user_key(); + const Comparator* ucmp = vset_->icmp_.user_comparator(); +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 ea3d9e5..7891b41 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/0004-bloom_test-failure-on-big-endian-archs.patch b/0004-bloom_test-failure-on-big-endian-archs.patch new file mode 100644 index 0000000000000000000000000000000000000000..49cb4cfc596f21e387980f1a7b3185cb3944e4ed --- /dev/null +++ b/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 436daa9..e4edc45 100644 +--- a/util/bloom_test.cc ++++ b/util/bloom_test.cc +@@ -136,7 +136,7 @@ TEST(BloomTest, VaryingLengths) { + fprintf(stderr, "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/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..d5ab942bdd8a1eb635749e0c856f64ff1bbc88d0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2023, NewStart +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/leveldb-1.22.tar.gz b/leveldb-1.22.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..af8a22325cc40620a2249ac8874bf69b9edd0c63 Binary files /dev/null and b/leveldb-1.22.tar.gz differ diff --git a/leveldb.spec b/leveldb.spec new file mode 100644 index 0000000000000000000000000000000000000000..289395283d9dc4e546e224b8ec478c98a890f5a9 --- /dev/null +++ b/leveldb.spec @@ -0,0 +1,198 @@ +Name: leveldb +Version: 1.22 +Release: 1%{?dist} +Summary: A fast and lightweight key/value database library by Google +License: BSD +URL: https://github.com/google/leveldb +Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz + +# available in https://github.com/fusesource/leveldbjni/blob/leveldb.patch +Patch0001: 0001-Allow-leveldbjni-build.patch +# https://github.com/fusesource/leveldbjni/issues/34 +# https://code.google.com/p/leveldb/issues/detail?id=184 +# Add DB::SuspendCompactions() and DB:: ResumeCompactions() methods +Patch0002: 0002-Added-a-DB-SuspendCompations-and-DB-ResumeCompaction.patch +# Cherry-picked from Basho's fork +Patch0003: 0003-allow-Get-calls-to-avoid-copies-into-std-string.patch +# https://groups.google.com/d/topic/leveldb/SbVPvl4j4vU/discussion +Patch0004: 0004-bloom_test-failure-on-big-endian-archs.patch + +BuildRequires: cmake +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: make +BuildRequires: snappy-devel +BuildRequires: sqlite-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: Development files for %{name} +Requires: cmake-filesystem +Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} + +%description devel +%{summary}. + +%prep +%autosetup -p1 + +cat > %{name}.pc << EOF +prefix=%{_prefix} +exec_prefix=${prefix} +libdir=%{_libdir} +includedir=%{_includedir} + +Name: %{name} +Description: %{summary} +Version: %{version} +Libs: -l%{name} +EOF + + +%build +%cmake . +%make_build + + +%install +%make_install + +mkdir -p %{buildroot}%{_libdir}/pkgconfig +cp -a %{name}.pc %{buildroot}%{_libdir}/pkgconfig/ + + +%check +ctest -V %{?_smp_mflags} + + +%ldconfig_scriptlets + + +%files +%license LICENSE +%doc AUTHORS README.md NEWS +%{_libdir}/lib%{name}.so.* + + +%files devel +%doc doc/ CONTRIBUTING.md TODO +%{_includedir}/%{name}/ +%{_libdir}/lib%{name}.so +%{_libdir}/pkgconfig/%{name}.pc +%{_libdir}/cmake/%{name}/ + + +%changelog +* Sun Mar 29 2020 Kefu Chai - 1.22-1 +- Update to 1.22 + +* Wed Jan 29 2020 Fedora Release Engineering - 1.21-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 1.21-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Tue Apr 09 2019 Peter Lemenkov - 1.21-1 +- Update to 1.21 + +* Fri Feb 01 2019 Fedora Release Engineering - 1.20-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jul 13 2018 Fedora Release Engineering - 1.20-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Wed Feb 07 2018 Fedora Release Engineering - 1.20-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Mon Oct 23 2017 Stephen Gallagher - 1.20-1 +- Update to 1.20 +- Disable parallel make invocation to prevent build failures + +* Thu Aug 03 2017 Fedora Release Engineering - 1.18-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.18-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Mon May 15 2017 Fedora Release Engineering - 1.18-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.18-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Sun Aug 07 2016 Igor Gnatenko - 1.18-1 +- Update to 1.18 (RHBZ #1306611) +- Cleanups and fixes in spec + +* Thu Feb 04 2016 Fedora Release Engineering - 1.12.0-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 1.12.0-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Thu May 14 2015 Tomas Hozza - 1.12.0-9 +- rebuild with newer gcc to resolve linking issues with Ceph + +* Sun Mar 1 2015 Mamoru TASAKA - 1.12.0-8 +- F-23: rebuild for gcc5 ABI change + +* Sun Aug 17 2014 Fedora Release Engineering - 1.12.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 1.12.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sun Aug 25 2013 Peter Lemenkov - 1.12.0-5 +- Don't build with assertions + +* Sat Aug 03 2013 Fedora Release Engineering - 1.12.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Jul 10 2013 Peter Lemenkov - 1.12.0-3 +- Backported Basho's patch (see rhbz#982980) + +* Mon Jul 01 2013 gil cattaneo 1.12.0-2 +- add SuspendCompactions and ResumeCompactions methods for allow leveldbjni build + +* Sat Jun 29 2013 gil cattaneo - 1.12.0-1 +- update to 1.12.0 + +* Wed Feb 27 2013 gil cattaneo - 1.9.0-1 +- update to 1.9.0 + +* Thu Feb 14 2013 Fedora Release Engineering - 1.7.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Feb 07 2013 Karsten Hopp 1.7.0-5 +- temporarily ignore result of self checks on PPC* (rhbz #908800) + +* Thu Nov 29 2012 gil cattaneo - 1.7.0-4 +- Applied patch for allow leveldbjni build + +* Sat Oct 27 2012 Peter Lemenkov - 1.7.0-3 +- Dirty workarounds for failed tests on ARM + +* Sat Oct 27 2012 Peter Lemenkov - 1.7.0-2 +- Restored patch no.2 + +* Sat Oct 27 2012 Peter Lemenkov - 1.7.0-1 +- Ver. 1.7.0 (API/ABI compatible bugfix release) + +* Tue Aug 21 2012 Dan HorĂ¡k - 1.5.0-4 +- add workaround for big endians eg. s390(x) + +* Thu Jul 19 2012 Fedora Release Engineering - 1.5.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Wed Jul 11 2012 Peter Lemenkov - 1.5.0-2 +- Cleaned up spec by removing EL5-related stuff +- Added notes about the patches + +* Fri Jun 15 2012 Peter Lemenkov - 1.5.0-1 +- Ver. 1.5.0 + +* Thu May 17 2012 Peter Lemenkov - 1.4.0-1 +- Initial package