1
0
Fork 0

Adapted resthandler to class version of TRI_col_info_t

This commit is contained in:
Michael Hackstein 2015-12-16 11:42:59 +01:00
parent f5bd11bda5
commit b543680cca
5 changed files with 27 additions and 23 deletions

View File

@ -337,7 +337,7 @@ bool RestDocumentHandler::createDocument () {
return false; 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 // check if we are inserting with the DOCUMENT handler into a non-DOCUMENT collection
generateError(HttpResponse::BAD, TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID); generateError(HttpResponse::BAD, TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID);
return false; return false;
@ -799,7 +799,7 @@ bool RestDocumentHandler::readAllDocuments () {
res = trx.read(ids); 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); res = trx.finish(res);
@ -1455,7 +1455,7 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
TRI_ASSERT(document != nullptr); TRI_ASSERT(document != nullptr);
auto shaper = document->getShaper(); // PROTECTED by trx here 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) { if (trx.orderDitch(trx.trxCollection()) == nullptr) {
generateTransactionError(collectionName, TRI_ERROR_OUT_OF_MEMORY); generateTransactionError(collectionName, TRI_ERROR_OUT_OF_MEMORY);

View File

@ -240,7 +240,7 @@ bool RestEdgeHandler::createDocument () {
TRI_document_collection_t* document = trx.documentCollection(); 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 // check if we are inserting with the EDGE handler into a non-EDGE collection
generateError(HttpResponse::BAD, TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID); generateError(HttpResponse::BAD, TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID);
return false; return false;

View File

@ -799,7 +799,7 @@ bool RestImportHandler::createFromJson (string const& type) {
} }
TRI_document_collection_t* document = trx.documentCollection(); 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(); trx.lockWrite();
@ -1331,7 +1331,7 @@ bool RestImportHandler::createFromKeyValueList () {
} }
TRI_document_collection_t* document = trx.documentCollection(); 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(); trx.lockWrite();

View File

@ -1784,24 +1784,25 @@ int RestReplicationHandler::createCollection (VPackSlice const& slice,
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
} }
VPackSlice const keyOptions = slice.get("keyOptions"); VocbaseCollectionInfo params (_vocbase,
name.c_str(),
TRI_col_info_t params; slice);
/*
TRI_InitCollectionInfo(_vocbase, TRI_InitCollectionInfo(_vocbase,
&params, &params,
name.c_str(), name.c_str(),
slice,
type, type,
triagens::basics::VelocyPackHelper::getNumericValue<TRI_voc_size_t>(slice, "maximalSize", TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE), triagens::basics::VelocyPackHelper::getNumericValue<TRI_voc_size_t>(slice, "maximalSize", TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE),
// static_cast<TRI_voc_size_t>(triagens::basics::VelocyPackHelper::getNumericValue<int64_t>(slice, "maximalSize", static_cast<int64_t>(TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE)), // static_cast<TRI_voc_size_t>(triagens::basics::VelocyPackHelper::getNumericValue<int64_t>(slice, "maximalSize", static_cast<int64_t>(TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE)),
keyOptions); keyOptions);
*/
params._doCompact = triagens::basics::VelocyPackHelper::getBooleanValue(slice, "doCompact", true); /* Temporary ASSERTS to prove correctness of new constructor */
params._waitForSync = triagens::basics::VelocyPackHelper::getBooleanValue(slice, "waitForSync", _vocbase->_settings.defaultWaitForSync); TRI_ASSERT(params.doCompact() == triagens::basics::VelocyPackHelper::getBooleanValue(slice, "doCompact", true));
params._isVolatile = triagens::basics::VelocyPackHelper::getBooleanValue(slice, "isVolatile", false); TRI_ASSERT(params.waitForSync() == triagens::basics::VelocyPackHelper::getBooleanValue(slice, "waitForSync", _vocbase->_settings.defaultWaitForSync));
params._isSystem = (name[0] == '_'); TRI_ASSERT(params.isVolatile() == triagens::basics::VelocyPackHelper::getBooleanValue(slice, "isVolatile", false));
params._indexBuckets = triagens::basics::VelocyPackHelper::getNumericValue<uint32_t>(slice, "indexBuckets", TRI_DEFAULT_INDEX_BUCKETS); TRI_ASSERT(params.isSystem() == (name[0] == '_'));
params._planId = 0; TRI_ASSERT(params.indexBuckets() == triagens::basics::VelocyPackHelper::getNumericValue<uint32_t>(slice, "indexBuckets", TRI_DEFAULT_INDEX_BUCKETS));
TRI_voc_cid_t planId = 0; TRI_voc_cid_t planId = 0;
VPackSlice const planIdSlice = slice.get("planId"); VPackSlice const planIdSlice = slice.get("planId");
if (planIdSlice.isNumber()) { if (planIdSlice.isNumber()) {
@ -1813,7 +1814,10 @@ int RestReplicationHandler::createCollection (VPackSlice const& slice,
} }
if (planId > 0) { if (planId > 0) {
params._planId = planId; TRI_ASSERT(params.planId() == planId);
}
else {
TRI_ASSERT(params.planId() == 0);
} }
if (cid > 0) { if (cid > 0) {
@ -2297,7 +2301,7 @@ int RestReplicationHandler::processRestoreIndexes (VPackSlice const& collection,
TRI_document_collection_t* document = guard.collection()->_collection; TRI_document_collection_t* document = guard.collection()->_collection;
SingleCollectionWriteTransaction<UINT64_MAX> trx(new StandaloneTransactionContext(), _vocbase, document->_info._cid); SingleCollectionWriteTransaction<UINT64_MAX> trx(new StandaloneTransactionContext(), _vocbase, document->_info.id());
int res = trx.begin(); int res = trx.begin();
@ -2454,7 +2458,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (triagens::arango::Transac
if (type == REPLICATION_MARKER_EDGE) { if (type == REPLICATION_MARKER_EDGE) {
// 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; res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID;
errorMsg = "expecting edge collection, got document collection"; errorMsg = "expecting edge collection, got document collection";
} }
@ -2485,7 +2489,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (triagens::arango::Transac
} }
else { else {
// document // document
if (document->_info._type != TRI_COL_TYPE_DOCUMENT) { if (document->_info.type() != TRI_COL_TYPE_DOCUMENT) {
res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID; res = TRI_ERROR_ARANGO_COLLECTION_TYPE_INVALID;
errorMsg = std::string(TRI_errno_string(res)) + ": expecting document collection, got edge collection"; errorMsg = std::string(TRI_errno_string(res)) + ": expecting document collection, got edge collection";
} }

View File

@ -223,7 +223,7 @@ namespace triagens {
statusCode = rest::HttpResponse::ACCEPTED; 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 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; 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); generate20x(statusCode, trx.resolver()->getCollectionName(cid), key, rid, type);
} }