From 4233fa3b475425c256d9d4cbc50618d581ad77df Mon Sep 17 00:00:00 2001 From: rockeet Date: Thu, 12 May 2016 16:13:13 +0800 Subject: [PATCH] Minor fixes --- src/config | 0 src/terark/db/db_context.hpp | 1 + src/terark/db/db_store.hpp | 5 +++++ src/terark/db/db_table.cpp | 12 +++++++++++- src/terark/db/db_table.hpp | 2 ++ .../terark-db/db_bench_terark_index/data/dbmeta.json | 2 +- .../db_bench_terark_index.vcxproj.user | 2 +- vs2015/terark-db/terark-db/terark-db.vcxproj | 4 ++++ vs2015/terark-db/terark-db/terark-db.vcxproj.filters | 12 ++++++++++++ 9 files changed, 37 insertions(+), 3 deletions(-) delete mode 100644 src/config diff --git a/src/config b/src/config deleted file mode 100644 index e69de29..0000000 diff --git a/src/terark/db/db_context.hpp b/src/terark/db/db_context.hpp index 462855f..d12ea03 100644 --- a/src/terark/db/db_context.hpp +++ b/src/terark/db/db_context.hpp @@ -108,6 +108,7 @@ class TERARK_DB_DLL DbContext : public DbContextLink { valvec row2; valvec key1; valvec key2; + valvec userBuf; // TerarkDB will not use userBuf valvec offsets; ColumnVec cols1; ColumnVec cols2; diff --git a/src/terark/db/db_store.hpp b/src/terark/db/db_store.hpp index 6453263..23a87a3 100644 --- a/src/terark/db/db_store.hpp +++ b/src/terark/db/db_store.hpp @@ -173,6 +173,11 @@ class TERARK_DB_DLL CommitException : public DbException { using DbException::DbException; }; +class TERARK_DB_DLL NeedRetryException : public DbException { +public: + using DbException::DbException; +}; + } } // namespace terark::db #endif // __terark_db_db_store_hpp__ diff --git a/src/terark/db/db_table.cpp b/src/terark/db/db_table.cpp index c942c4a..763cf11 100644 --- a/src/terark/db/db_table.cpp +++ b/src/terark/db/db_table.cpp @@ -990,8 +990,18 @@ CompositeTable::insertSyncIndex(llong subId, TransactionGuard& txn, DbContext* c } // dup keys in unique index errors will be ignored +llong CompositeTable::upsertRow(fstring row, DbContext* ctx) { + for (size_t retry = 0; retry < 2; ++retry) { + llong recId = doUpsertRow(row, ctx); + if (recId >= 0) { + return recId; + } + } + TERARK_THROW(NeedRetryException, "Insertion temporary failed, retry later"); +} + llong -CompositeTable::upsertRow(fstring row, DbContext* ctx) { +CompositeTable::doUpsertRow(fstring row, DbContext* ctx) { const SchemaConfig& sconf = *m_schema; if (sconf.m_uniqIndices.size() > 1) { THROW_STD(invalid_argument diff --git a/src/terark/db/db_table.hpp b/src/terark/db/db_table.hpp index 2a1a5b9..2f1d344 100644 --- a/src/terark/db/db_table.hpp +++ b/src/terark/db/db_table.hpp @@ -246,6 +246,8 @@ class TERARK_DB_DLL CompositeTable : public ReadableStore { bool updateWithSyncIndex(llong newSubId, fstring row, DbContext*); void updateSyncMultIndex(llong newSubId, class TransactionGuard&, DbContext*); + llong doUpsertRow(fstring row, DbContext*); + boost::filesystem::path getMergePath(PathRef dir, size_t mergeSeq) const; boost::filesystem::path getSegPath(const char* type, size_t segIdx) const; boost::filesystem::path getSegPath2(PathRef dir, size_t mergeSeq, const char* type, size_t segIdx) const; diff --git a/vs2015/terark-db/db_bench_terark_index/data/dbmeta.json b/vs2015/terark-db/db_bench_terark_index/data/dbmeta.json index 431e64a..caad061 100644 --- a/vs2015/terark-db/db_bench_terark_index/data/dbmeta.json +++ b/vs2015/terark-db/db_bench_terark_index/data/dbmeta.json @@ -7,7 +7,7 @@ }, "CompressingWorkMemSize" : "10K", "MaxWritingSegmentSize": "20K", - "TableClass" : "MockDbTable", + "//TableClass" : "MockDbTable", "TableIndex" : [ { "fields": "key", "ordered" : true, "unique": true } ] diff --git a/vs2015/terark-db/db_bench_terark_index/db_bench_terark_index.vcxproj.user b/vs2015/terark-db/db_bench_terark_index/db_bench_terark_index.vcxproj.user index feab1f8..e419685 100644 --- a/vs2015/terark-db/db_bench_terark_index/db_bench_terark_index.vcxproj.user +++ b/vs2015/terark-db/db_bench_terark_index/db_bench_terark_index.vcxproj.user @@ -5,7 +5,7 @@ WindowsLocalDebugger - --benchmarks=readwhilewriting --value_size=128 --num=1000000 --reads=2000000 --sync_index=1 --threads=4 --db=data --read_ratio=70 + --benchmarks=readwhilewriting --value_size=128 --num=100000 --reads=200000 --sync_index=1 --threads=4 --db=data --read_ratio=70 WindowsLocalDebugger PATH=C:\osc\wiredtiger-2.7.0;C:\osc\tbb\build\vs2010\intel64\Debug-MT; diff --git a/vs2015/terark-db/terark-db/terark-db.vcxproj b/vs2015/terark-db/terark-db/terark-db.vcxproj index 742ebda..bdae457 100644 --- a/vs2015/terark-db/terark-db/terark-db.vcxproj +++ b/vs2015/terark-db/terark-db/terark-db.vcxproj @@ -172,12 +172,14 @@ + + @@ -187,6 +189,7 @@ + @@ -207,6 +210,7 @@ + diff --git a/vs2015/terark-db/terark-db/terark-db.vcxproj.filters b/vs2015/terark-db/terark-db/terark-db.vcxproj.filters index 73147db..99ed7ef 100644 --- a/vs2015/terark-db/terark-db/terark-db.vcxproj.filters +++ b/vs2015/terark-db/terark-db/terark-db.vcxproj.filters @@ -126,6 +126,15 @@ Header Files\terark\db + + Header Files\terark\db + + + Header Files\terark\db + + + Header Files\terark\db + @@ -197,5 +206,8 @@ Source Files\terark\db + + Source Files\terark\db + \ No newline at end of file