summaryrefslogtreecommitdiff
path: root/helpers
Commit message (Collapse)AuthorAgeFilesLines
* Remove main() from most tests.Victor Costan2022-01-031-5/+0
| | | | | | | | | | | | | | | This gives some flexibility to embedders. Currently, embedders have to build a binary for each test file. After this CL, embedders can still choose to have a binary for each test file, by linking each test file with a googletest target that includes main() (usually "gtest_main"). Embedders can also choose to build a single binary for almost all test files, and link with a googletest target that includes main(). The latter is more convenient for projects that have very few test binaries, like Chromium. PiperOrigin-RevId: 419470798
* Add some std:: qualifiers to types and functions.Victor Costan2020-04-291-3/+3
| | | | PiperOrigin-RevId: 309110431
* Switch from C headers to C++ headers.Victor Costan2020-04-291-2/+1
| | | | | | | | | | | | | | | This CL makes the following substitutions. * assert.h -> cassert * math.h -> cmath * stdarg.h -> cstdarg * stddef.h -> cstddef * stdint.h -> cstdint * stdio.h -> cstdio * stdlib.h -> cstdlib * string.h -> cstring PiperOrigin-RevId: 309080151
* Remove Windows workarounds in some tests.Victor Costan2020-01-141-5/+0
| | | | | | | leveldb::Env::DeleteFile was replaced with leveldb::Env::RemoveFile in all tests. This allows us to remove workarounds for windows.h #defining DeleteFile. PiperOrigin-RevId: 289121105
* Add Env::Remove{File,Dir} which obsolete Env::Delete{File,Dir}.Victor Costan2020-01-092-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "DeleteFile" method name causes pain for Windows developers, because <windows.h> #defines a DeleteFile macro to DeleteFileW or DeleteFileA. Current code uses workarounds, like #undefining DeleteFile everywhere an Env is declared, implemented, or used. This CL removes the need for workarounds by renaming Env::DeleteFile to Env::RemoveFile. For consistency, Env::DeleteDir is also renamed to Env::RemoveDir. A few internal methods are also renamed for consistency. Software that supports Windows is expected to migrate any Env implementations and usage to Remove{File,Dir}, and never use the name Env::Delete{File,Dir} in its code. The renaming is done in a backwards-compatible way, at the risk of making it slightly more difficult to build a new correct Env implementation. The backwards compatibility is achieved using the following hacks: 1) Env::Remove{File,Dir} methods are added, with a default implementation that calls into Env::Delete{File,Dir}. This makes old Env implementations compatible with code that calls into the updated API. 2) The Env::Delete{File,Dir} methods are no longer pure virtuals. Instead, they gain a default implementation that calls into Env::Remove{File,Dir}. This makes updated Env implementations compatible with code that calls into the old API. The cost of this approach is that it's possible to write an Env without overriding either Rename{File,Dir} or Delete{File,Dir}, without getting a compiler warning. However, attempting to run the test suite will immediately fail with an infinite call stack ending in {Remove,Delete}{File,Dir}, making developers aware of the problem. PiperOrigin-RevId: 288710907
* Defend against inclusion of windows.h in tests that invokeleveldb Team2020-01-091-0/+5
| | | | | | Env::DeleteFile. PiperOrigin-RevId: 283607548
* Internal change.leveldb Team2019-12-021-1/+1
| | | | PiperOrigin-RevId: 282373286
* Switch testing harness to googletest.Victor Costan2019-11-211-65/+70
| | | | PiperOrigin-RevId: 281815695
* Switch to using C++ 11 override specifier.Chris Mumford2019-05-091-12/+12
| | | | PiperOrigin-RevId: 247491163
* Style cleanup.Victor Costan2019-05-041-27/+26
| | | | | | | | | 1) Convert iterator-based for loops to C++11 foreach loops. 2) Convert "void operator=" to "T& operator=". 3) Switch from copy operators from private to public deleted. 4) Switch from empty ctors / dtors to "= default" where appropriate. PiperOrigin-RevId: 246679195
* Correct class/structure declaration order.Chris Mumford2019-05-032-8/+9
| | | | | | | | | | | | | 1. Correct the class/struct declaration order to be IAW the Google C++ style guide[1]. 2. For non-copyable classes, switched from non-implemented private methods to explicitly deleted[2] methods. 3. Minor const and member initialization fixes. [1] https://google.github.io/styleguide/cppguide.html#Declaration_Order [2] http://eel.is/c++draft/dcl.fct.def.delete PiperOrigin-RevId: 246521844
* Format all files IAW the Google C++ Style Guide.Chris Mumford2019-05-022-56/+32
| | | | | | Use clang-format to correct formatting to be in agreement with the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). Doing this simplifies the process of accepting changes. Also fixed a few warnings flagged by clang-tidy. PiperOrigin-RevId: 246350737
* Always copy bytes to scratch buffer when reading w/MemEnv.cmumford2019-03-201-7/+0
| | | | | | | | | | | | | | | | FileState::Read (used by InMemoryEnv) creates a new Slice when reading. If all the bytes for the read are in the first block then the Slice points to the private block data in FileState and is not copied to the |scratch| buffer. A recent change allows files in InMemEnv to be overwritten which deletes these blocks and in this case can result in a Slice having a dangling pointer. This change fixes this bug by always copying to the |scratch| buffer. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=239301930
* Make InMemoryEnv more consistent with filesystem based Env's.cmumford2019-03-112-16/+53
| | | | | | | | | | | | | | | | | | | | | Env's (like the POSIX Env) which use an actual filesystem behave differently than InMemoryEnv with regards to writing data to a currently open file. InMemoryEnv::NewWritableFile would previously delete that file, if it was open, before creating a new file so any previously open file would be unlinked. This change truncates an open file so that subsequent reads will read that new data. This should have no impact on leveldb as it never has the same file open for both read and write access. This change is only being made for tests (specifically a future change to corruption_test) to allow them to be decoupled from the underlying platform and allow them to use an Env. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237858231
* Replace NULL with nullptr in C++ files.costan2018-04-101-3/+3
| | | | | | ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=192365747
* Replace SIZE_MAX with std::numeric_limits.costan2018-03-201-1/+2
| | | | | | | | | | | | helpers/memenv/memenv.cc used SIZE_MAX without including <stdint.h>. Since we're fixing this problem, replace SIZE_MAX with std::numeric_limits<size_t>::max(), which is clearer. Fixes https://github.com/google/leveldb/issues/562 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=189821707
* Add CMake build support.costan2018-03-161-1/+3
| | | | | | | | Fixes https://github.com/google/leveldb/issues/466 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=189425354
* Extend thread safety annotations.costan2018-03-161-7/+11
| | | | | | | | | | | | | | | | | | | This CL makes it easier to reason about thread safety by: 1) Adding Clang thread safety annotations according to comments. 2) Expanding a couple of variable names, without adding extra lines of code. 3) Adding const in a couple of places. 4) Replacing an always-non-null const pointer with a reference. 5) Fixing style warnings in the modified files. This CL does not annotate the DBImpl members that claim to be protected by the instance mutex, but are accessed without the mutex being held. Those members (and their unprotected accesses) will be addressed in future CLs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=189354657
* LevelDB now attempts to reuse the preceding MANIFEST and log file when ↵Sanjay Ghemawat2015-08-112-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | re-opened. (Based on a suggestion by cmumford.) "open" benchmark on my workstation speeds up significantly since we can now avoid three fdatasync calls and a compaction per open: Before: ~80000 microseconds After: ~130 microseconds Details: (1) Added Options::reuse_logs (currently defaults to false) to control new behavior. The intention is to change the default to true after some baking. (2) Added Env::NewAppendableFile() whose default implementation returns a not-supported error. (3) VersionSet::Recovery attempts to reuse the MANIFEST from which it is recovering. (4) DBImpl recovery attempts to reuse the last log file and memtable. (5) db_test.cc now tests a new configuration that sets reuse_logs to true. (6) fault_injection_test also tests a reuse_logs==true config. (7) Added a new recovery_test.
* Release 1.18v1.18Chris Mumford2014-09-161-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
* Update to leveldb 1.6v1.6David Grogan2012-10-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Highlights ---------- Mmap at most 1000 files on Posix to improve performance for large databases. Support for more architectures (thanks to Alexander K.) Building and porting -------------------- HP/UX support (issue 126) AtomicPointer for ia64 (issue 123) Sparc v9 support (issue 124) Atomic ops for powerpc Use -fno-builtin-memcmp only when using g++ Simplify IOS build rules (issue 114) Use CXXFLAGS instead of CFLAGS when invoking C++ compiler (issue 118) Fix snappy shared library problem (issue 94) Fix shared library installation path regression Endian-ness detection tweak for FreeBSD Bug fixes --------- Stop ignoring FLAGS_open_files in db_bench Make bloom test behavior agnostic to endian-ness Performance ----------- Limit number of mmapped files to 1000 to improve perf for large dbs Do not delay for 1 second on shutdown path (issue 125) Misc ---- Make InMemoryEnv return a no-op logger C binding now has a wrapper for free (issue 117) Add thread-safety annotations Added an in-process lock table (issue 120) Make RandomAccessFile and SequentialFile non-copyable
* A number of fixes:Hans Wennborg2011-10-313-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Replace raw slice comparison with a call to user comparator. Added test for custom comparators. - Fix end of namespace comments. - Fixed bug in picking inputs for a level-0 compaction. When finding overlapping files, the covered range may expand as files are added to the input set. We now correctly expand the range when this happens instead of continuing to use the old range. For example, suppose L0 contains files with the following ranges: F1: a .. d F2: c .. g F3: f .. j and the initial compaction target is F3. We used to search for range f..j which yielded {F2,F3}. However we now expand the range as soon as another file is added. In this case, when F2 is added, we expand the range to c..j and restart the search. That picks up file F1 as well. This change fixes a bug related to deleted keys showing up incorrectly after a compaction as described in Issue 44. (Sync with upstream @25072954)
* Sync with upstream @24213649.Hans Wennborg2011-09-261-1/+1
| | | | | | | | Adding GNU/kFreeBSD support. As requested here: http://code.google.com/p/leveldb/issues/detail?id=38 Use uint64_t instead of size_t in MemEnvTest. As pointed out at http://code.google.com/p/leveldb/issues/detail?id=41
* Sync with upstream @23860137.Hans Wennborg2011-09-123-0/+626
Fix GCC -Wshadow warnings in LevelDB's public header files, reported by Dustin. Add in-memory Env implementation (helpers/memenv/*). This enables users to create LevelDB databases in-memory. Initialize ShardedLRUCache::last_id_ to zero. This fixes a Valgrind warning. (Also delete port/sha1_* which were removed upstream some time ago.)