mirror of https://gitee.com/bigwinds/arangodb
store documentation
This commit is contained in:
parent
132788a205
commit
9ea023acb1
|
@ -68,7 +68,7 @@ inline std::vector<std::string> split(const std::string& value,
|
|||
}
|
||||
|
||||
|
||||
// Build endpoint from URL
|
||||
/// Build endpoint from URL
|
||||
inline static bool endpointPathFromUrl(
|
||||
std::string const& url, std::string& endpoint, std::string& path) {
|
||||
|
||||
|
@ -103,11 +103,11 @@ inline static bool endpointPathFromUrl(
|
|||
}
|
||||
|
||||
|
||||
// Create with name
|
||||
/// Ctor with name
|
||||
Store::Store(std::string const& name) : Thread(name), _node(name, this) {}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
/// Copy ctor
|
||||
Store::Store(Store const& other) :
|
||||
Thread(other._node.name()), _agent(other._agent), _timeTable(other._timeTable),
|
||||
_observerTable(other._observerTable), _observedTable(other._observedTable),
|
||||
|
@ -122,6 +122,7 @@ Store::Store(Store&& other) :
|
|||
_observedTable(std::move(other._observedTable)),
|
||||
_node(std::move(other._node)) {}
|
||||
|
||||
|
||||
// Copy assignment operator
|
||||
Store& Store::operator=(Store const& rhs) {
|
||||
_agent = rhs._agent;
|
||||
|
@ -132,6 +133,7 @@ Store& Store::operator=(Store const& rhs) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Move assignment operator
|
||||
Store& Store::operator=(Store&& rhs) {
|
||||
_agent = std::move(rhs._agent);
|
||||
|
@ -142,45 +144,55 @@ Store& Store::operator=(Store&& rhs) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Default dtor
|
||||
Store::~Store() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
// Apply queries multiple queries to store
|
||||
std::vector<bool> Store::apply(query_t const& query) {
|
||||
|
||||
std::vector<bool> applied;
|
||||
// Apply array of queries multiple queries to store
|
||||
// Return vector of according success
|
||||
std::vector<bool> Store::apply(query_t const& query, bool verbose) {
|
||||
|
||||
std::vector<bool> success;
|
||||
MUTEX_LOCKER(storeLocker, _storeLock);
|
||||
|
||||
try {
|
||||
|
||||
for (auto const& i : VPackArrayIterator(query->slice())) {
|
||||
|
||||
switch (i.length()) {
|
||||
case 1:
|
||||
applied.push_back(applies(i[0]));
|
||||
break; // no precond
|
||||
case 2:
|
||||
if (check(i[1])) { // precondition
|
||||
applied.push_back(applies(i[0]));
|
||||
case 1: // No precondition
|
||||
success.push_back(applies(i[0]));
|
||||
break;
|
||||
case 2: // precondition
|
||||
if (check(i[1])) {
|
||||
success.push_back(applies(i[0]));
|
||||
} else { // precondition failed
|
||||
LOG_TOPIC(TRACE, Logger::AGENCY) << "Precondition failed!";
|
||||
applied.push_back(false);
|
||||
success.push_back(false);
|
||||
}
|
||||
break;
|
||||
default: // wrong
|
||||
default: // Wrong
|
||||
LOG_TOPIC(ERR, Logger::AGENCY)
|
||||
<< "We can only handle log entry with or without precondition!";
|
||||
applied.push_back(false);
|
||||
success.push_back(false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
_cv.signal();
|
||||
} catch (std::exception const& e) {
|
||||
|
||||
//Wake up TTL processing
|
||||
_cv.signal();
|
||||
|
||||
} catch (std::exception const& e) { // Catch any erorrs
|
||||
LOG_TOPIC(ERR, Logger::AGENCY)
|
||||
<< __FILE__ << ":" << __LINE__ << " " << e.what();
|
||||
}
|
||||
|
||||
return applied;
|
||||
return success;
|
||||
|
||||
}
|
||||
|
||||
// Get name
|
||||
|
@ -294,7 +306,7 @@ std::vector<bool> Store::apply(
|
|||
}
|
||||
|
||||
|
||||
// Check single precondition
|
||||
/// Check precodition object
|
||||
bool Store::check(VPackSlice const& slice) const {
|
||||
|
||||
if (!slice.isObject()) { // Must be object
|
||||
|
|
|
@ -53,7 +53,7 @@ class Store : public arangodb::Thread {
|
|||
Store& operator= (Store&& rhs);
|
||||
|
||||
/// @brief Apply entry in query
|
||||
std::vector<bool> apply(query_t const& query);
|
||||
std::vector<bool> apply(query_t const& query, bool verbose = false);
|
||||
|
||||
/// @brief Apply entry in query
|
||||
std::vector<bool> apply(std::vector<Slice> const& query, bool inform = true);
|
||||
|
|
Loading…
Reference in New Issue