Procházet zdrojové kódy

忽略ttl的存在,使得程序能够顺利运行

pull/1/head
cyq před 1 měsícem
rodič
revize
56fee562a6
6 změnil soubory, kde provedl 24 přidání a 2 odebrání
  1. +13
    -0
      db/db_impl.cc
  2. +2
    -0
      db/db_impl.h
  3. +3
    -0
      db/db_test.cc
  4. +3
    -0
      port/port.h
  5. +1
    -0
      test/db_test2.cc
  6. +2
    -2
      test/ttl_test.cc

+ 13
- 0
db/db_impl.cc Zobrazit soubor

@ -1198,6 +1198,11 @@ Status DBImpl::Put(const WriteOptions& o, const Slice& key, const Slice& val) {
return DB::Put(o, key, val);
}
Status DBImpl::Put(const WriteOptions& options, const Slice& key,
const Slice& value, uint64_t ttl) {
return DB::Put(options,key,value,ttl);
}
Status DBImpl::Delete(const WriteOptions& options, const Slice& key) {
return DB::Delete(options, key);
}
@ -1491,6 +1496,14 @@ Status DB::Put(const WriteOptions& opt, const Slice& key, const Slice& value) {
return Write(opt, &batch);
}
//为了通过编译,忽略ttl
Status DB::Put(const WriteOptions& options, const Slice& key,
const Slice& value, uint64_t ttl) {
WriteBatch batch;
batch.Put(key, value);
return Write(options, &batch);
}
Status DB::Delete(const WriteOptions& opt, const Slice& key) {
WriteBatch batch;
batch.Delete(key);

+ 2
- 0
db/db_impl.h Zobrazit soubor

@ -38,6 +38,8 @@ class DBImpl : public DB {
// Implementations of the DB interface
Status Put(const WriteOptions&, const Slice& key,
const Slice& value) override;
Status Put(const WriteOptions& options, const Slice& key,
const Slice& value, uint64_t ttl) override;
Status Delete(const WriteOptions&, const Slice& key) override;
Status Write(const WriteOptions& options, WriteBatch* updates) override;
Status Get(const ReadOptions& options, const Slice& key,

+ 3
- 0
db/db_test.cc Zobrazit soubor

@ -2117,6 +2117,9 @@ class ModelDB : public DB {
Status Put(const WriteOptions& o, const Slice& k, const Slice& v) override {
return DB::Put(o, k, v);
}
Status Put(const WriteOptions& o, const Slice& k,const Slice& v,uint64_t ttl) {
return DB::Put(o,k,v);
}
Status Delete(const WriteOptions& o, const Slice& key) override {
return DB::Delete(o, key);
}

+ 3
- 0
port/port.h Zobrazit soubor

@ -7,6 +7,9 @@
#include <string.h>
#ifndef LEVELDB_PLATFORM_POSIX
#define LEVELDB_PLATFORM_POSIX
#endif
// Include the appropriate platform specific file below. If you are
// porting to a new platform, see "port_example.h" for documentation
// of what the new port_<platform>.h file must provide.

+ 1
- 0
test/db_test2.cc Zobrazit soubor

@ -68,6 +68,7 @@ int main() {
GetData(db);
delete db;
}
DestroyDB("testdb",Options());
return 0;
}

+ 2
- 2
test/ttl_test.cc Zobrazit soubor

@ -99,9 +99,9 @@ TEST(TestTTL, CompactionTTL) {
db->CompactRange(nullptr, nullptr);
leveldb::Range ranges[1];
// leveldb::Range ranges[1];
ranges[0] = leveldb::Range("-", "A");
uint64_t sizes[1];
// uint64_t sizes[1];
db->GetApproximateSizes(ranges, 1, sizes);
ASSERT_EQ(sizes[0], 0);
}

Načítá se…
Zrušit
Uložit