-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [fix] Rework code according to Valgrind's recommendations * Clear code * Avoid PEP's warnings * Update code * Support sync transactions * Rewrite query results wrapper * Properly use NewItem method. Reorganize code * Implement transaction py API * Add transaction py-tests * Update Readme.md * [fix] Fix build pyreindexer with reindexer v.4.15 * Try fix MacOS tests * Correct style * Update tests * Reorganize README * Correct test_item * Update transaction test * Simplify code * Style changes * Add commit_with_count() * Add commit_with_count(). Fix code and check in test * Upgrade version * Fix transaction tests * Fix build * Update transaction tests * Update transaction tests. Fix build * Review changes --------- Co-authored-by: Alexander.A.Utkin <[email protected]>
- Loading branch information
1 parent
7e83f55
commit f7220cf
Showing
20 changed files
with
1,132 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
""" | ||
|
||
from pyreindexer.rx_connector import RxConnector | ||
# from pyreindexer.index_definition import IndexDefinition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#pragma once | ||
|
||
#include "reindexerinterface.h" | ||
|
||
#ifdef PYREINDEXER_CPROTO | ||
#include "client/cororeindexer.h" | ||
#else | ||
#include "core/reindexer.h" | ||
#endif | ||
|
||
namespace pyreindexer { | ||
|
||
#ifdef PYREINDEXER_CPROTO | ||
using DBInterface = ReindexerInterface<reindexer::client::CoroReindexer>; | ||
using TransactionT = reindexer::client::CoroTransaction; | ||
using QueryResultsT = reindexer::client::CoroQueryResults; | ||
using ItemT = reindexer::client::Item; | ||
#else | ||
using DBInterface = ReindexerInterface<reindexer::Reindexer>; | ||
using TransactionT = reindexer::Transaction; | ||
using QueryResultsT = reindexer::QueryResults; | ||
using ItemT = reindexer::Item; | ||
#endif | ||
|
||
class TransactionWrapper { | ||
public: | ||
TransactionWrapper(DBInterface* db) : db_{db} { | ||
assert(db_); | ||
} | ||
|
||
void Wrap(TransactionT&& transaction) { | ||
transaction_ = std::move(transaction); | ||
wrap_ = true; | ||
} | ||
|
||
Error Start(std::string_view ns) { | ||
return db_->StartTransaction(ns, *this); | ||
} | ||
|
||
ItemT NewItem() { | ||
assert(wrap_); | ||
return db_->NewItem(transaction_); | ||
} | ||
|
||
Error Modify(ItemT&& item, ItemModifyMode mode) { | ||
assert(wrap_); | ||
return db_->Modify(transaction_, std::move(item), mode); | ||
} | ||
|
||
Error Commit(size_t& count) { | ||
assert(wrap_); | ||
return db_->CommitTransaction(transaction_, count); | ||
} | ||
|
||
Error Rollback() { | ||
assert(wrap_); | ||
return db_->RollbackTransaction(transaction_); | ||
} | ||
|
||
private: | ||
DBInterface* db_{nullptr}; | ||
TransactionT transaction_; | ||
bool wrap_{false}; | ||
}; | ||
|
||
} // namespace pyreindexer |
Oops, something went wrong.