Skip to content

Commit 539db09

Browse files
committed
Case 784 - Upgraded to LevelDB 1.18
1 parent a4b15dc commit 539db09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+455
-298
lines changed

CMakeLists.txt

+6-3
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ include_directories(${Boost_INCLUDE_DIRS}
7070
# /wd4702: unreachable code because of singleton pattern
7171
# /wd4800: bool cast performance warning
7272
IF(MSVC)
73-
SET(LEVELDB_COMPILE_FLAGS "/D_CRT_SECURE_NO_WARNINGS /wd4800 /wd4722 /wd4702")
73+
SET(LEVELDB_COMPILE_FLAGS "/D_CRT_SECURE_NO_WARNINGS /wd4800 /wd4722 /wd4702 /DLEVELDB_ATOMIC_PRESENT")
7474
ELSE(MSVC)
75-
SET(LEVELDB_COMPILE_FLAGS "-Wno-sign-compare")
75+
SET(LEVELDB_COMPILE_FLAGS "-Wno-sign-compare -DLEVELDB_ATOMIC_PRESENT")
7676
ENDIF(MSVC)
7777

7878
SET(LEVEL_DB_FILES
7979
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/c.h
8080
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/cache.h
8181
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/comparator.h
8282
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/db.h
83+
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/dumpfile.h
8384
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/env.h
8485
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/iterator.h
8586
${CMAKE_CURRENT_SOURCE_DIR}/include/leveldb/filter_policy.h
@@ -98,6 +99,7 @@ SET(LEVEL_DB_FILES
9899
${CMAKE_CURRENT_SOURCE_DIR}/db/db_iter.h
99100
${CMAKE_CURRENT_SOURCE_DIR}/db/dbformat.cc
100101
${CMAKE_CURRENT_SOURCE_DIR}/db/dbformat.h
102+
${CMAKE_CURRENT_SOURCE_DIR}/db/dumpfile.cc
101103
${CMAKE_CURRENT_SOURCE_DIR}/db/filename.cc
102104
${CMAKE_CURRENT_SOURCE_DIR}/db/filename.h
103105
${CMAKE_CURRENT_SOURCE_DIR}/db/log_format.h
@@ -265,4 +267,5 @@ LEVELDB_ADD_TEST(write_batch ${CMAKE_CURRENT_SOURCE_DIR}/db/write_batch_test.cc)
265267
LEVELDB_ADD_TEST(db_bench ${CMAKE_CURRENT_SOURCE_DIR}/db/db_bench.cc)
266268
LEVELDB_ADD_TEST(version_set ${CMAKE_CURRENT_SOURCE_DIR}/db/version_set_test.cc)
267269
LEVELDB_ADD_TEST(filter_block ${CMAKE_CURRENT_SOURCE_DIR}/table/filter_block_test.cc)
268-
LEVELDB_ADD_TEST(bloom ${CMAKE_CURRENT_SOURCE_DIR}/util/bloom_test.cc)
270+
LEVELDB_ADD_TEST(bloom ${CMAKE_CURRENT_SOURCE_DIR}/util/bloom_test.cc)
271+
LEVELDB_ADD_TEST(hash ${CMAKE_CURRENT_SOURCE_DIR}/util/hash_test.cc)

Makefile

+20-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
77
# to switch between compilation modes.
88

9-
OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
10-
# OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
11-
# OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
9+
# (A) Production use (optimized mode)
10+
OPT ?= -O2 -DNDEBUG
11+
# (B) Debug mode, w/ full line-level debugging symbols
12+
# OPT ?= -g2
13+
# (C) Profiling mode: opt, but w/debugging symbols
14+
# OPT ?= -O2 -g2 -DNDEBUG
1215
#-----------------------------------------------
1316

1417
# detect what platform we're building on
@@ -29,6 +32,11 @@ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
2932
TESTUTIL = ./util/testutil.o
3033
TESTHARNESS = ./util/testharness.o $(TESTUTIL)
3134

35+
# Note: iOS should probably be using libtool, not ar.
36+
ifeq ($(PLATFORM), IOS)
37+
AR=xcrun ar
38+
endif
39+
3240
TESTS = \
3341
arena_test \
3442
autocompact_test \
@@ -43,6 +51,7 @@ TESTS = \
4351
env_test \
4452
filename_test \
4553
filter_block_test \
54+
hash_test \
4655
issue178_test \
4756
issue200_test \
4857
log_test \
@@ -72,7 +81,7 @@ SHARED = $(SHARED1)
7281
else
7382
# Update db.h if you change these.
7483
SHARED_MAJOR = 1
75-
SHARED_MINOR = 17
84+
SHARED_MINOR = 18
7685
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
7786
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
7887
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
@@ -152,6 +161,9 @@ filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
152161
filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
153162
$(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
154163

164+
hash_test: util/hash_test.o $(LIBOBJECTS) $(TESTHARNESS)
165+
$(CXX) $(LDFLAGS) util/hash_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
166+
155167
issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS)
156168
$(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
157169

@@ -194,17 +206,17 @@ IOSARCH=-arch armv6 -arch armv7 -arch armv7s -arch arm64
194206

195207
.cc.o:
196208
mkdir -p ios-x86/$(dir $@)
197-
$(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
209+
xcrun -sdk iphonesimulator $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
198210
mkdir -p ios-arm/$(dir $@)
199211
xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk $(IOSARCH) -c $< -o ios-arm/$@
200-
lipo ios-x86/$@ ios-arm/$@ -create -output $@
212+
xcrun lipo ios-x86/$@ ios-arm/$@ -create -output $@
201213

202214
.c.o:
203215
mkdir -p ios-x86/$(dir $@)
204-
$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
216+
xcrun -sdk iphonesimulator $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
205217
mkdir -p ios-arm/$(dir $@)
206218
xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk $(IOSARCH) -c $< -o ios-arm/$@
207-
lipo ios-x86/$@ ios-arm/$@ -create -output $@
219+
xcrun lipo ios-x86/$@ ios-arm/$@ -create -output $@
208220

209221
else
210222
.cc.o:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
LevelDB B14 branch
22
==================
33

4-
Current version: 1.17
4+
Current version: 1.18
55

66
Bureau 14 [LevelDB](http://code.google.com/p/leveldb/) branch with full Windows support. This is not an official LevelDB branch, but the branch we use in our product, [quasardb](https://www.quasardb.net/).
77

@@ -11,7 +11,7 @@ Bureau 14 [LevelDB](http://code.google.com/p/leveldb/) branch with full Windows
1111
* The Windows build requires [Boost](http://www.boost.org/);
1212
* Our code is C++11ish and may require a recent compiler;
1313
* Lots of warnings fixed;
14-
* Is not 100% compliant with ugly Google coding style.
14+
* Is not 100% compliant with Google coding style.
1515

1616
Tested on [FreeBSD](http://www.freebsd.org/), Linux and Windows (32-bit & 64-bit).
1717

build_detect_platform

+11-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121
# The PLATFORM_CCFLAGS and PLATFORM_CXXFLAGS might include the following:
2222
#
23-
# -DLEVELDB_CSTDATOMIC_PRESENT if <cstdatomic> is present
23+
# -DLEVELDB_ATOMIC_PRESENT if <atomic> is present
2424
# -DLEVELDB_PLATFORM_POSIX for Posix-based platforms
2525
# -DSNAPPY if the Snappy library is present
2626
#
@@ -72,6 +72,12 @@ if [ "$CXX" = "g++" ]; then
7272
fi
7373

7474
case "$TARGET_OS" in
75+
CYGWIN_*)
76+
PLATFORM=OS_LINUX
77+
COMMON_FLAGS="$MEMCMP_FLAG -lpthread -DOS_LINUX -DCYGWIN"
78+
PLATFORM_LDFLAGS="-lpthread"
79+
PORT_FILE=port/port_posix.cc
80+
;;
7581
Darwin)
7682
PLATFORM=OS_MACOSX
7783
COMMON_FLAGS="$MEMCMP_FLAG -DOS_MACOSX"
@@ -171,13 +177,14 @@ if [ "$CROSS_COMPILE" = "true" ]; then
171177
else
172178
CXXOUTPUT="${TMPDIR}/leveldb_build_detect_platform-cxx.$$"
173179

174-
# If -std=c++0x works, use <cstdatomic>. Otherwise use port_posix.h.
180+
# If -std=c++0x works, use <atomic> as fallback for when memory barriers
181+
# are not available.
175182
$CXX $CXXFLAGS -std=c++0x -x c++ - -o $CXXOUTPUT 2>/dev/null <<EOF
176-
#include <cstdatomic>
183+
#include <atomic>
177184
int main() {}
178185
EOF
179186
if [ "$?" = 0 ]; then
180-
COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT"
187+
COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT"
181188
PLATFORM_CXXFLAGS="-std=c++0x"
182189
else
183190
COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX"

db/autocompact_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ void AutoCompactTest::DoReads(int n) {
8888
delete iter;
8989
// Wait a little bit to allow any triggered compactions to complete.
9090
Env::Default()->SleepForMicroseconds(1000000);
91-
int64_t size = Size(Key(0), Key(n));
91+
uint64_t size = Size(Key(0), Key(n));
9292
fprintf(stderr, "iter %3d => %7.3f MB [other %7.3f MB]\n",
9393
read+1, size/1048576.0, Size(Key(n), Key(kCount))/1048576.0);
94-
if (size <= initial_size/4) { // a factor of 10 is too great
94+
if (size <= static_cast<uint64_t>(initial_size/4)) { // 10 is too much, put it to 4
9595
break;
9696
}
9797
}

db/db_bench.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class Benchmark {
431431
benchmarks = sep + 1;
432432
}
433433

434-
// Reset parameters that may be overriddden bwlow
434+
// Reset parameters that may be overridden below
435435
num_ = FLAGS_num;
436436
reads_ = (FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads);
437437
value_size_ = FLAGS_value_size;
@@ -811,7 +811,6 @@ class Benchmark {
811811

812812
void SeekRandom(ThreadState* thread) {
813813
ReadOptions options;
814-
std::string value;
815814
int found = 0;
816815
for (int i = 0; i < reads_; i++) {
817816
Iterator* iter = db_->NewIterator(options);

db/db_impl.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ Status DBImpl::RecoverLogFile(uint64_t log_number,
392392
reporter.info_log = options_.info_log;
393393
reporter.fname = fname.c_str();
394394
reporter.status = (options_.paranoid_checks ? &status : NULL);
395-
// We intentially make log::Reader do checksumming even if
395+
// We intentionally make log::Reader do checksumming even if
396396
// paranoid_checks==false so that corruptions cause entire commits
397397
// to be skipped instead of propagating bad information (like overly
398398
// large sequence numbers).
@@ -1275,7 +1275,7 @@ WriteBatch* DBImpl::BuildBatchGroup(Writer** last_writer) {
12751275
break;
12761276
}
12771277

1278-
// Append to *reuslt
1278+
// Append to *result
12791279
if (result == first->batch) {
12801280
// Switch to temporary batch instead of disturbing caller's batch
12811281
result = tmp_batch_;

db/db_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ TEST(DBTest, GetEncountersEmptyLevel) {
626626
// * sstable B in level 2
627627
// Then do enough Get() calls to arrange for an automatic compaction
628628
// of sstable A. A bug would cause the compaction to be marked as
629-
// occuring at level 1 (instead of the correct level 0).
629+
// occurring at level 1 (instead of the correct level 0).
630630

631631
// Step 1: First place sstables in levels 0 and 2
632632
int compaction_count = 0;

db/dbformat.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file. See the AUTHORS file for names of contributors.
44

5-
#ifndef STORAGE_LEVELDB_DB_FORMAT_H_
6-
#define STORAGE_LEVELDB_DB_FORMAT_H_
5+
#ifndef STORAGE_LEVELDB_DB_DBFORMAT_H_
6+
#define STORAGE_LEVELDB_DB_DBFORMAT_H_
77

88
#include <stdio.h>
99
#include "leveldb/comparator.h"
@@ -227,4 +227,4 @@ inline LookupKey::~LookupKey() {
227227

228228
} // namespace leveldb
229229

230-
#endif // STORAGE_LEVELDB_DB_FORMAT_H_
230+
#endif // STORAGE_LEVELDB_DB_DBFORMAT_H_

0 commit comments

Comments
 (0)