From b543680ccaeb15739d0fc7b2da0c25a352f212b6 Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Wed, 16 Dec 2015 11:42:59 +0100 Subject: [PATCH] Adapted resthandler to class version of TRI_col_info_t --- arangod/RestHandler/RestDocumentHandler.cpp | 6 ++-- arangod/RestHandler/RestEdgeHandler.cpp | 2 +- arangod/RestHandler/RestImportHandler.cpp | 4 +-- .../RestHandler/RestReplicationHandler.cpp | 34 +++++++++++-------- arangod/RestHandler/RestVocbaseBaseHandler.h | 4 +-- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/arangod/RestHandler/RestDocumentHandler.cpp b/arangod/RestHandler/RestDocumentHandler.cpp index cb2e5fc76c..98b39a1482 100644 --- a/arangod/RestHandler/RestDocumentHandler.cpp +++ b/arangod/RestHandler/RestDocumentHandler.cpp @@ -337,7 +337,7 @@ bool RestDocumentHandler::createDocument () { return false; } - if (trx.documentCollection()->_info._type != TRI_COL_TYPE_DOCUMENT) { + if (trx.documentCollection()->_info.type() != TRI_COL_TYPE_DOCUMENT) { // check if we are inserting with the DOCUMENT handler into a non-DOCUMENT collection generateError(HttpResponse::BAD, TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID); return false; @@ -799,7 +799,7 @@ bool RestDocumentHandler::readAllDocuments () { res = trx.read(ids); - TRI_col_type_e type = trx.documentCollection()->_info._type; + TRI_col_type_e type = trx.documentCollection()->_info.type(); res = trx.finish(res); @@ -1455,7 +1455,7 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) { TRI_ASSERT(document != nullptr); auto shaper = document->getShaper(); // PROTECTED by trx here - string const&& cidString = StringUtils::itoa(document->_info._planId); + string const&& cidString = StringUtils::itoa(document->_info.planId()); if (trx.orderDitch(trx.trxCollection()) == nullptr) { generateTransactionError(collectionName, TRI_ERROR_OUT_OF_MEMORY); diff --git a/arangod/RestHandler/RestEdgeHandler.cpp b/arangod/RestHandler/RestEdgeHandler.cpp index 4790b1f1fc..be04f820ca 100644 --- a/arangod/RestHandler/RestEdgeHandler.cpp +++ b/arangod/RestHandler/RestEdgeHandler.cpp @@ -240,7 +240,7 @@ bool RestEdgeHandler::createDocument () { TRI_document_collection_t* document = trx.documentCollection(); - if (document->_info._type != TRI_COL_TYPE_EDGE) { + if (document->_info.type() != TRI_COL_TYPE_EDGE) { // check if we are inserting with the EDGE handler into a non-EDGE collection generateError(HttpResponse::BAD, TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID); return false; diff --git a/arangod/RestHandler/RestImportHandler.cpp b/arangod/RestHandler/RestImportHandler.cpp index 8e51682fbe..55ac0cc238 100644 --- a/arangod/RestHandler/RestImportHandler.cpp +++ b/arangod/RestHandler/RestImportHandler.cpp @@ -799,7 +799,7 @@ bool RestImportHandler::createFromJson (string const& type) { } TRI_document_collection_t* document = trx.documentCollection(); - bool const isEdgeCollection = (document->_info._type == TRI_COL_TYPE_EDGE); + bool const isEdgeCollection = (document->_info.type() == TRI_COL_TYPE_EDGE); trx.lockWrite(); @@ -1331,7 +1331,7 @@ bool RestImportHandler::createFromKeyValueList () { } TRI_document_collection_t* document = trx.documentCollection(); - bool const isEdgeCollection = (document->_info._type == TRI_COL_TYPE_EDGE); + bool const isEdgeCollection = (document->_info.type() == TRI_COL_TYPE_EDGE); trx.lockWrite(); diff --git a/arangod/RestHandler/RestReplicationHandler.cpp b/arangod/RestHandler/RestReplicationHandler.cpp index 7d2caed778..4b2bbca35b 100644 --- a/arangod/RestHandler/RestReplicationHandler.cpp +++ b/arangod/RestHandler/RestReplicationHandler.cpp @@ -1784,24 +1784,25 @@ int RestReplicationHandler::createCollection (VPackSlice const& slice, return TRI_ERROR_NO_ERROR; } - VPackSlice const keyOptions = slice.get("keyOptions"); - - TRI_col_info_t params; + VocbaseCollectionInfo params (_vocbase, + name.c_str(), + slice); + /* TRI_InitCollectionInfo(_vocbase, ¶ms, name.c_str(), + slice, type, triagens::basics::VelocyPackHelper::getNumericValue(slice, "maximalSize", TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE), // static_cast(triagens::basics::VelocyPackHelper::getNumericValue(slice, "maximalSize", static_cast(TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE)), keyOptions); - - params._doCompact = triagens::basics::VelocyPackHelper::getBooleanValue(slice, "doCompact", true); - params._waitForSync = triagens::basics::VelocyPackHelper::getBooleanValue(slice, "waitForSync", _vocbase->_settings.defaultWaitForSync); - params._isVolatile = triagens::basics::VelocyPackHelper::getBooleanValue(slice, "isVolatile", false); - params._isSystem = (name[0] == '_'); - params._indexBuckets = triagens::basics::VelocyPackHelper::getNumericValue(slice, "indexBuckets", TRI_DEFAULT_INDEX_BUCKETS); - params._planId = 0; - + */ + /* Temporary ASSERTS to prove correctness of new constructor */ + TRI_ASSERT(params.doCompact() == triagens::basics::VelocyPackHelper::getBooleanValue(slice, "doCompact", true)); + TRI_ASSERT(params.waitForSync() == triagens::basics::VelocyPackHelper::getBooleanValue(slice, "waitForSync", _vocbase->_settings.defaultWaitForSync)); + TRI_ASSERT(params.isVolatile() == triagens::basics::VelocyPackHelper::getBooleanValue(slice, "isVolatile", false)); + TRI_ASSERT(params.isSystem() == (name[0] == '_')); + TRI_ASSERT(params.indexBuckets() == triagens::basics::VelocyPackHelper::getNumericValue(slice, "indexBuckets", TRI_DEFAULT_INDEX_BUCKETS)); TRI_voc_cid_t planId = 0; VPackSlice const planIdSlice = slice.get("planId"); if (planIdSlice.isNumber()) { @@ -1813,7 +1814,10 @@ int RestReplicationHandler::createCollection (VPackSlice const& slice, } if (planId > 0) { - params._planId = planId; + TRI_ASSERT(params.planId() == planId); + } + else { + TRI_ASSERT(params.planId() == 0); } if (cid > 0) { @@ -2297,7 +2301,7 @@ int RestReplicationHandler::processRestoreIndexes (VPackSlice const& collection, TRI_document_collection_t* document = guard.collection()->_collection; - SingleCollectionWriteTransaction trx(new StandaloneTransactionContext(), _vocbase, document->_info._cid); + SingleCollectionWriteTransaction trx(new StandaloneTransactionContext(), _vocbase, document->_info.id()); int res = trx.begin(); @@ -2454,7 +2458,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (triagens::arango::Transac if (type == REPLICATION_MARKER_EDGE) { // edge - if (document->_info._type != TRI_COL_TYPE_EDGE) { + if (document->_info.type() != TRI_COL_TYPE_EDGE) { res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID; errorMsg = "expecting edge collection, got document collection"; } @@ -2485,7 +2489,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (triagens::arango::Transac } else { // document - if (document->_info._type != TRI_COL_TYPE_DOCUMENT) { + if (document->_info.type() != TRI_COL_TYPE_DOCUMENT) { res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID; errorMsg = std::string(TRI_errno_string(res)) + ": expecting document collection, got edge collection"; } diff --git a/arangod/RestHandler/RestVocbaseBaseHandler.h b/arangod/RestHandler/RestVocbaseBaseHandler.h index c08d979629..8963a78707 100644 --- a/arangod/RestHandler/RestVocbaseBaseHandler.h +++ b/arangod/RestHandler/RestVocbaseBaseHandler.h @@ -223,7 +223,7 @@ namespace triagens { statusCode = rest::HttpResponse::ACCEPTED; } - TRI_col_type_e type = trx.documentCollection()->_info._type; + TRI_col_type_e type = trx.documentCollection()->_info.type(); generate20x(statusCode, trx.resolver()->getCollectionName(cid), (TRI_voc_key_t) TRI_EXTRACT_MARKER_KEY(&mptr), mptr._rid, type); // PROTECTED by trx here } @@ -244,7 +244,7 @@ namespace triagens { statusCode = rest::HttpResponse::ACCEPTED; } - TRI_col_type_e type = trx.documentCollection()->_info._type; + TRI_col_type_e type = trx.documentCollection()->_info.type(); generate20x(statusCode, trx.resolver()->getCollectionName(cid), key, rid, type); }