mirror of https://gitee.com/bigwinds/arangodb
truncate optimization
This commit is contained in:
parent
3e2e14d800
commit
49181147e4
|
@ -354,6 +354,11 @@ void PrimaryIndex::invokeOnAllElements(
|
||||||
_primaryIndex->invokeOnAllElements(work);
|
_primaryIndex->invokeOnAllElements(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrimaryIndex::invokeOnAllElementsForRemoval(
|
||||||
|
std::function<void(TRI_doc_mptr_t*)> work) {
|
||||||
|
_primaryIndex->invokeOnAllElementsForRemoval(work);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief checks whether the index supports the condition
|
/// @brief checks whether the index supports the condition
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -238,6 +238,7 @@ class PrimaryIndex final : public Index {
|
||||||
static uint64_t calculateHash(arangodb::Transaction*, uint8_t const*);
|
static uint64_t calculateHash(arangodb::Transaction*, uint8_t const*);
|
||||||
|
|
||||||
void invokeOnAllElements(std::function<void(TRI_doc_mptr_t*)>);
|
void invokeOnAllElements(std::function<void(TRI_doc_mptr_t*)>);
|
||||||
|
void invokeOnAllElementsForRemoval(std::function<void(TRI_doc_mptr_t*)>);
|
||||||
|
|
||||||
bool supportsFilterCondition(arangodb::aql::AstNode const*,
|
bool supportsFilterCondition(arangodb::aql::AstNode const*,
|
||||||
arangodb::aql::Variable const*, size_t, size_t&,
|
arangodb::aql::Variable const*, size_t, size_t&,
|
||||||
|
|
|
@ -1481,7 +1481,7 @@ OperationResult Transaction::truncateLocal(std::string const& collectionName,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
primaryIndex->invokeOnAllElements(callback);
|
primaryIndex->invokeOnAllElementsForRemoval(callback);
|
||||||
}
|
}
|
||||||
catch (basics::Exception const& ex) {
|
catch (basics::Exception const& ex) {
|
||||||
unlock(trxCollection(cid), TRI_TRANSACTION_WRITE);
|
unlock(trxCollection(cid), TRI_TRANSACTION_WRITE);
|
||||||
|
|
|
@ -844,10 +844,30 @@ class AssocUnique {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief a method to iterate over all elements in the hash. this method
|
/// @brief a method to iterate over all elements in the hash. this method
|
||||||
/// can be used for deleting elements as well
|
/// can NOT be used for deleting elements
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void invokeOnAllElements(CallbackElementFuncType callback) {
|
void invokeOnAllElements(CallbackElementFuncType callback) {
|
||||||
|
for (auto& b : _buckets) {
|
||||||
|
if (b._table == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < b._nrAlloc; ++i) {
|
||||||
|
if (b._table[i] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// don't increment i
|
||||||
|
callback(b._table[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief a method to iterate over all elements in the hash. this method
|
||||||
|
/// can be used for deleting elements as well
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void invokeOnAllElementsForRemoval(CallbackElementFuncType callback) {
|
||||||
for (auto& b : _buckets) {
|
for (auto& b : _buckets) {
|
||||||
if (b._table == nullptr) {
|
if (b._table == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -857,11 +877,15 @@ class AssocUnique {
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// don't increment i
|
// intentionally don't increment i
|
||||||
|
auto old = b._table[i];
|
||||||
callback(b._table[i]);
|
callback(b._table[i]);
|
||||||
if (b._nrUsed == 0) {
|
if (b._nrUsed == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (b._table[i] == old) {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue