mirror of https://gitee.com/bigwinds/arangodb
entirely removed TRI_document_collection_t
This commit is contained in:
parent
80f1a7aaee
commit
d92f15aeed
|
@ -30,8 +30,8 @@
|
|||
#define BOOST_TEST_INCLUDED
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "arangod/VocBase/collection.h"
|
||||
#include "arangod/VocBase/datafile.h"
|
||||
#include "arangod/VocBase/document-collection.h"
|
||||
#include "arangod/Wal/Marker.h"
|
||||
|
||||
template<typename T, typename U> size_t offsetOf (U T::*member) {
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "Utils/AqlTransaction.h"
|
||||
#include "V8/v8-conv.h"
|
||||
#include "V8/v8-vpack.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
|
||||
#include <velocypack/Buffer.h>
|
||||
#include <velocypack/Iterator.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "Aql/types.h"
|
||||
#include "Basics/ConditionalDeleter.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
#include <velocypack/Buffer.h>
|
||||
#include <velocypack/Builder.h>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "Cluster/ClusterInfo.h"
|
||||
#include "Cluster/ClusterMethods.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
|
@ -55,7 +55,7 @@ Collection::Collection(std::string const& name, TRI_vocbase_t* vocbase,
|
|||
Collection::~Collection() {}
|
||||
|
||||
/// @brief get the pointer to the document collection
|
||||
TRI_document_collection_t* Collection::documentCollection() const {
|
||||
TRI_collection_t* Collection::documentCollection() const {
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
TRI_ASSERT(collection->_collection != nullptr);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
struct TRI_document_collection_t;
|
||||
struct TRI_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
namespace aql {
|
||||
|
@ -71,7 +71,7 @@ struct Collection {
|
|||
}
|
||||
|
||||
/// @brief get the pointer to the document collection
|
||||
TRI_document_collection_t* documentCollection() const;
|
||||
TRI_collection_t* documentCollection() const;
|
||||
|
||||
/// @brief count the LOCAL number of documents in the collection
|
||||
size_t count() const;
|
||||
|
|
|
@ -322,7 +322,6 @@ add_executable(${BIN_ARANGOD}
|
|||
VocBase/collection.cpp
|
||||
VocBase/compactor.cpp
|
||||
VocBase/datafile.cpp
|
||||
VocBase/document-collection.cpp
|
||||
VocBase/modes.cpp
|
||||
VocBase/replication-applier.cpp
|
||||
VocBase/replication-common.cpp
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "Cluster/ServerState.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Rest/HttpResponse.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// turn off warnings about too long type name for debug symbols blabla in MSVC
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "Basics/Common.h"
|
||||
#include "Cluster/AgencyComm.h"
|
||||
#include "Rest/HttpResponse.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#include <velocypack/Slice.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "Utils/Transaction.h"
|
||||
#include "Utils/TransactionContext.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "Logger/Logger.h"
|
||||
#include "Basics/Utf8Helper.h"
|
||||
#include "FulltextIndex/fulltext-index.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "GeoIndex2.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Indexes/SimpleAttributeEqualityMatcher.h"
|
||||
#include "Utils/TransactionContext.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
|
||||
#include <ostream>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "Indexes/SimpleAttributeEqualityMatcher.h"
|
||||
#include "Utils/Transaction.h"
|
||||
#include "Utils/TransactionContext.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "Indexes/RocksDBFeature.h"
|
||||
#include "Indexes/RocksDBKeyComparator.h"
|
||||
#include "Utils/Transaction.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
#include <rocksdb/utilities/optimistic_transaction_db.h>
|
||||
#include <rocksdb/utilities/transaction.h>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Basics/debugging.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Utils/Transaction.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "Utils/CollectionGuard.h"
|
||||
#include "Utils/SingleCollectionTransaction.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "Utils/CollectionGuard.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ int InitialSyncer::handleSyncKeys(TRI_vocbase_col_t* col,
|
|||
// fetch all local keys from primary index
|
||||
std::vector<void const*> markers;
|
||||
|
||||
TRI_document_collection_t* document = nullptr;
|
||||
TRI_collection_t* document = nullptr;
|
||||
DocumentDitch* ditch = nullptr;
|
||||
|
||||
// acquire a replication ditch so no datafiles are thrown away from now on
|
||||
|
@ -1849,7 +1849,7 @@ int InitialSyncer::handleCollection(VPackSlice const& parameters,
|
|||
|
||||
trx.orderDitch(col->_cid); // will throw when it fails
|
||||
|
||||
TRI_document_collection_t* document = trx.documentCollection();
|
||||
TRI_collection_t* document = trx.documentCollection();
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
for (auto const& idxDef : VPackArrayIterator(indexes)) {
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "Utils/OperationResult.h"
|
||||
#include "Utils/SingleCollectionTransaction.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
@ -558,7 +557,7 @@ int Syncer::createIndex(VPackSlice const& slice) {
|
|||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = guard.collection()->_collection;
|
||||
TRI_collection_t* document = guard.collection()->_collection;
|
||||
|
||||
SingleCollectionTransaction trx(StandaloneTransactionContext::Create(_vocbase), guard.collection()->_cid, TRI_TRANSACTION_WRITE);
|
||||
|
||||
|
@ -616,7 +615,7 @@ int Syncer::dropIndex(arangodb::velocypack::Slice const& slice) {
|
|||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = guard.collection()->_collection;
|
||||
TRI_collection_t* document = guard.collection()->_collection;
|
||||
|
||||
bool result = document->dropIndex(iid, true);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Rest/HttpRequest.h"
|
||||
#include "Utils/SingleCollectionTransaction.h"
|
||||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "Cluster/ClusterMethods.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
|
|
@ -1775,7 +1775,7 @@ int RestReplicationHandler::processRestoreCollectionCoordinator(
|
|||
|
||||
// create a dummy primary index
|
||||
{
|
||||
TRI_document_collection_t* doc = nullptr;
|
||||
TRI_collection_t* doc = nullptr;
|
||||
std::unique_ptr<arangodb::PrimaryIndex> primaryIndex(
|
||||
new arangodb::PrimaryIndex(doc));
|
||||
toMerge.openObject();
|
||||
|
@ -1882,7 +1882,7 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection,
|
|||
try {
|
||||
CollectionGuard guard(_vocbase, name.c_str());
|
||||
|
||||
TRI_document_collection_t* document = guard.collection()->_collection;
|
||||
TRI_collection_t* document = guard.collection()->_collection;
|
||||
|
||||
SingleCollectionTransaction trx(
|
||||
StandaloneTransactionContext::Create(_vocbase), document->_info.id(),
|
||||
|
@ -3858,7 +3858,7 @@ void RestReplicationHandler::handleCommandAddFollower() {
|
|||
return;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* docColl = col->_collection;
|
||||
TRI_collection_t* docColl = col->_collection;
|
||||
if (docColl == nullptr) {
|
||||
generateError(GeneralResponse::ResponseCode::SERVER_ERROR,
|
||||
TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED,
|
||||
|
@ -3915,7 +3915,7 @@ void RestReplicationHandler::handleCommandRemoveFollower() {
|
|||
return;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* docColl = col->_collection;
|
||||
TRI_collection_t* docColl = col->_collection;
|
||||
if (docColl == nullptr) {
|
||||
generateError(GeneralResponse::ResponseCode::SERVER_ERROR,
|
||||
TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED,
|
||||
|
@ -3989,7 +3989,7 @@ void RestReplicationHandler::handleCommandHoldReadLockCollection() {
|
|||
}
|
||||
}
|
||||
|
||||
TRI_document_collection_t* docColl = col->_collection;
|
||||
TRI_collection_t* docColl = col->_collection;
|
||||
if (docColl == nullptr) {
|
||||
generateError(GeneralResponse::ResponseCode::SERVER_ERROR,
|
||||
TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "Rest/HttpRequest.h"
|
||||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "Utils/Transaction.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
#include <velocypack/Dumper.h>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "V8Server/V8DealerFeature.h"
|
||||
#include "V8Server/v8-query.h"
|
||||
#include "V8Server/v8-vocbase.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::application_features;
|
||||
|
|
|
@ -112,7 +112,7 @@ class AqlTransaction : public Transaction {
|
|||
/// @brief documentCollection
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* documentCollection(TRI_voc_cid_t cid) {
|
||||
TRI_collection_t* documentCollection(TRI_voc_cid_t cid) {
|
||||
TRI_transaction_collection_t* trxColl = this->trxCollection(cid);
|
||||
TRI_ASSERT(trxColl != nullptr);
|
||||
return trxColl->_collection->_collection;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "VocBase/compactor.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
struct TRI_document_collection_t;
|
||||
struct TRI_collection_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
namespace arangodb {
|
||||
|
@ -62,7 +62,7 @@ class CollectionExport {
|
|||
|
||||
private:
|
||||
arangodb::CollectionGuard* _guard;
|
||||
struct TRI_document_collection_t* _document;
|
||||
struct TRI_collection_t* _document;
|
||||
arangodb::DocumentDitch* _ditch;
|
||||
std::string const _name;
|
||||
arangodb::CollectionNameResolver _resolver;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "VocBase/compactor.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
struct TRI_df_marker_t;
|
||||
struct TRI_document_collection_t;
|
||||
struct TRI_collection_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
namespace arangodb {
|
||||
|
@ -116,7 +116,7 @@ class CollectionKeys {
|
|||
private:
|
||||
struct TRI_vocbase_t* _vocbase;
|
||||
arangodb::CollectionGuard* _guard;
|
||||
struct TRI_document_collection_t* _document;
|
||||
struct TRI_collection_t* _document;
|
||||
arangodb::DocumentDitch* _ditch;
|
||||
std::string const _name;
|
||||
arangodb::CollectionNameResolver _resolver;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "Utils/TransactionContext.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "Utils/Transaction.h"
|
||||
#include "Utils/TransactionContext.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
@ -97,7 +97,7 @@ TRI_transaction_collection_t* SingleCollectionTransaction::trxCollection() {
|
|||
/// in two different situations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* SingleCollectionTransaction::documentCollection() {
|
||||
TRI_collection_t* SingleCollectionTransaction::documentCollection() {
|
||||
if (_documentCollection != nullptr) {
|
||||
return _documentCollection;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class SingleCollectionTransaction : public Transaction {
|
|||
/// in two different situations
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* documentCollection();
|
||||
TRI_collection_t* documentCollection();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the underlying collection's id
|
||||
|
@ -133,10 +133,10 @@ class SingleCollectionTransaction : public Transaction {
|
|||
TRI_transaction_collection_t* _trxCollection;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief TRI_document_collection_t* cache
|
||||
/// @brief TRI_collection_t* cache
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* _documentCollection;
|
||||
TRI_collection_t* _documentCollection;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief collection access type
|
||||
|
|
|
@ -46,9 +46,9 @@
|
|||
#include "Utils/TransactionContext.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
#include "VocBase/MasterPointers.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
|
@ -588,7 +588,7 @@ DocumentDitch* Transaction::orderDitch(TRI_voc_cid_t cid) {
|
|||
|
||||
TRI_ASSERT(trxCollection->_collection != nullptr);
|
||||
|
||||
TRI_document_collection_t* document =
|
||||
TRI_collection_t* document =
|
||||
trxCollection->_collection->_collection;
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
|
@ -951,7 +951,7 @@ void Transaction::extractKeyAndRevFromDocument(VPackSlice slice,
|
|||
/// added to the builder in the argument as a single object.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Transaction::buildDocumentIdentity(TRI_document_collection_t* document,
|
||||
void Transaction::buildDocumentIdentity(TRI_collection_t* document,
|
||||
VPackBuilder& builder,
|
||||
TRI_voc_cid_t cid,
|
||||
StringRef const& key,
|
||||
|
@ -1242,7 +1242,7 @@ void Transaction::invokeOnAllElements(std::string const& collectionName,
|
|||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_transaction_collection_t* trxCol = trxCollection(cid);
|
||||
TRI_document_collection_t* document = documentCollection(trxCol);
|
||||
TRI_collection_t* document = documentCollection(trxCol);
|
||||
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
||||
|
@ -1293,7 +1293,7 @@ int Transaction::documentFastPath(std::string const& collectionName,
|
|||
}
|
||||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ int Transaction::documentFastPathLocal(std::string const& collectionName,
|
|||
TRI_ASSERT(getStatus() == TRI_TRANSACTION_RUNNING);
|
||||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
||||
|
@ -1416,7 +1416,7 @@ OperationResult Transaction::documentLocal(std::string const& collectionName,
|
|||
OperationOptions& options) {
|
||||
TIMER_START(TRANSACTION_DOCUMENT_LOCAL);
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
if (!options.silent) {
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
@ -1575,7 +1575,7 @@ OperationResult Transaction::insertLocal(std::string const& collectionName,
|
|||
OperationOptions& options) {
|
||||
TIMER_START(TRANSACTION_INSERT_LOCAL);
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
// First see whether or not we have to do synchronous replication:
|
||||
std::shared_ptr<std::vector<ServerID> const> followers;
|
||||
|
@ -1919,7 +1919,7 @@ OperationResult Transaction::modifyLocal(
|
|||
TRI_voc_document_operation_e operation) {
|
||||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
if (options.returnOld || options.returnNew) {
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
@ -2187,7 +2187,7 @@ OperationResult Transaction::removeLocal(std::string const& collectionName,
|
|||
VPackSlice const value,
|
||||
OperationOptions& options) {
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
if (options.returnOld) {
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
@ -2494,7 +2494,7 @@ OperationResult Transaction::truncateLocal(std::string const& collectionName,
|
|||
return OperationResult(res);
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
VPackBuilder keyBuilder;
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
|
@ -2629,7 +2629,7 @@ OperationResult Transaction::countLocal(std::string const& collectionName) {
|
|||
return OperationResult(res);
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
uint64_t num = document->_numberDocuments;
|
||||
|
||||
|
@ -2867,7 +2867,7 @@ std::unique_ptr<OperationCursor> Transaction::indexScan(
|
|||
}
|
||||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
orderDitch(cid); // will throw when it fails
|
||||
|
||||
|
@ -2938,7 +2938,7 @@ std::unique_ptr<OperationCursor> Transaction::indexScan(
|
|||
/// @brief return the collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* Transaction::documentCollection(
|
||||
TRI_collection_t* Transaction::documentCollection(
|
||||
TRI_transaction_collection_t const* trxCollection) const {
|
||||
TRI_ASSERT(_trx != nullptr);
|
||||
TRI_ASSERT(trxCollection != nullptr);
|
||||
|
@ -2953,7 +2953,7 @@ TRI_document_collection_t* Transaction::documentCollection(
|
|||
/// @brief return the collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* Transaction::documentCollection(
|
||||
TRI_collection_t* Transaction::documentCollection(
|
||||
TRI_voc_cid_t cid) const {
|
||||
TRI_ASSERT(_trx != nullptr);
|
||||
TRI_ASSERT(getStatus() == TRI_TRANSACTION_RUNNING);
|
||||
|
@ -3039,7 +3039,7 @@ int Transaction::addCollection(std::string const& name, TRI_transaction_type_e t
|
|||
/// @brief test if a collection is already locked
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Transaction::isLocked(TRI_document_collection_t* document,
|
||||
bool Transaction::isLocked(TRI_collection_t* document,
|
||||
TRI_transaction_type_e type) {
|
||||
if (_trx == nullptr || getStatus() != TRI_TRANSACTION_RUNNING) {
|
||||
return false;
|
||||
|
@ -3090,7 +3090,7 @@ std::vector<std::shared_ptr<Index>> Transaction::indexesForCollection(
|
|||
// For a DBserver we use the local case.
|
||||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
// Wrap fake shared pointers around the raw pointers:
|
||||
std::shared_ptr<Index> dummy;
|
||||
|
@ -3256,7 +3256,7 @@ Transaction::IndexHandle Transaction::getIndexByIdentifier(
|
|||
}
|
||||
|
||||
TRI_voc_cid_t cid = addCollectionAtRuntime(collectionName);
|
||||
TRI_document_collection_t* document = documentCollection(trxCollection(cid));
|
||||
TRI_collection_t* document = documentCollection(trxCollection(cid));
|
||||
|
||||
if (indexHandle.empty()) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER,
|
||||
|
|
|
@ -42,7 +42,7 @@ class Transaction;
|
|||
}
|
||||
#endif
|
||||
|
||||
struct TRI_document_collection_t;
|
||||
struct TRI_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
|
||||
|
@ -602,7 +602,7 @@ class Transaction {
|
|||
/// @brief test if a collection is already locked
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool isLocked(TRI_document_collection_t*, TRI_transaction_type_e);
|
||||
bool isLocked(TRI_collection_t*, TRI_transaction_type_e);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the setup state
|
||||
|
@ -610,7 +610,7 @@ class Transaction {
|
|||
|
||||
int setupState() { return _setupState; }
|
||||
|
||||
TRI_document_collection_t* documentCollection(TRI_voc_cid_t) const;
|
||||
TRI_collection_t* documentCollection(TRI_voc_cid_t) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the index by it's identifier. Will either throw or
|
||||
|
@ -643,7 +643,7 @@ class Transaction {
|
|||
/// argument as a single object.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void buildDocumentIdentity(TRI_document_collection_t* document,
|
||||
void buildDocumentIdentity(TRI_collection_t* document,
|
||||
VPackBuilder& builder,
|
||||
TRI_voc_cid_t cid,
|
||||
StringRef const& key,
|
||||
|
@ -724,7 +724,7 @@ class Transaction {
|
|||
/// @brief return the collection
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* documentCollection(
|
||||
TRI_collection_t* documentCollection(
|
||||
TRI_transaction_collection_t const*) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "Utils/Transaction.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
|
@ -120,7 +120,7 @@ VPackCustomTypeHandler* TransactionContext::createCustomTypeHandler(TRI_vocbase_
|
|||
/// function will return a nullptr!
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DocumentDitch* TransactionContext::orderDitch(TRI_document_collection_t* document) {
|
||||
DocumentDitch* TransactionContext::orderDitch(TRI_collection_t* document) {
|
||||
TRI_voc_cid_t cid = document->_info.id();
|
||||
|
||||
auto it = _ditches.find(cid);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <velocypack/Options.h>
|
||||
|
||||
struct TRI_document_collection_t;
|
||||
struct TRI_collection_t;
|
||||
struct TRI_transaction_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
|
@ -88,7 +88,7 @@ class TransactionContext {
|
|||
/// function will return a nullptr!
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DocumentDitch* orderDitch(TRI_document_collection_t*);
|
||||
DocumentDitch* orderDitch(TRI_collection_t*);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the ditch for a collection
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "V8Traverser.h"
|
||||
#include "VocBase/SingleServerTraverser.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
|
|
@ -952,7 +952,7 @@ static TRI_doc_collection_info_t* GetFigures(TRI_vocbase_col_t* collection) {
|
|||
// READ-LOCK start
|
||||
trx.lockRead();
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
TRI_doc_collection_info_t* info = document->figures();
|
||||
|
||||
trx.finish(res);
|
||||
|
@ -1111,7 +1111,7 @@ static void JS_LeaderResign(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_V8_THROW_EXCEPTION(res);
|
||||
}
|
||||
TRI_document_collection_t* docColl = trx.documentCollection();
|
||||
TRI_collection_t* docColl = trx.documentCollection();
|
||||
docColl->followers()->clear();
|
||||
}
|
||||
|
||||
|
@ -1364,7 +1364,7 @@ static void JS_PropertiesVocbaseCol(
|
|||
return;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
// check if we want to change some parameters
|
||||
if (0 < args.Length()) {
|
||||
|
@ -2056,7 +2056,7 @@ static void JS_RotateVocbaseCol(
|
|||
|
||||
TRI_THROW_SHARDING_COLLECTION_NOT_YET_IMPLEMENTED(collection);
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
int res = document->rotateActiveJournal();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "V8/v8-vpack.h"
|
||||
#include "V8Server/v8-vocbase.h"
|
||||
#include "V8Server/v8-vocindex.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
|
@ -365,7 +365,7 @@ static void JS_ChecksumCollection(
|
|||
trx.orderDitch(col->_cid); // will throw when it fails
|
||||
|
||||
// get last tick
|
||||
TRI_document_collection_t* document = trx.documentCollection();
|
||||
TRI_collection_t* document = trx.documentCollection();
|
||||
std::string const revisionId = std::to_string(document->_info.revision());
|
||||
uint64_t hash = 0;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "v8-vocbaseprivate.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
#include "V8/v8-conv.h"
|
||||
|
||||
|
|
|
@ -105,10 +105,10 @@ int32_t const WRP_VOCBASE_COL_TYPE = 2;
|
|||
|
||||
struct CollectionDitchInfo {
|
||||
arangodb::DocumentDitch* ditch;
|
||||
TRI_document_collection_t* col;
|
||||
TRI_collection_t* col;
|
||||
|
||||
CollectionDitchInfo(arangodb::DocumentDitch* ditch,
|
||||
TRI_document_collection_t* col)
|
||||
TRI_collection_t* col)
|
||||
: ditch(ditch), col(col) {}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "Basics/Common.h"
|
||||
#include "V8/v8-globals.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
|
||||
#include "Basics/Common.h"
|
||||
#include "V8/v8-utils.h"
|
||||
#include "v8-vocbase.h"
|
||||
#include "V8Server/v8-vocbase.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
|
||||
#include <velocypack/Builder.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief wrapped class for TRI_vocbase_t
|
||||
|
|
|
@ -590,7 +590,7 @@ static void EnsureIndexLocal(v8::FunctionCallbackInfo<v8::Value> const& args,
|
|||
TRI_V8_THROW_EXCEPTION(res);
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = trx.documentCollection();
|
||||
TRI_collection_t* document = trx.documentCollection();
|
||||
std::string const& collectionName = std::string(collection->_name);
|
||||
|
||||
// disallow index creation in read-only mode
|
||||
|
@ -1056,7 +1056,7 @@ static void CreateCollectionCoordinator(
|
|||
ArrayBuilder ab(&velocy, "indexes");
|
||||
|
||||
// create a dummy primary index
|
||||
TRI_document_collection_t* doc = nullptr;
|
||||
TRI_collection_t* doc = nullptr;
|
||||
std::unique_ptr<arangodb::PrimaryIndex> primaryIndex(
|
||||
new arangodb::PrimaryIndex(doc));
|
||||
|
||||
|
@ -1207,7 +1207,7 @@ static void JS_DropIndexVocbaseCol(
|
|||
TRI_V8_THROW_EXCEPTION(res);
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = trx.documentCollection();
|
||||
TRI_collection_t* document = trx.documentCollection();
|
||||
|
||||
auto idx = TRI_LookupIndexByHandle(isolate, trx.resolver(), collection,
|
||||
args[0], true);
|
||||
|
@ -1304,7 +1304,7 @@ static void JS_GetIndexesVocbaseCol(
|
|||
// READ-LOCK start
|
||||
trx.lockRead();
|
||||
|
||||
TRI_document_collection_t* document = trx.documentCollection();
|
||||
TRI_collection_t* document = trx.documentCollection();
|
||||
std::string const& collectionName = std::string(collection->_name);
|
||||
|
||||
// get list of indexes
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include "Logger/Logger.h"
|
||||
#include "Utils/CursorRepository.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/compactor.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
@ -82,7 +82,7 @@ void CleanupThread::run() {
|
|||
|
||||
for (auto& collection : collections) {
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
TRI_document_collection_t* document;
|
||||
TRI_collection_t* document;
|
||||
|
||||
{
|
||||
READ_LOCKER(readLocker, collection->_lock);
|
||||
|
@ -152,7 +152,7 @@ void CleanupThread::cleanupCursors(bool force) {
|
|||
|
||||
/// @brief checks all datafiles of a collection
|
||||
void CleanupThread::cleanupCollection(TRI_vocbase_col_t* collection,
|
||||
TRI_document_collection_t* document) {
|
||||
TRI_collection_t* document) {
|
||||
// unload operations can normally only be executed when a collection is fully
|
||||
// garbage collected
|
||||
bool unloadChecked = false;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "Basics/Common.h"
|
||||
#include "Basics/Thread.h"
|
||||
|
||||
struct TRI_document_collection_t;
|
||||
struct TRI_collection_t;
|
||||
struct TRI_vocbase_col_t;
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class CleanupThread : public Thread {
|
|||
void cleanupCursors(bool force);
|
||||
|
||||
/// @brief checks all datafiles of a collection
|
||||
void cleanupCollection(TRI_vocbase_col_t* collection, TRI_document_collection_t* document);
|
||||
void cleanupCollection(TRI_vocbase_col_t* collection, TRI_collection_t* document);
|
||||
|
||||
private:
|
||||
TRI_vocbase_t* _vocbase;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "Ditch.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ public:
|
|||
|
||||
bool vertexMatchesConditions(std::string const&, size_t);
|
||||
|
||||
std::vector<TRI_document_collection_t*> _edgeCols;
|
||||
std::vector<TRI_collection_t*> _edgeCols;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Outer top level transaction
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/IndexPoolFeature.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "Wal/DocumentOperation.h"
|
||||
|
@ -1089,8 +1088,8 @@ TRI_datafile_t* TRI_collection_t::createDatafile(TRI_voc_fid_t fid,
|
|||
TRI_voc_size_t journalSize,
|
||||
bool isCompactor) {
|
||||
TRI_ASSERT(fid > 0);
|
||||
TRI_document_collection_t* document =
|
||||
static_cast<TRI_document_collection_t*>(this);
|
||||
TRI_collection_t* document =
|
||||
static_cast<TRI_collection_t*>(this);
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
// create an entry for the new datafile
|
||||
|
@ -5117,3 +5116,550 @@ int TRI_collection_t::indexFromVelocyPack(arangodb::Transaction* trx,
|
|||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/// @brief state during opening of a collection
|
||||
struct open_iterator_state_t {
|
||||
TRI_collection_t* _document;
|
||||
TRI_voc_tid_t _tid;
|
||||
TRI_voc_fid_t _fid;
|
||||
std::unordered_map<TRI_voc_fid_t, DatafileStatisticsContainer*> _stats;
|
||||
DatafileStatisticsContainer* _dfi;
|
||||
TRI_vocbase_t* _vocbase;
|
||||
arangodb::Transaction* _trx;
|
||||
uint64_t _deletions;
|
||||
uint64_t _documents;
|
||||
int64_t _initialCount;
|
||||
|
||||
open_iterator_state_t(TRI_collection_t* document,
|
||||
TRI_vocbase_t* vocbase)
|
||||
: _document(document),
|
||||
_tid(0),
|
||||
_fid(0),
|
||||
_stats(),
|
||||
_dfi(nullptr),
|
||||
_vocbase(vocbase),
|
||||
_trx(nullptr),
|
||||
_deletions(0),
|
||||
_documents(0),
|
||||
_initialCount(-1) {}
|
||||
|
||||
~open_iterator_state_t() {
|
||||
for (auto& it : _stats) {
|
||||
delete it.second;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// @brief find a statistics container for a given file id
|
||||
static DatafileStatisticsContainer* FindDatafileStats(
|
||||
open_iterator_state_t* state, TRI_voc_fid_t fid) {
|
||||
auto it = state->_stats.find(fid);
|
||||
|
||||
if (it != state->_stats.end()) {
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
auto stats = std::make_unique<DatafileStatisticsContainer>();
|
||||
|
||||
state->_stats.emplace(fid, stats.get());
|
||||
auto p = stats.release();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/// @brief process a document (or edge) marker when opening a collection
|
||||
static int OpenIteratorHandleDocumentMarker(TRI_df_marker_t const* marker,
|
||||
TRI_datafile_t* datafile,
|
||||
open_iterator_state_t* state) {
|
||||
auto const fid = datafile->_fid;
|
||||
TRI_collection_t* document = state->_document;
|
||||
arangodb::Transaction* trx = state->_trx;
|
||||
|
||||
VPackSlice const slice(reinterpret_cast<char const*>(marker) + DatafileHelper::VPackOffset(TRI_DF_MARKER_VPACK_DOCUMENT));
|
||||
VPackSlice keySlice;
|
||||
TRI_voc_rid_t revisionId;
|
||||
|
||||
Transaction::extractKeyAndRevFromDocument(slice, keySlice, revisionId);
|
||||
|
||||
document->setLastRevision(revisionId, false);
|
||||
VPackValueLength length;
|
||||
char const* p = keySlice.getString(length);
|
||||
document->_keyGenerator->track(p, length);
|
||||
|
||||
++state->_documents;
|
||||
|
||||
if (state->_fid != fid) {
|
||||
// update the state
|
||||
state->_fid = fid; // when we're here, we're looking at a datafile
|
||||
state->_dfi = FindDatafileStats(state, fid);
|
||||
}
|
||||
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
|
||||
// no primary index lock required here because we are the only ones reading
|
||||
// from the index ATM
|
||||
auto found = primaryIndex->lookupKey(trx, keySlice);
|
||||
|
||||
// it is a new entry
|
||||
if (found == nullptr) {
|
||||
TRI_doc_mptr_t* header = document->_masterPointers.request();
|
||||
|
||||
if (header == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
header->setFid(fid, false);
|
||||
header->setHash(primaryIndex->calculateHash(trx, keySlice));
|
||||
header->setVPackFromMarker(marker);
|
||||
|
||||
// insert into primary index
|
||||
void const* result = nullptr;
|
||||
int res = primaryIndex->insertKey(trx, header, &result);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
document->_masterPointers.release(header);
|
||||
LOG(ERR) << "inserting document into primary index failed with error: " << TRI_errno_string(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
++document->_numberDocuments;
|
||||
|
||||
// update the datafile info
|
||||
state->_dfi->numberAlive++;
|
||||
state->_dfi->sizeAlive += DatafileHelper::AlignedMarkerSize<int64_t>(marker);
|
||||
}
|
||||
|
||||
// it is an update, but only if found has a smaller revision identifier
|
||||
else {
|
||||
// save the old data
|
||||
TRI_doc_mptr_t oldData = *found;
|
||||
|
||||
// update the header info
|
||||
found->setFid(fid, false); // when we're here, we're looking at a datafile
|
||||
found->setVPackFromMarker(marker);
|
||||
|
||||
// update the datafile info
|
||||
DatafileStatisticsContainer* dfi;
|
||||
if (oldData.getFid() == state->_fid) {
|
||||
dfi = state->_dfi;
|
||||
} else {
|
||||
dfi = FindDatafileStats(state, oldData.getFid());
|
||||
}
|
||||
|
||||
if (oldData.vpack() != nullptr) {
|
||||
int64_t size = static_cast<int64_t>(oldData.markerSize());
|
||||
|
||||
dfi->numberAlive--;
|
||||
dfi->sizeAlive -= DatafileHelper::AlignedSize<int64_t>(size);
|
||||
dfi->numberDead++;
|
||||
dfi->sizeDead += DatafileHelper::AlignedSize<int64_t>(size);
|
||||
}
|
||||
|
||||
state->_dfi->numberAlive++;
|
||||
state->_dfi->sizeAlive += DatafileHelper::AlignedMarkerSize<int64_t>(marker);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief process a deletion marker when opening a collection
|
||||
static int OpenIteratorHandleDeletionMarker(TRI_df_marker_t const* marker,
|
||||
TRI_datafile_t* datafile,
|
||||
open_iterator_state_t* state) {
|
||||
TRI_collection_t* document = state->_document;
|
||||
arangodb::Transaction* trx = state->_trx;
|
||||
|
||||
VPackSlice const slice(reinterpret_cast<char const*>(marker) + DatafileHelper::VPackOffset(TRI_DF_MARKER_VPACK_REMOVE));
|
||||
|
||||
VPackSlice keySlice;
|
||||
TRI_voc_rid_t revisionId;
|
||||
|
||||
Transaction::extractKeyAndRevFromDocument(slice, keySlice, revisionId);
|
||||
|
||||
document->setLastRevision(revisionId, false);
|
||||
VPackValueLength length;
|
||||
char const* p = keySlice.getString(length);
|
||||
document->_keyGenerator->track(p, length);
|
||||
|
||||
++state->_deletions;
|
||||
|
||||
if (state->_fid != datafile->_fid) {
|
||||
// update the state
|
||||
state->_fid = datafile->_fid;
|
||||
state->_dfi = FindDatafileStats(state, datafile->_fid);
|
||||
}
|
||||
|
||||
// no primary index lock required here because we are the only ones reading
|
||||
// from the index ATM
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
TRI_doc_mptr_t* found = primaryIndex->lookupKey(trx, keySlice);
|
||||
|
||||
// it is a new entry, so we missed the create
|
||||
if (found == nullptr) {
|
||||
// update the datafile info
|
||||
state->_dfi->numberDeletions++;
|
||||
}
|
||||
|
||||
// it is a real delete
|
||||
else {
|
||||
// update the datafile info
|
||||
DatafileStatisticsContainer* dfi;
|
||||
|
||||
if (found->getFid() == state->_fid) {
|
||||
dfi = state->_dfi;
|
||||
} else {
|
||||
dfi = FindDatafileStats(state, found->getFid());
|
||||
}
|
||||
|
||||
TRI_ASSERT(found->vpack() != nullptr);
|
||||
|
||||
int64_t size = DatafileHelper::AlignedSize<int64_t>(found->markerSize());
|
||||
|
||||
dfi->numberAlive--;
|
||||
dfi->sizeAlive -= DatafileHelper::AlignedSize<int64_t>(size);
|
||||
dfi->numberDead++;
|
||||
dfi->sizeDead += DatafileHelper::AlignedSize<int64_t>(size);
|
||||
state->_dfi->numberDeletions++;
|
||||
|
||||
document->deletePrimaryIndex(trx, found);
|
||||
--document->_numberDocuments;
|
||||
|
||||
// free the header
|
||||
document->_masterPointers.release(found);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief iterator for open
|
||||
static bool OpenIterator(TRI_df_marker_t const* marker, void* data,
|
||||
TRI_datafile_t* datafile) {
|
||||
TRI_collection_t* document =
|
||||
static_cast<open_iterator_state_t*>(data)->_document;
|
||||
TRI_voc_tick_t const tick = marker->getTick();
|
||||
TRI_df_marker_type_t const type = marker->getType();
|
||||
|
||||
int res;
|
||||
|
||||
if (type == TRI_DF_MARKER_VPACK_DOCUMENT) {
|
||||
res = OpenIteratorHandleDocumentMarker(marker, datafile,
|
||||
static_cast<open_iterator_state_t*>(data));
|
||||
|
||||
if (datafile->_dataMin == 0) {
|
||||
datafile->_dataMin = tick;
|
||||
}
|
||||
|
||||
if (tick > datafile->_dataMax) {
|
||||
datafile->_dataMax = tick;
|
||||
}
|
||||
} else if (type == TRI_DF_MARKER_VPACK_REMOVE) {
|
||||
res = OpenIteratorHandleDeletionMarker(marker, datafile,
|
||||
static_cast<open_iterator_state_t*>(data));
|
||||
} else {
|
||||
if (type == TRI_DF_MARKER_HEADER) {
|
||||
// ensure there is a datafile info entry for each datafile of the
|
||||
// collection
|
||||
FindDatafileStats(static_cast<open_iterator_state_t*>(data), datafile->_fid);
|
||||
}
|
||||
|
||||
LOG(TRACE) << "skipping marker type " << TRI_NameMarkerDatafile(marker);
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
if (datafile->_tickMin == 0) {
|
||||
datafile->_tickMin = tick;
|
||||
}
|
||||
|
||||
if (tick > datafile->_tickMax) {
|
||||
datafile->_tickMax = tick;
|
||||
}
|
||||
|
||||
if (tick > document->_tickMax) {
|
||||
if (type != TRI_DF_MARKER_HEADER &&
|
||||
type != TRI_DF_MARKER_FOOTER &&
|
||||
type != TRI_DF_MARKER_COL_HEADER &&
|
||||
type != TRI_DF_MARKER_PROLOGUE) {
|
||||
document->_tickMax = tick;
|
||||
}
|
||||
}
|
||||
|
||||
return (res == TRI_ERROR_NO_ERROR);
|
||||
}
|
||||
|
||||
/// @brief initializes a document collection
|
||||
static bool InitDocumentCollection(TRI_collection_t* document) {
|
||||
// create primary index
|
||||
std::unique_ptr<arangodb::Index> primaryIndex(
|
||||
new arangodb::PrimaryIndex(document));
|
||||
|
||||
try {
|
||||
document->addIndex(primaryIndex.get());
|
||||
primaryIndex.release();
|
||||
} catch (...) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// create edges index
|
||||
if (document->_info.type() == TRI_COL_TYPE_EDGE) {
|
||||
TRI_idx_iid_t iid = document->_info.id();
|
||||
if (document->_info.planId() > 0) {
|
||||
iid = document->_info.planId();
|
||||
}
|
||||
|
||||
try {
|
||||
std::unique_ptr<arangodb::Index> edgeIndex(
|
||||
new arangodb::EdgeIndex(iid, document));
|
||||
|
||||
document->addIndex(edgeIndex.get());
|
||||
edgeIndex.release();
|
||||
} catch (...) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief iterate all markers of the collection
|
||||
static int IterateMarkersCollection(arangodb::Transaction* trx,
|
||||
TRI_collection_t* collection) {
|
||||
auto document = reinterpret_cast<TRI_collection_t*>(collection);
|
||||
|
||||
// initialize state for iteration
|
||||
open_iterator_state_t openState(document, collection->_vocbase);
|
||||
|
||||
if (collection->_info.initialCount() != -1) {
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
|
||||
int res = primaryIndex->resize(
|
||||
trx, static_cast<size_t>(collection->_info.initialCount() * 1.1));
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
|
||||
openState._initialCount = collection->_info.initialCount();
|
||||
}
|
||||
|
||||
// read all documents and fill primary index
|
||||
auto cb = [&openState](TRI_df_marker_t const* marker, TRI_datafile_t* datafile) -> bool {
|
||||
return OpenIterator(marker, &openState, datafile);
|
||||
};
|
||||
|
||||
collection->iterateDatafiles(cb);
|
||||
|
||||
LOG(TRACE) << "found " << openState._documents << " document markers, " << openState._deletions << " deletion markers for collection '" << collection->_info.name() << "'";
|
||||
|
||||
// update the real statistics for the collection
|
||||
try {
|
||||
for (auto& it : openState._stats) {
|
||||
document->_datafileStatistics.create(it.first, *(it.second));
|
||||
}
|
||||
} catch (basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
} catch (...) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
/// @brief creates a new collection
|
||||
TRI_collection_t* TRI_CreateDocumentCollection(
|
||||
TRI_vocbase_t* vocbase, VocbaseCollectionInfo& parameters,
|
||||
TRI_voc_cid_t cid) {
|
||||
if (cid > 0) {
|
||||
TRI_UpdateTickServer(cid);
|
||||
} else {
|
||||
cid = TRI_NewTickServer();
|
||||
}
|
||||
|
||||
parameters.setCollectionId(cid);
|
||||
|
||||
// check if we can generate the key generator
|
||||
std::shared_ptr<arangodb::velocypack::Buffer<uint8_t> const> buffer =
|
||||
parameters.keyOptions();
|
||||
|
||||
VPackSlice slice;
|
||||
if (buffer != nullptr) {
|
||||
slice = VPackSlice(buffer->data());
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyGenerator> keyGenerator(KeyGenerator::factory(slice));
|
||||
|
||||
if (keyGenerator == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_ARANGO_INVALID_KEY_GENERATOR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto document = std::make_unique<TRI_collection_t>(vocbase);
|
||||
document->_keyGenerator.reset(keyGenerator.release());
|
||||
|
||||
TRI_collection_t* collection =
|
||||
TRI_CreateCollection(vocbase, document.get(), parameters);
|
||||
|
||||
if (collection == nullptr) {
|
||||
LOG(ERR) << "cannot create document collection";
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create document collection
|
||||
if (false == InitDocumentCollection(document.get())) {
|
||||
LOG(ERR) << "cannot initialize document collection";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// save the parameters block (within create, no need to lock)
|
||||
bool doSync = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database")->forceSyncProperties();
|
||||
int res = parameters.saveToFile(collection->path(), doSync);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG(ERR) << "cannot save collection parameters in directory '" << collection->path() << "': '" << TRI_last_error() << "'";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// remove the temporary file
|
||||
std::string tmpfile = collection->path() + ".tmp";
|
||||
TRI_UnlinkFile(tmpfile.c_str());
|
||||
|
||||
return document.release();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief opens an existing collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_collection_t* TRI_OpenDocumentCollection(TRI_vocbase_t* vocbase,
|
||||
TRI_vocbase_col_t* col,
|
||||
bool ignoreErrors) {
|
||||
// first open the document collection
|
||||
auto document = std::make_unique<TRI_collection_t>(vocbase);
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
double start = TRI_microtime();
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE)
|
||||
<< "open-document-collection { collection: " << vocbase->name() << "/"
|
||||
<< col->name() << " }";
|
||||
|
||||
int res = document->open(col->path(), ignoreErrors);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG(ERR) << "cannot open document collection from path '" << col->path() << "'";
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create document collection
|
||||
if (false == InitDocumentCollection(document.get())) {
|
||||
LOG(ERR) << "cannot initialize document collection";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// check if we can generate the key generator
|
||||
std::shared_ptr<arangodb::velocypack::Buffer<uint8_t> const> buffer = document->_info.keyOptions();
|
||||
|
||||
VPackSlice slice;
|
||||
if (buffer.get() != nullptr) {
|
||||
slice = VPackSlice(buffer->data());
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyGenerator> keyGenerator(KeyGenerator::factory(slice));
|
||||
|
||||
if (keyGenerator == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_ARANGO_INVALID_KEY_GENERATOR);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
document->_keyGenerator.reset(keyGenerator.release());
|
||||
|
||||
arangodb::SingleCollectionTransaction trx(
|
||||
arangodb::StandaloneTransactionContext::Create(vocbase),
|
||||
document->_info.id(), TRI_TRANSACTION_WRITE);
|
||||
|
||||
// build the primary index
|
||||
res = TRI_ERROR_INTERNAL;
|
||||
|
||||
try {
|
||||
double start = TRI_microtime();
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE)
|
||||
<< "iterate-markers { collection: " << vocbase->name() << "/"
|
||||
<< document->_info.name() << " }";
|
||||
|
||||
// iterate over all markers of the collection
|
||||
res = IterateMarkersCollection(&trx, document.get());
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE) << "[timer] " << Logger::FIXED(TRI_microtime() - start) << " s, iterate-markers { collection: " << vocbase->name() << "/" << document->_info.name() << " }";
|
||||
} catch (arangodb::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
} catch (std::bad_alloc const&) {
|
||||
res = TRI_ERROR_OUT_OF_MEMORY;
|
||||
} catch (...) {
|
||||
res = TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG(ERR) << "cannot iterate data of document collection";
|
||||
TRI_set_errno(res);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// build the indexes meta-data, but do not fill the indexes yet
|
||||
{
|
||||
auto old = document->useSecondaryIndexes();
|
||||
|
||||
// turn filling of secondary indexes off. we're now only interested in getting
|
||||
// the indexes' definition. we'll fill them below ourselves.
|
||||
document->useSecondaryIndexes(false);
|
||||
|
||||
try {
|
||||
document->detectIndexes(&trx);
|
||||
document->useSecondaryIndexes(old);
|
||||
} catch (...) {
|
||||
document->useSecondaryIndexes(old);
|
||||
LOG(ERR) << "cannot initialize collection indexes";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!arangodb::wal::LogfileManager::instance()->isInRecovery()) {
|
||||
// build the index structures, and fill the indexes
|
||||
document->fillIndexes(&trx, col);
|
||||
}
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE)
|
||||
<< "[timer] " << Logger::FIXED(TRI_microtime() - start)
|
||||
<< " s, open-document-collection { collection: " << vocbase->name() << "/"
|
||||
<< document->_info.name() << " }";
|
||||
|
||||
return document.release();
|
||||
}
|
||||
|
||||
/// @brief closes an open collection
|
||||
int TRI_CloseDocumentCollection(TRI_collection_t* document,
|
||||
bool updateStats) {
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
auto idxSize = primaryIndex->size();
|
||||
|
||||
if (!document->_info.deleted() &&
|
||||
document->_info.initialCount() != static_cast<int64_t>(idxSize)) {
|
||||
document->_info.updateCount(idxSize);
|
||||
|
||||
bool doSync = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database")->forceSyncProperties();
|
||||
// Ignore the error?
|
||||
document->_info.saveToFile(document->path(), doSync);
|
||||
}
|
||||
|
||||
// closes all open compactors, journals, datafiles
|
||||
document->close();
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
|
|
@ -636,4 +636,16 @@ struct TRI_collection_t {
|
|||
TRI_collection_t* TRI_CreateCollection(TRI_vocbase_t*, TRI_collection_t*,
|
||||
arangodb::VocbaseCollectionInfo const&);
|
||||
|
||||
/// @brief creates a new collection
|
||||
TRI_collection_t* TRI_CreateDocumentCollection(
|
||||
TRI_vocbase_t*, arangodb::VocbaseCollectionInfo&,
|
||||
TRI_voc_cid_t);
|
||||
|
||||
/// @brief opens an existing collection
|
||||
TRI_collection_t* TRI_OpenDocumentCollection(TRI_vocbase_t*,
|
||||
TRI_vocbase_col_t*, bool);
|
||||
|
||||
/// @brief closes an open collection
|
||||
int TRI_CloseDocumentCollection(TRI_collection_t*, bool);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/DatafileStatistics.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
|
@ -139,7 +139,7 @@ static int const COMPACTOR_INTERVAL = (1 * 1000 * 1000);
|
|||
|
||||
struct compaction_initial_context_t {
|
||||
arangodb::Transaction* _trx;
|
||||
TRI_document_collection_t* _document;
|
||||
TRI_collection_t* _document;
|
||||
int64_t _targetSize;
|
||||
TRI_voc_fid_t _fid;
|
||||
bool _keepDeletions;
|
||||
|
@ -152,7 +152,7 @@ struct compaction_initial_context_t {
|
|||
|
||||
struct compaction_context_t {
|
||||
arangodb::Transaction* _trx;
|
||||
TRI_document_collection_t* _document;
|
||||
TRI_collection_t* _document;
|
||||
TRI_datafile_t* _compactor;
|
||||
DatafileStatisticsContainer _dfi;
|
||||
bool _keepDeletions;
|
||||
|
@ -168,7 +168,7 @@ struct compaction_info_t {
|
|||
};
|
||||
|
||||
/// @brief determine the number of documents in the collection
|
||||
static uint64_t GetNumberOfDocuments(TRI_document_collection_t* document) {
|
||||
static uint64_t GetNumberOfDocuments(TRI_collection_t* document) {
|
||||
TRI_vocbase_t* vocbase = document->_vocbase;
|
||||
|
||||
SingleCollectionTransaction trx(StandaloneTransactionContext::Create(vocbase), document->_info.id(), TRI_TRANSACTION_READ);
|
||||
|
@ -189,7 +189,7 @@ static uint64_t GetNumberOfDocuments(TRI_document_collection_t* document) {
|
|||
/// @brief write a copy of the marker into the datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int CopyMarker(TRI_document_collection_t* document,
|
||||
static int CopyMarker(TRI_collection_t* document,
|
||||
TRI_datafile_t* compactor, TRI_df_marker_t const* marker,
|
||||
TRI_df_marker_t** result) {
|
||||
int res = TRI_ReserveElementDatafile(compactor, marker->getSize(), result, 0);
|
||||
|
@ -208,8 +208,7 @@ static int CopyMarker(TRI_document_collection_t* document,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void DropDatafileCallback(TRI_datafile_t* datafile, void* data) {
|
||||
TRI_document_collection_t* document =
|
||||
static_cast<TRI_document_collection_t*>(data);
|
||||
TRI_collection_t* document = static_cast<TRI_collection_t*>(data);
|
||||
TRI_voc_fid_t fid = datafile->_fid;
|
||||
|
||||
std::string copy;
|
||||
|
@ -274,7 +273,7 @@ static void RenameDatafileCallback(TRI_datafile_t* datafile, void* data) {
|
|||
auto* context = static_cast<compaction_context_t*>(data);
|
||||
TRI_datafile_t* compactor = context->_compactor;
|
||||
|
||||
TRI_document_collection_t* document = context->_document;
|
||||
TRI_collection_t* document = context->_document;
|
||||
|
||||
bool ok = false;
|
||||
TRI_ASSERT(datafile->_fid == compactor->_fid);
|
||||
|
@ -325,7 +324,7 @@ static void RenameDatafileCallback(TRI_datafile_t* datafile, void* data) {
|
|||
static bool Compactifier(TRI_df_marker_t const* marker, void* data,
|
||||
TRI_datafile_t* datafile) {
|
||||
auto* context = static_cast<compaction_context_t*>(data);
|
||||
TRI_document_collection_t* document = context->_document;
|
||||
TRI_collection_t* document = context->_document;
|
||||
TRI_voc_fid_t const targetFid = context->_compactor->_fid;
|
||||
|
||||
TRI_df_marker_type_t const type = marker->getType();
|
||||
|
@ -399,7 +398,7 @@ static bool Compactifier(TRI_df_marker_t const* marker, void* data,
|
|||
/// @brief remove an empty compactor file
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int RemoveCompactor(TRI_document_collection_t* document,
|
||||
static int RemoveCompactor(TRI_collection_t* document,
|
||||
TRI_datafile_t* compactor) {
|
||||
LOG_TOPIC(DEBUG, Logger::COMPACTOR) << "removing empty compaction file '" << compactor->getName(compactor) << "'";
|
||||
|
||||
|
@ -431,7 +430,7 @@ static int RemoveCompactor(TRI_document_collection_t* document,
|
|||
/// @brief remove an empty datafile
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int RemoveDatafile(TRI_document_collection_t* document,
|
||||
static int RemoveDatafile(TRI_collection_t* document,
|
||||
TRI_datafile_t* df) {
|
||||
LOG_TOPIC(DEBUG, Logger::COMPACTOR) << "removing empty datafile '" << df->getName(df) << "'";
|
||||
|
||||
|
@ -456,7 +455,7 @@ static int RemoveDatafile(TRI_document_collection_t* document,
|
|||
static bool CalculateSize(TRI_df_marker_t const* marker, void* data,
|
||||
TRI_datafile_t* datafile) {
|
||||
auto* context = static_cast<compaction_initial_context_t*>(data);
|
||||
TRI_document_collection_t* document = context->_document;
|
||||
TRI_collection_t* document = context->_document;
|
||||
|
||||
TRI_df_marker_type_t const type = marker->getType();
|
||||
|
||||
|
@ -495,7 +494,7 @@ static bool CalculateSize(TRI_df_marker_t const* marker, void* data,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static compaction_initial_context_t InitCompaction(
|
||||
arangodb::Transaction* trx, TRI_document_collection_t* document,
|
||||
arangodb::Transaction* trx, TRI_collection_t* document,
|
||||
std::vector<compaction_info_t> const& toCompact) {
|
||||
compaction_initial_context_t context;
|
||||
|
||||
|
@ -555,7 +554,7 @@ static compaction_initial_context_t InitCompaction(
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void CompactifyDatafiles(
|
||||
TRI_document_collection_t* document,
|
||||
TRI_collection_t* document,
|
||||
std::vector<compaction_info_t> const& toCompact) {
|
||||
TRI_datafile_t* compactor;
|
||||
compaction_context_t context;
|
||||
|
@ -738,7 +737,7 @@ static void CompactifyDatafiles(
|
|||
/// @brief checks all datafiles of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool CompactifyDocumentCollection(TRI_document_collection_t* document) {
|
||||
static bool CompactifyDocumentCollection(TRI_collection_t* document) {
|
||||
// we can hopefully get away without the lock here...
|
||||
// if (! document->isFullyCollected()) {
|
||||
// return false;
|
||||
|
@ -1132,7 +1131,7 @@ void TRI_CompactorVocBase(void* data) {
|
|||
continue;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
if (document == nullptr) {
|
||||
continue;
|
||||
|
|
|
@ -1,654 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "document-collection.h"
|
||||
|
||||
#include "ApplicationFeatures/ApplicationServer.h"
|
||||
#include "Aql/QueryCache.h"
|
||||
#include "Basics/Barrier.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/HybridLogicalClock.h"
|
||||
#include "Basics/Timers.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/ThreadPool.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Cluster/ClusterMethods.h"
|
||||
#include "FulltextIndex/fulltext-index.h"
|
||||
#include "Indexes/EdgeIndex.h"
|
||||
#include "Indexes/FulltextIndex.h"
|
||||
#include "Indexes/GeoIndex2.h"
|
||||
#include "Indexes/HashIndex.h"
|
||||
#include "Indexes/PrimaryIndex.h"
|
||||
#include "Indexes/SkiplistIndex.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "RestServer/DatabaseFeature.h"
|
||||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "Utils/CollectionReadLocker.h"
|
||||
#include "Utils/CollectionWriteLocker.h"
|
||||
#include "Utils/SingleCollectionTransaction.h"
|
||||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/IndexPoolFeature.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
#include "VocBase/MasterPointers.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "Wal/DocumentOperation.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
#include "Wal/Marker.h"
|
||||
#include "Wal/Slots.h"
|
||||
|
||||
#ifdef ARANGODB_ENABLE_ROCKSDB
|
||||
#include "Indexes/RocksDBIndex.h"
|
||||
|
||||
#include <rocksdb/db.h>
|
||||
#include <rocksdb/options.h>
|
||||
#include <rocksdb/utilities/optimistic_transaction_db.h>
|
||||
#include <rocksdb/utilities/transaction.h>
|
||||
#endif
|
||||
|
||||
#include <velocypack/Collection.h>
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/Value.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::basics;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief state during opening of a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct open_iterator_state_t {
|
||||
TRI_document_collection_t* _document;
|
||||
TRI_voc_tid_t _tid;
|
||||
TRI_voc_fid_t _fid;
|
||||
std::unordered_map<TRI_voc_fid_t, DatafileStatisticsContainer*> _stats;
|
||||
DatafileStatisticsContainer* _dfi;
|
||||
TRI_vocbase_t* _vocbase;
|
||||
arangodb::Transaction* _trx;
|
||||
uint64_t _deletions;
|
||||
uint64_t _documents;
|
||||
int64_t _initialCount;
|
||||
|
||||
open_iterator_state_t(TRI_document_collection_t* document,
|
||||
TRI_vocbase_t* vocbase)
|
||||
: _document(document),
|
||||
_tid(0),
|
||||
_fid(0),
|
||||
_stats(),
|
||||
_dfi(nullptr),
|
||||
_vocbase(vocbase),
|
||||
_trx(nullptr),
|
||||
_deletions(0),
|
||||
_documents(0),
|
||||
_initialCount(-1) {}
|
||||
|
||||
~open_iterator_state_t() {
|
||||
for (auto& it : _stats) {
|
||||
delete it.second;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief find a statistics container for a given file id
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static DatafileStatisticsContainer* FindDatafileStats(
|
||||
open_iterator_state_t* state, TRI_voc_fid_t fid) {
|
||||
auto it = state->_stats.find(fid);
|
||||
|
||||
if (it != state->_stats.end()) {
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
auto stats = std::make_unique<DatafileStatisticsContainer>();
|
||||
|
||||
state->_stats.emplace(fid, stats.get());
|
||||
auto p = stats.release();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief process a document (or edge) marker when opening a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int OpenIteratorHandleDocumentMarker(TRI_df_marker_t const* marker,
|
||||
TRI_datafile_t* datafile,
|
||||
open_iterator_state_t* state) {
|
||||
auto const fid = datafile->_fid;
|
||||
TRI_document_collection_t* document = state->_document;
|
||||
arangodb::Transaction* trx = state->_trx;
|
||||
|
||||
VPackSlice const slice(reinterpret_cast<char const*>(marker) + DatafileHelper::VPackOffset(TRI_DF_MARKER_VPACK_DOCUMENT));
|
||||
VPackSlice keySlice;
|
||||
TRI_voc_rid_t revisionId;
|
||||
|
||||
Transaction::extractKeyAndRevFromDocument(slice, keySlice, revisionId);
|
||||
|
||||
document->setLastRevision(revisionId, false);
|
||||
VPackValueLength length;
|
||||
char const* p = keySlice.getString(length);
|
||||
document->_keyGenerator->track(p, length);
|
||||
|
||||
++state->_documents;
|
||||
|
||||
if (state->_fid != fid) {
|
||||
// update the state
|
||||
state->_fid = fid; // when we're here, we're looking at a datafile
|
||||
state->_dfi = FindDatafileStats(state, fid);
|
||||
}
|
||||
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
|
||||
// no primary index lock required here because we are the only ones reading
|
||||
// from the index ATM
|
||||
auto found = primaryIndex->lookupKey(trx, keySlice);
|
||||
|
||||
// it is a new entry
|
||||
if (found == nullptr) {
|
||||
TRI_doc_mptr_t* header = document->_masterPointers.request();
|
||||
|
||||
if (header == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
header->setFid(fid, false);
|
||||
header->setHash(primaryIndex->calculateHash(trx, keySlice));
|
||||
header->setVPackFromMarker(marker);
|
||||
|
||||
// insert into primary index
|
||||
void const* result = nullptr;
|
||||
int res = primaryIndex->insertKey(trx, header, &result);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
document->_masterPointers.release(header);
|
||||
LOG(ERR) << "inserting document into primary index failed with error: " << TRI_errno_string(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
++document->_numberDocuments;
|
||||
|
||||
// update the datafile info
|
||||
state->_dfi->numberAlive++;
|
||||
state->_dfi->sizeAlive += DatafileHelper::AlignedMarkerSize<int64_t>(marker);
|
||||
}
|
||||
|
||||
// it is an update, but only if found has a smaller revision identifier
|
||||
else {
|
||||
// save the old data
|
||||
TRI_doc_mptr_t oldData = *found;
|
||||
|
||||
// update the header info
|
||||
found->setFid(fid, false); // when we're here, we're looking at a datafile
|
||||
found->setVPackFromMarker(marker);
|
||||
|
||||
// update the datafile info
|
||||
DatafileStatisticsContainer* dfi;
|
||||
if (oldData.getFid() == state->_fid) {
|
||||
dfi = state->_dfi;
|
||||
} else {
|
||||
dfi = FindDatafileStats(state, oldData.getFid());
|
||||
}
|
||||
|
||||
if (oldData.vpack() != nullptr) {
|
||||
int64_t size = static_cast<int64_t>(oldData.markerSize());
|
||||
|
||||
dfi->numberAlive--;
|
||||
dfi->sizeAlive -= DatafileHelper::AlignedSize<int64_t>(size);
|
||||
dfi->numberDead++;
|
||||
dfi->sizeDead += DatafileHelper::AlignedSize<int64_t>(size);
|
||||
}
|
||||
|
||||
state->_dfi->numberAlive++;
|
||||
state->_dfi->sizeAlive += DatafileHelper::AlignedMarkerSize<int64_t>(marker);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief process a deletion marker when opening a collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int OpenIteratorHandleDeletionMarker(TRI_df_marker_t const* marker,
|
||||
TRI_datafile_t* datafile,
|
||||
open_iterator_state_t* state) {
|
||||
TRI_document_collection_t* document = state->_document;
|
||||
arangodb::Transaction* trx = state->_trx;
|
||||
|
||||
VPackSlice const slice(reinterpret_cast<char const*>(marker) + DatafileHelper::VPackOffset(TRI_DF_MARKER_VPACK_REMOVE));
|
||||
|
||||
VPackSlice keySlice;
|
||||
TRI_voc_rid_t revisionId;
|
||||
|
||||
Transaction::extractKeyAndRevFromDocument(slice, keySlice, revisionId);
|
||||
|
||||
document->setLastRevision(revisionId, false);
|
||||
VPackValueLength length;
|
||||
char const* p = keySlice.getString(length);
|
||||
document->_keyGenerator->track(p, length);
|
||||
|
||||
++state->_deletions;
|
||||
|
||||
if (state->_fid != datafile->_fid) {
|
||||
// update the state
|
||||
state->_fid = datafile->_fid;
|
||||
state->_dfi = FindDatafileStats(state, datafile->_fid);
|
||||
}
|
||||
|
||||
// no primary index lock required here because we are the only ones reading
|
||||
// from the index ATM
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
TRI_doc_mptr_t* found = primaryIndex->lookupKey(trx, keySlice);
|
||||
|
||||
// it is a new entry, so we missed the create
|
||||
if (found == nullptr) {
|
||||
// update the datafile info
|
||||
state->_dfi->numberDeletions++;
|
||||
}
|
||||
|
||||
// it is a real delete
|
||||
else {
|
||||
// update the datafile info
|
||||
DatafileStatisticsContainer* dfi;
|
||||
|
||||
if (found->getFid() == state->_fid) {
|
||||
dfi = state->_dfi;
|
||||
} else {
|
||||
dfi = FindDatafileStats(state, found->getFid());
|
||||
}
|
||||
|
||||
TRI_ASSERT(found->vpack() != nullptr);
|
||||
|
||||
int64_t size = DatafileHelper::AlignedSize<int64_t>(found->markerSize());
|
||||
|
||||
dfi->numberAlive--;
|
||||
dfi->sizeAlive -= DatafileHelper::AlignedSize<int64_t>(size);
|
||||
dfi->numberDead++;
|
||||
dfi->sizeDead += DatafileHelper::AlignedSize<int64_t>(size);
|
||||
state->_dfi->numberDeletions++;
|
||||
|
||||
document->deletePrimaryIndex(trx, found);
|
||||
--document->_numberDocuments;
|
||||
|
||||
// free the header
|
||||
document->_masterPointers.release(found);
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief iterator for open
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool OpenIterator(TRI_df_marker_t const* marker, void* data,
|
||||
TRI_datafile_t* datafile) {
|
||||
TRI_document_collection_t* document =
|
||||
static_cast<open_iterator_state_t*>(data)->_document;
|
||||
TRI_voc_tick_t const tick = marker->getTick();
|
||||
TRI_df_marker_type_t const type = marker->getType();
|
||||
|
||||
int res;
|
||||
|
||||
if (type == TRI_DF_MARKER_VPACK_DOCUMENT) {
|
||||
res = OpenIteratorHandleDocumentMarker(marker, datafile,
|
||||
static_cast<open_iterator_state_t*>(data));
|
||||
|
||||
if (datafile->_dataMin == 0) {
|
||||
datafile->_dataMin = tick;
|
||||
}
|
||||
|
||||
if (tick > datafile->_dataMax) {
|
||||
datafile->_dataMax = tick;
|
||||
}
|
||||
} else if (type == TRI_DF_MARKER_VPACK_REMOVE) {
|
||||
res = OpenIteratorHandleDeletionMarker(marker, datafile,
|
||||
static_cast<open_iterator_state_t*>(data));
|
||||
} else {
|
||||
if (type == TRI_DF_MARKER_HEADER) {
|
||||
// ensure there is a datafile info entry for each datafile of the
|
||||
// collection
|
||||
FindDatafileStats(static_cast<open_iterator_state_t*>(data), datafile->_fid);
|
||||
}
|
||||
|
||||
LOG(TRACE) << "skipping marker type " << TRI_NameMarkerDatafile(marker);
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
if (datafile->_tickMin == 0) {
|
||||
datafile->_tickMin = tick;
|
||||
}
|
||||
|
||||
if (tick > datafile->_tickMax) {
|
||||
datafile->_tickMax = tick;
|
||||
}
|
||||
|
||||
if (tick > document->_tickMax) {
|
||||
if (type != TRI_DF_MARKER_HEADER &&
|
||||
type != TRI_DF_MARKER_FOOTER &&
|
||||
type != TRI_DF_MARKER_COL_HEADER &&
|
||||
type != TRI_DF_MARKER_PROLOGUE) {
|
||||
document->_tickMax = tick;
|
||||
}
|
||||
}
|
||||
|
||||
return (res == TRI_ERROR_NO_ERROR);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a document collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool InitDocumentCollection(TRI_document_collection_t* document) {
|
||||
// create primary index
|
||||
std::unique_ptr<arangodb::Index> primaryIndex(
|
||||
new arangodb::PrimaryIndex(document));
|
||||
|
||||
try {
|
||||
document->addIndex(primaryIndex.get());
|
||||
primaryIndex.release();
|
||||
} catch (...) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// create edges index
|
||||
if (document->_info.type() == TRI_COL_TYPE_EDGE) {
|
||||
TRI_idx_iid_t iid = document->_info.id();
|
||||
if (document->_info.planId() > 0) {
|
||||
iid = document->_info.planId();
|
||||
}
|
||||
|
||||
try {
|
||||
std::unique_ptr<arangodb::Index> edgeIndex(
|
||||
new arangodb::EdgeIndex(iid, document));
|
||||
|
||||
document->addIndex(edgeIndex.get());
|
||||
edgeIndex.release();
|
||||
} catch (...) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief iterate all markers of the collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int IterateMarkersCollection(arangodb::Transaction* trx,
|
||||
TRI_collection_t* collection) {
|
||||
auto document = reinterpret_cast<TRI_document_collection_t*>(collection);
|
||||
|
||||
// initialize state for iteration
|
||||
open_iterator_state_t openState(document, collection->_vocbase);
|
||||
|
||||
if (collection->_info.initialCount() != -1) {
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
|
||||
int res = primaryIndex->resize(
|
||||
trx, static_cast<size_t>(collection->_info.initialCount() * 1.1));
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
|
||||
openState._initialCount = collection->_info.initialCount();
|
||||
}
|
||||
|
||||
// read all documents and fill primary index
|
||||
auto cb = [&openState](TRI_df_marker_t const* marker, TRI_datafile_t* datafile) -> bool {
|
||||
return OpenIterator(marker, &openState, datafile);
|
||||
};
|
||||
|
||||
collection->iterateDatafiles(cb);
|
||||
|
||||
LOG(TRACE) << "found " << openState._documents << " document markers, " << openState._deletions << " deletion markers for collection '" << collection->_info.name() << "'";
|
||||
|
||||
// update the real statistics for the collection
|
||||
try {
|
||||
for (auto& it : openState._stats) {
|
||||
document->_datafileStatistics.create(it.first, *(it.second));
|
||||
}
|
||||
} catch (basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
} catch (...) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* TRI_CreateDocumentCollection(
|
||||
TRI_vocbase_t* vocbase, VocbaseCollectionInfo& parameters,
|
||||
TRI_voc_cid_t cid) {
|
||||
if (cid > 0) {
|
||||
TRI_UpdateTickServer(cid);
|
||||
} else {
|
||||
cid = TRI_NewTickServer();
|
||||
}
|
||||
|
||||
parameters.setCollectionId(cid);
|
||||
|
||||
// check if we can generate the key generator
|
||||
std::shared_ptr<arangodb::velocypack::Buffer<uint8_t> const> buffer =
|
||||
parameters.keyOptions();
|
||||
|
||||
VPackSlice slice;
|
||||
if (buffer != nullptr) {
|
||||
slice = VPackSlice(buffer->data());
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyGenerator> keyGenerator(KeyGenerator::factory(slice));
|
||||
|
||||
if (keyGenerator == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_ARANGO_INVALID_KEY_GENERATOR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto document = std::make_unique<TRI_document_collection_t>(vocbase);
|
||||
document->_keyGenerator.reset(keyGenerator.release());
|
||||
|
||||
TRI_collection_t* collection =
|
||||
TRI_CreateCollection(vocbase, document.get(), parameters);
|
||||
|
||||
if (collection == nullptr) {
|
||||
LOG(ERR) << "cannot create document collection";
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create document collection
|
||||
if (false == InitDocumentCollection(document.get())) {
|
||||
LOG(ERR) << "cannot initialize document collection";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// save the parameters block (within create, no need to lock)
|
||||
bool doSync = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database")->forceSyncProperties();
|
||||
int res = parameters.saveToFile(collection->path(), doSync);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG(ERR) << "cannot save collection parameters in directory '" << collection->path() << "': '" << TRI_last_error() << "'";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// remove the temporary file
|
||||
std::string tmpfile = collection->path() + ".tmp";
|
||||
TRI_UnlinkFile(tmpfile.c_str());
|
||||
|
||||
return document.release();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief opens an existing collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_document_collection_t* TRI_OpenDocumentCollection(TRI_vocbase_t* vocbase,
|
||||
TRI_vocbase_col_t* col,
|
||||
bool ignoreErrors) {
|
||||
// first open the document collection
|
||||
auto document = std::make_unique<TRI_document_collection_t>(vocbase);
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
double start = TRI_microtime();
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE)
|
||||
<< "open-document-collection { collection: " << vocbase->name() << "/"
|
||||
<< col->name() << " }";
|
||||
|
||||
int res = document->open(col->path(), ignoreErrors);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG(ERR) << "cannot open document collection from path '" << col->path() << "'";
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create document collection
|
||||
if (false == InitDocumentCollection(document.get())) {
|
||||
LOG(ERR) << "cannot initialize document collection";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// check if we can generate the key generator
|
||||
std::shared_ptr<arangodb::velocypack::Buffer<uint8_t> const> buffer = document->_info.keyOptions();
|
||||
|
||||
VPackSlice slice;
|
||||
if (buffer.get() != nullptr) {
|
||||
slice = VPackSlice(buffer->data());
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyGenerator> keyGenerator(KeyGenerator::factory(slice));
|
||||
|
||||
if (keyGenerator == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_ARANGO_INVALID_KEY_GENERATOR);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
document->_keyGenerator.reset(keyGenerator.release());
|
||||
|
||||
arangodb::SingleCollectionTransaction trx(
|
||||
arangodb::StandaloneTransactionContext::Create(vocbase),
|
||||
document->_info.id(), TRI_TRANSACTION_WRITE);
|
||||
|
||||
// build the primary index
|
||||
res = TRI_ERROR_INTERNAL;
|
||||
|
||||
try {
|
||||
double start = TRI_microtime();
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE)
|
||||
<< "iterate-markers { collection: " << vocbase->name() << "/"
|
||||
<< document->_info.name() << " }";
|
||||
|
||||
// iterate over all markers of the collection
|
||||
res = IterateMarkersCollection(&trx, document.get());
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE) << "[timer] " << Logger::FIXED(TRI_microtime() - start) << " s, iterate-markers { collection: " << vocbase->name() << "/" << document->_info.name() << " }";
|
||||
} catch (arangodb::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
} catch (std::bad_alloc const&) {
|
||||
res = TRI_ERROR_OUT_OF_MEMORY;
|
||||
} catch (...) {
|
||||
res = TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG(ERR) << "cannot iterate data of document collection";
|
||||
TRI_set_errno(res);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// build the indexes meta-data, but do not fill the indexes yet
|
||||
{
|
||||
auto old = document->useSecondaryIndexes();
|
||||
|
||||
// turn filling of secondary indexes off. we're now only interested in getting
|
||||
// the indexes' definition. we'll fill them below ourselves.
|
||||
document->useSecondaryIndexes(false);
|
||||
|
||||
try {
|
||||
document->detectIndexes(&trx);
|
||||
document->useSecondaryIndexes(old);
|
||||
} catch (...) {
|
||||
document->useSecondaryIndexes(old);
|
||||
LOG(ERR) << "cannot initialize collection indexes";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!arangodb::wal::LogfileManager::instance()->isInRecovery()) {
|
||||
// build the index structures, and fill the indexes
|
||||
document->fillIndexes(&trx, col);
|
||||
}
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::PERFORMANCE)
|
||||
<< "[timer] " << Logger::FIXED(TRI_microtime() - start)
|
||||
<< " s, open-document-collection { collection: " << vocbase->name() << "/"
|
||||
<< document->_info.name() << " }";
|
||||
|
||||
return document.release();
|
||||
}
|
||||
|
||||
/// @brief closes an open collection
|
||||
int TRI_CloseDocumentCollection(TRI_document_collection_t* document,
|
||||
bool updateStats) {
|
||||
auto primaryIndex = document->primaryIndex();
|
||||
auto idxSize = primaryIndex->size();
|
||||
|
||||
if (!document->_info.deleted() &&
|
||||
document->_info.initialCount() != static_cast<int64_t>(idxSize)) {
|
||||
document->_info.updateCount(idxSize);
|
||||
|
||||
bool doSync = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database")->forceSyncProperties();
|
||||
// Ignore the error?
|
||||
document->_info.saveToFile(document->path(), doSync);
|
||||
}
|
||||
|
||||
// closes all open compactors, journals, datafiles
|
||||
document->close();
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_VOC_BASE_DOCUMENT_COLLECTION_H
|
||||
#define ARANGOD_VOC_BASE_DOCUMENT_COLLECTION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
#include "Basics/StringRef.h"
|
||||
#include "Cluster/ClusterInfo.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/DatafileStatistics.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/MasterPointer.h"
|
||||
#include "VocBase/MasterPointers.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
#include "Wal/Marker.h"
|
||||
|
||||
struct TRI_vocbase_t;
|
||||
|
||||
namespace arangodb {
|
||||
class Index;
|
||||
struct OperationOptions;
|
||||
class Transaction;
|
||||
namespace velocypack {
|
||||
class Builder;
|
||||
class Slice;
|
||||
}
|
||||
namespace wal {
|
||||
struct DocumentOperation;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief document collection with global read-write lock
|
||||
///
|
||||
/// A document collection is a collection with a single read-write lock. This
|
||||
/// lock is used to coordinate the read and write transactions.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct TRI_document_collection_t : public TRI_collection_t {
|
||||
TRI_document_collection_t(TRI_vocbase_t* vocbase) : TRI_collection_t(vocbase) {}
|
||||
};
|
||||
|
||||
/// @brief creates a new collection
|
||||
TRI_document_collection_t* TRI_CreateDocumentCollection(
|
||||
TRI_vocbase_t*, arangodb::VocbaseCollectionInfo&,
|
||||
TRI_voc_cid_t);
|
||||
|
||||
/// @brief opens an existing collection
|
||||
TRI_document_collection_t* TRI_OpenDocumentCollection(TRI_vocbase_t*,
|
||||
TRI_vocbase_col_t*, bool);
|
||||
|
||||
/// @brief closes an open collection
|
||||
int TRI_CloseDocumentCollection(TRI_document_collection_t*, bool);
|
||||
|
||||
#endif
|
|
@ -40,7 +40,6 @@
|
|||
#include "StorageEngine/EngineSelectorFeature.h"
|
||||
#include "StorageEngine/StorageEngine.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "VocBase/collection.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/datafile.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "Wal/Logfile.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
@ -146,7 +146,7 @@ static void IterateDatafiles(std::vector<TRI_datafile_t*> const& datafiles,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static std::vector<df_entry_t> GetRangeDatafiles(
|
||||
TRI_document_collection_t* document, TRI_voc_tick_t dataMin,
|
||||
TRI_collection_t* document, TRI_voc_tick_t dataMin,
|
||||
TRI_voc_tick_t dataMax) {
|
||||
LOG(TRACE) << "getting datafiles in data range " << dataMin << " - " << dataMax;
|
||||
|
||||
|
@ -457,7 +457,7 @@ static bool MustReplicateWalMarker(
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int DumpCollection(TRI_replication_dump_t* dump,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_collection_t* document,
|
||||
TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId,
|
||||
TRI_voc_tick_t dataMin, TRI_voc_tick_t dataMax,
|
||||
bool withTicks) {
|
||||
|
@ -617,7 +617,7 @@ int TRI_DumpCollectionReplication(TRI_replication_dump_t* dump,
|
|||
auto customTypeHandler = dump->_transactionContext->orderCustomTypeHandler();
|
||||
dump->_vpackOptions.customTypeHandler = customTypeHandler.get();
|
||||
|
||||
TRI_document_collection_t* document = col->_collection;
|
||||
TRI_collection_t* document = col->_collection;
|
||||
|
||||
// create a barrier so the underlying collection is not unloaded
|
||||
auto b = document->ditches()->createReplicationDitch(__FILE__, __LINE__);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "Wal/DocumentOperation.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "Basics/WriteLocker.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/hashes.h"
|
||||
#include "Basics/locks.h"
|
||||
#include "Basics/memory-map.h"
|
||||
#include "Basics/threads.h"
|
||||
|
@ -54,8 +53,8 @@
|
|||
#include "Utils/CursorRepository.h"
|
||||
#include "V8Server/v8-user-structures.h"
|
||||
#include "VocBase/Ditch.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/compactor.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/replication-applier.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
@ -271,7 +270,7 @@ static bool UnloadCollectionCallback(TRI_collection_t* col, void* data) {
|
|||
return false;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
|
@ -317,7 +316,7 @@ bool TRI_vocbase_t::DropCollectionCallback(TRI_collection_t* col, void* data) {
|
|||
// .............................................................................
|
||||
|
||||
if (collection->_collection != nullptr) {
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
int res = TRI_CloseDocumentCollection(document, false);
|
||||
|
||||
|
@ -469,7 +468,7 @@ TRI_vocbase_col_t* TRI_vocbase_t::createCollectionWorker(
|
|||
}
|
||||
|
||||
// ok, construct the collection
|
||||
TRI_document_collection_t* document = nullptr;
|
||||
TRI_collection_t* document = nullptr;
|
||||
try {
|
||||
document = TRI_CreateDocumentCollection(this, parameters, cid);
|
||||
} catch (...) {
|
||||
|
@ -733,7 +732,7 @@ int TRI_vocbase_t::loadCollection(TRI_vocbase_col_t* collection,
|
|||
ignoreDatafileErrors = DatabaseFeature::DATABASE->ignoreDatafileErrors();
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = nullptr;
|
||||
TRI_collection_t* document = nullptr;
|
||||
try {
|
||||
document = TRI_OpenDocumentCollection(this, collection, ignoreDatafileErrors);
|
||||
} catch (...) {
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "velocypack/velocypack-aliases.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
struct TRI_document_collection_t;
|
||||
class TRI_replication_applier_t;
|
||||
class TRI_vocbase_col_t;
|
||||
|
||||
|
@ -537,7 +536,7 @@ class TRI_vocbase_col_t {
|
|||
arangodb::basics::ReadWriteLock _lock; // lock protecting the status and name
|
||||
|
||||
TRI_vocbase_col_status_e _status; // status of the collection
|
||||
TRI_document_collection_t* _collection; // NULL or pointer to loaded collection
|
||||
TRI_collection_t* _collection; // NULL or pointer to loaded collection
|
||||
std::string const _dbName; // name of the database
|
||||
std::string _name; // name of the collection
|
||||
std::string const _path; // storage path
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "VocBase/DatafileHelper.h"
|
||||
#include "VocBase/DatafileStatistics.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "Wal/Logfile.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
|
@ -564,7 +564,7 @@ size_t CollectorThread::numQueuedOperations() {
|
|||
/// @brief process a single marker in collector step 2
|
||||
void CollectorThread::processCollectionMarker(
|
||||
arangodb::SingleCollectionTransaction& trx,
|
||||
TRI_document_collection_t* document, CollectorCache* cache,
|
||||
TRI_collection_t* document, CollectorCache* cache,
|
||||
CollectorOperation const& operation) {
|
||||
auto const* walMarker = reinterpret_cast<TRI_df_marker_t const*>(operation.walPosition);
|
||||
TRI_ASSERT(walMarker != nullptr);
|
||||
|
@ -635,7 +635,7 @@ int CollectorThread::processCollectionOperations(CollectorCache* cache) {
|
|||
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
// first try to read-lock the compactor-lock, afterwards try to write-lock the
|
||||
// collection
|
||||
|
@ -860,7 +860,7 @@ int CollectorThread::transferMarkers(Logfile* logfile,
|
|||
TRI_vocbase_col_t* collection = collectionGuard.collection();
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
LOG_TOPIC(TRACE, Logger::COLLECTOR) << "collector transferring markers for '"
|
||||
|
@ -910,7 +910,7 @@ int CollectorThread::transferMarkers(Logfile* logfile,
|
|||
|
||||
/// @brief transfer markers into a collection, actual work
|
||||
/// the collection must have been prepared to call this function
|
||||
int CollectorThread::executeTransferMarkers(TRI_document_collection_t* document,
|
||||
int CollectorThread::executeTransferMarkers(TRI_collection_t* document,
|
||||
CollectorCache* cache,
|
||||
OperationsType const& operations) {
|
||||
// used only for crash / recovery tests
|
||||
|
@ -1020,7 +1020,7 @@ int CollectorThread::queueOperations(arangodb::wal::Logfile* logfile,
|
|||
|
||||
/// @brief update a collection's datafile information
|
||||
int CollectorThread::updateDatafileStatistics(
|
||||
TRI_document_collection_t* document, CollectorCache* cache) {
|
||||
TRI_collection_t* document, CollectorCache* cache) {
|
||||
// iterate over all datafile infos and update the collection's datafile stats
|
||||
for (auto it = cache->dfi.begin(); it != cache->dfi.end();
|
||||
/* no hoisting */) {
|
||||
|
@ -1037,7 +1037,7 @@ int CollectorThread::updateDatafileStatistics(
|
|||
|
||||
/// @brief sync all journals of a collection
|
||||
int CollectorThread::syncJournalCollection(
|
||||
TRI_document_collection_t* document) {
|
||||
TRI_collection_t* document) {
|
||||
TRI_IF_FAILURE("CollectorThread::syncDatafileCollection") {
|
||||
return TRI_ERROR_DEBUG;
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ int CollectorThread::syncJournalCollection(
|
|||
|
||||
/// @brief get the next position for a marker of the specified size
|
||||
char* CollectorThread::nextFreeMarkerPosition(
|
||||
TRI_document_collection_t* document, TRI_voc_tick_t tick,
|
||||
TRI_collection_t* document, TRI_voc_tick_t tick,
|
||||
TRI_df_marker_type_t type, TRI_voc_size_t size, CollectorCache* cache) {
|
||||
|
||||
// align the specified size
|
||||
|
@ -1105,7 +1105,7 @@ char* CollectorThread::nextFreeMarkerPosition(
|
|||
/// @brief set the tick of a marker and calculate its CRC value
|
||||
void CollectorThread::finishMarker(char const* walPosition,
|
||||
char* datafilePosition,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_collection_t* document,
|
||||
TRI_voc_tick_t tick, CollectorCache* cache) {
|
||||
TRI_df_marker_t* marker =
|
||||
reinterpret_cast<TRI_df_marker_t*>(datafilePosition);
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
#include "VocBase/voc-types.h"
|
||||
#include "Wal/Logfile.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
struct TRI_datafile_t;
|
||||
struct TRI_df_marker_t;
|
||||
struct TRI_document_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
namespace wal {
|
||||
|
@ -175,7 +175,7 @@ class CollectorThread : public Thread {
|
|||
/// @brief process a single marker in collector step 2
|
||||
void processCollectionMarker(
|
||||
arangodb::SingleCollectionTransaction&,
|
||||
TRI_document_collection_t*, CollectorCache*, CollectorOperation const&);
|
||||
TRI_collection_t*, CollectorCache*, CollectorOperation const&);
|
||||
|
||||
/// @brief return the number of queued operations
|
||||
size_t numQueuedOperations();
|
||||
|
@ -197,25 +197,25 @@ class CollectorThread : public Thread {
|
|||
int64_t, OperationsType const&);
|
||||
|
||||
/// @brief transfer markers into a collection
|
||||
int executeTransferMarkers(TRI_document_collection_t*, CollectorCache*,
|
||||
int executeTransferMarkers(TRI_collection_t*, CollectorCache*,
|
||||
OperationsType const&);
|
||||
|
||||
/// @brief insert the collect operations into a per-collection queue
|
||||
int queueOperations(arangodb::wal::Logfile*, CollectorCache*&);
|
||||
|
||||
/// @brief update a collection's datafile information
|
||||
int updateDatafileStatistics(TRI_document_collection_t*, CollectorCache*);
|
||||
int updateDatafileStatistics(TRI_collection_t*, CollectorCache*);
|
||||
|
||||
/// @brief sync the journal of a collection
|
||||
int syncJournalCollection(struct TRI_document_collection_t*);
|
||||
int syncJournalCollection(TRI_collection_t*);
|
||||
|
||||
/// @brief get the next free position for a new marker of the specified size
|
||||
char* nextFreeMarkerPosition(struct TRI_document_collection_t*,
|
||||
char* nextFreeMarkerPosition(TRI_collection_t*,
|
||||
TRI_voc_tick_t, TRI_df_marker_type_t,
|
||||
TRI_voc_size_t, CollectorCache*);
|
||||
|
||||
/// @brief set the tick of a marker and calculate its CRC value
|
||||
void finishMarker(char const*, char*, struct TRI_document_collection_t*,
|
||||
void finishMarker(char const*, char*, TRI_collection_t*,
|
||||
TRI_voc_tick_t, CollectorCache*);
|
||||
|
||||
private:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#define ARANGOD_WAL_DOCUMENT_OPERATION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/MasterPointers.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
#include "Wal/Marker.h"
|
||||
|
|
|
@ -206,7 +206,7 @@ TRI_vocbase_col_t* RecoverState::useCollection(TRI_vocbase_t* vocbase,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
// disable secondary indexes for the moment
|
||||
|
@ -221,7 +221,7 @@ TRI_vocbase_col_t* RecoverState::useCollection(TRI_vocbase_t* vocbase,
|
|||
/// the collection will be opened after this call and inserted into a local
|
||||
/// cache for faster lookups
|
||||
/// returns nullptr if the collection does not exist
|
||||
TRI_document_collection_t* RecoverState::getCollection(
|
||||
TRI_collection_t* RecoverState::getCollection(
|
||||
TRI_voc_tick_t databaseId, TRI_voc_cid_t collectionId) {
|
||||
TRI_vocbase_t* vocbase = useDatabase(databaseId);
|
||||
|
||||
|
@ -238,7 +238,7 @@ TRI_document_collection_t* RecoverState::getCollection(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
return document;
|
||||
|
@ -635,7 +635,7 @@ bool RecoverState::ReplayMarker(TRI_df_marker_t const* marker, void* data,
|
|||
return true;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document =
|
||||
TRI_collection_t* document =
|
||||
state->getCollection(databaseId, collectionId);
|
||||
|
||||
if (document == nullptr) {
|
||||
|
@ -685,7 +685,7 @@ bool RecoverState::ReplayMarker(TRI_df_marker_t const* marker, void* data,
|
|||
return true;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document =
|
||||
TRI_collection_t* document =
|
||||
state->getCollection(databaseId, collectionId);
|
||||
|
||||
if (document == nullptr) {
|
||||
|
@ -922,7 +922,7 @@ bool RecoverState::ReplayMarker(TRI_df_marker_t const* marker, void* data,
|
|||
return true;
|
||||
}
|
||||
|
||||
TRI_document_collection_t* document =
|
||||
TRI_collection_t* document =
|
||||
state->getCollection(databaseId, collectionId);
|
||||
if (document == nullptr) {
|
||||
// if the underlying collection gone, we can go on
|
||||
|
@ -1145,7 +1145,7 @@ int RecoverState::fillIndexes() {
|
|||
for (auto it = openedCollections.begin(); it != openedCollections.end();
|
||||
++it) {
|
||||
TRI_vocbase_col_t* collection = (*it).second;
|
||||
TRI_document_collection_t* document = collection->_collection;
|
||||
TRI_collection_t* document = collection->_collection;
|
||||
|
||||
TRI_ASSERT(document != nullptr);
|
||||
|
||||
|
|
|
@ -27,13 +27,14 @@
|
|||
#include "Basics/Common.h"
|
||||
#include "Utils/SingleCollectionTransaction.h"
|
||||
#include "VocBase/datafile.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/ticks.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "Wal/Logfile.h"
|
||||
#include "Wal/Marker.h"
|
||||
|
||||
struct TRI_collection_t;
|
||||
|
||||
namespace arangodb {
|
||||
class DatabaseFeature;
|
||||
|
||||
|
@ -124,7 +125,7 @@ struct RecoverState {
|
|||
/// the collection will be opened after this call and inserted into a local
|
||||
/// cache for faster lookups
|
||||
/// returns nullptr if the collection does not exist
|
||||
TRI_document_collection_t* getCollection(TRI_voc_tick_t, TRI_voc_cid_t);
|
||||
TRI_collection_t* getCollection(TRI_voc_tick_t, TRI_voc_cid_t);
|
||||
|
||||
/// @brief executes a single operation inside a transaction
|
||||
int executeSingleOperation(
|
||||
|
|
Loading…
Reference in New Issue