mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'vpack' of ssh://github.com/ArangoDB/ArangoDB into vpack
This commit is contained in:
commit
989e92761b
|
@ -1445,8 +1445,8 @@ int ClusterInfo::dropCollectionCoordinator (string const& databaseName,
|
||||||
/// @brief set collection properties in coordinator
|
/// @brief set collection properties in coordinator
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int ClusterInfo::setCollectionPropertiesCoordinator (string const& databaseName,
|
int ClusterInfo::setCollectionPropertiesCoordinator (std::string const& databaseName,
|
||||||
string const& collectionID,
|
std::string const& collectionID,
|
||||||
VocbaseCollectionInfo const* info) {
|
VocbaseCollectionInfo const* info) {
|
||||||
AgencyComm ac;
|
AgencyComm ac;
|
||||||
AgencyCommResult res;
|
AgencyCommResult res;
|
||||||
|
@ -1480,25 +1480,23 @@ int ClusterInfo::setCollectionPropertiesCoordinator (string const& databaseName,
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_json_t* copy = TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, json);
|
std::unique_ptr<TRI_json_t> copy(TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, json));
|
||||||
if (copy == nullptr) {
|
if (copy == nullptr) {
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "doCompact");
|
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "doCompact");
|
||||||
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "journalSize");
|
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "journalSize");
|
||||||
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "waitForSync");
|
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "waitForSync");
|
||||||
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "indexBuckets");
|
TRI_DeleteObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "indexBuckets");
|
||||||
|
|
||||||
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "doCompact", TRI_CreateBooleanJson(TRI_UNKNOWN_MEM_ZONE, info->doCompact()));
|
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "doCompact", TRI_CreateBooleanJson(TRI_UNKNOWN_MEM_ZONE, info->doCompact()));
|
||||||
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "journalSize", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, info->maximalSize()));
|
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "journalSize", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, info->maximalSize()));
|
||||||
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "waitForSync", TRI_CreateBooleanJson(TRI_UNKNOWN_MEM_ZONE, info->waitForSync()));
|
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "waitForSync", TRI_CreateBooleanJson(TRI_UNKNOWN_MEM_ZONE, info->waitForSync()));
|
||||||
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy, "indexBuckets", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, info->indexBuckets()));
|
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, copy.get(), "indexBuckets", TRI_CreateNumberJson(TRI_UNKNOWN_MEM_ZONE, info->indexBuckets()));
|
||||||
|
|
||||||
res.clear();
|
res.clear();
|
||||||
res = ac.setValue("Plan/Collections/" + databaseName + "/" + collectionID, copy, 0.0);
|
res = ac.setValue("Plan/Collections/" + databaseName + "/" + collectionID, copy.get(), 0.0);
|
||||||
|
|
||||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.successful()) {
|
if (res.successful()) {
|
||||||
|
|
|
@ -911,10 +911,9 @@ bool RestImportHandler::createFromJson (string const& type) {
|
||||||
else {
|
else {
|
||||||
// the entire request body is one JSON document
|
// the entire request body is one JSON document
|
||||||
// TODO Workaround for cast char* to uint8_t*
|
// TODO Workaround for cast char* to uint8_t*
|
||||||
std::string body(_request->body(), _request->bodySize());
|
|
||||||
std::shared_ptr<VPackBuilder> parsedDocuments;
|
std::shared_ptr<VPackBuilder> parsedDocuments;
|
||||||
try {
|
try {
|
||||||
parsedDocuments = VPackParser::fromJson(body);
|
parsedDocuments = VPackParser::fromJson(reinterpret_cast<uint8_t const*>(_request->body()), _request->bodySize());
|
||||||
}
|
}
|
||||||
catch (VPackException const& e) {
|
catch (VPackException const& e) {
|
||||||
generateError(HttpResponse::BAD,
|
generateError(HttpResponse::BAD,
|
||||||
|
|
|
@ -37,13 +37,13 @@
|
||||||
#include "Basics/string-buffer.h"
|
#include "Basics/string-buffer.h"
|
||||||
#include "Basics/json-utilities.h"
|
#include "Basics/json-utilities.h"
|
||||||
#include "Basics/VelocyPackHelper.h"
|
#include "Basics/VelocyPackHelper.h"
|
||||||
|
#include "Cluster/ClusterComm.h"
|
||||||
|
#include "Cluster/ClusterInfo.h"
|
||||||
|
#include "Cluster/ClusterMethods.h"
|
||||||
|
#include "Cluster/ServerState.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "VocBase/document-collection.h"
|
#include "VocBase/document-collection.h"
|
||||||
#include "VocBase/vocbase.h"
|
#include "VocBase/vocbase.h"
|
||||||
#include "Cluster/ServerState.h"
|
|
||||||
#include "Cluster/ClusterInfo.h"
|
|
||||||
#include "Cluster/ClusterComm.h"
|
|
||||||
#include "Cluster/ClusterMethods.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace triagens::basics;
|
using namespace triagens::basics;
|
||||||
|
@ -81,25 +81,37 @@ bool RestQueryHandler::isDirect () const {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HttpHandler::status_t RestQueryHandler::execute () {
|
HttpHandler::status_t RestQueryHandler::execute () {
|
||||||
|
|
||||||
// extract the sub-request type
|
// extract the sub-request type
|
||||||
HttpRequest::HttpRequestType type = _request->requestType();
|
HttpRequest::HttpRequestType type = _request->requestType();
|
||||||
|
|
||||||
// execute one of the CRUD methods
|
// execute one of the CRUD methods
|
||||||
switch (type) {
|
try {
|
||||||
case HttpRequest::HTTP_REQUEST_DELETE: deleteQuery(); break;
|
switch (type) {
|
||||||
case HttpRequest::HTTP_REQUEST_GET: readQuery(); break;
|
case HttpRequest::HTTP_REQUEST_DELETE: deleteQuery(); break;
|
||||||
case HttpRequest::HTTP_REQUEST_PUT: replaceProperties(); break;
|
case HttpRequest::HTTP_REQUEST_GET: readQuery(); break;
|
||||||
case HttpRequest::HTTP_REQUEST_POST: parseQuery(); break;
|
case HttpRequest::HTTP_REQUEST_PUT: replaceProperties(); break;
|
||||||
|
case HttpRequest::HTTP_REQUEST_POST: parseQuery(); break;
|
||||||
|
|
||||||
case HttpRequest::HTTP_REQUEST_HEAD:
|
case HttpRequest::HTTP_REQUEST_HEAD:
|
||||||
case HttpRequest::HTTP_REQUEST_PATCH:
|
case HttpRequest::HTTP_REQUEST_PATCH:
|
||||||
case HttpRequest::HTTP_REQUEST_ILLEGAL:
|
case HttpRequest::HTTP_REQUEST_ILLEGAL:
|
||||||
default: {
|
default: {
|
||||||
generateNotImplemented("ILLEGAL " + DOCUMENT_PATH);
|
generateNotImplemented("ILLEGAL " + DOCUMENT_PATH);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception const& err) {
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
|
catch (std::exception const& ex) {
|
||||||
|
triagens::basics::Exception err(TRI_ERROR_INTERNAL, ex.what(), __FILE__, __LINE__);
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
triagens::basics::Exception err(TRI_ERROR_INTERNAL, __FILE__, __LINE__);
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
|
|
||||||
// this handler is done
|
// this handler is done
|
||||||
return status_t(HANDLER_DONE);
|
return status_t(HANDLER_DONE);
|
||||||
|
@ -167,6 +179,7 @@ bool RestQueryHandler::readQueryProperties () {
|
||||||
result.add("maxQueryStringLength", VPackValue(queryList->maxQueryStringLength()));
|
result.add("maxQueryStringLength", VPackValue(queryList->maxQueryStringLength()));
|
||||||
result.close();
|
result.close();
|
||||||
VPackSlice slice = result.slice();
|
VPackSlice slice = result.slice();
|
||||||
|
|
||||||
generateResult(slice);
|
generateResult(slice);
|
||||||
}
|
}
|
||||||
catch (Exception const& err) {
|
catch (Exception const& err) {
|
||||||
|
@ -253,13 +266,14 @@ bool RestQueryHandler::readQueryProperties () {
|
||||||
bool RestQueryHandler::readQuery (bool slow) {
|
bool RestQueryHandler::readQuery (bool slow) {
|
||||||
try {
|
try {
|
||||||
auto queryList = static_cast<QueryList*>(_vocbase->_queries);
|
auto queryList = static_cast<QueryList*>(_vocbase->_queries);
|
||||||
auto const&& queries = slow ? queryList->listSlow() : queryList->listCurrent();
|
auto queries = slow ? queryList->listSlow() : queryList->listCurrent();
|
||||||
|
|
||||||
VPackBuilder result;
|
VPackBuilder result;
|
||||||
result.add(VPackValue(VPackValueType::Array));
|
result.add(VPackValue(VPackValueType::Array));
|
||||||
|
|
||||||
for (auto it : queries) {
|
for (auto const& it : queries) {
|
||||||
const auto&& timeString = TRI_StringTimeStamp(it.started);
|
auto const& timeString = TRI_StringTimeStamp(it.started);
|
||||||
const auto& queryString = it.queryString;
|
auto const& queryString = it.queryString;
|
||||||
|
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
result.add(VPackValue(VPackValueType::Object));
|
||||||
result.add("id", VPackValue(StringUtils::itoa(it.id)));
|
result.add("id", VPackValue(StringUtils::itoa(it.id)));
|
||||||
|
@ -302,7 +316,7 @@ bool RestQueryHandler::readQuery () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& name = suffix[0];
|
auto const& name = suffix[0];
|
||||||
|
|
||||||
if (name == "slow") {
|
if (name == "slow") {
|
||||||
return readQuery(true);
|
return readQuery(true);
|
||||||
|
@ -344,18 +358,13 @@ bool RestQueryHandler::deleteQuerySlow () {
|
||||||
auto queryList = static_cast<triagens::aql::QueryList*>(_vocbase->_queries);
|
auto queryList = static_cast<triagens::aql::QueryList*>(_vocbase->_queries);
|
||||||
queryList->clearSlow();
|
queryList->clearSlow();
|
||||||
|
|
||||||
try {
|
VPackBuilder result;
|
||||||
VPackBuilder result;
|
result.add(VPackValue(VPackValueType::Object));
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
result.add("error", VPackValue(false));
|
||||||
result.add("error", VPackValue(false));
|
result.add("code", VPackValue(HttpResponse::OK));
|
||||||
result.add("code", VPackValue(HttpResponse::OK));
|
result.close();
|
||||||
result.close();
|
VPackSlice slice = result.slice();
|
||||||
VPackSlice slice = result.slice();
|
generateResult(slice);
|
||||||
generateResult(slice);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// Ignore the error
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -398,18 +407,13 @@ bool RestQueryHandler::deleteQuery (const string& name) {
|
||||||
auto res = queryList->kill(id);
|
auto res = queryList->kill(id);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
try {
|
VPackBuilder result;
|
||||||
VPackBuilder result;
|
result.add(VPackValue(VPackValueType::Object));
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
result.add("error", VPackValue(false));
|
||||||
result.add("error", VPackValue(false));
|
result.add("code", VPackValue(HttpResponse::OK));
|
||||||
result.add("code", VPackValue(HttpResponse::OK));
|
result.close();
|
||||||
result.close();
|
VPackSlice slice = result.slice();
|
||||||
VPackSlice slice = result.slice();
|
generateResult(slice);
|
||||||
generateResult(slice);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// Ignore the error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
generateError(HttpResponse::BAD, res, "cannot kill query '" + name + "'");
|
generateError(HttpResponse::BAD, res, "cannot kill query '" + name + "'");
|
||||||
|
@ -432,14 +436,12 @@ bool RestQueryHandler::deleteQuery () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& name = suffix[0];
|
auto const& name = suffix[0];
|
||||||
|
|
||||||
if (name == "slow") {
|
if (name == "slow") {
|
||||||
return deleteQuerySlow();
|
return deleteQuerySlow();
|
||||||
}
|
}
|
||||||
else {
|
return deleteQuery(name);
|
||||||
return deleteQuery(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -544,8 +546,8 @@ bool RestQueryHandler::replaceProperties () {
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute = body.get("slowQueryThreshold");
|
attribute = body.get("slowQueryThreshold");
|
||||||
if (attribute.isDouble()) {
|
if (attribute.isNumber()) {
|
||||||
slowQueryThreshold = attribute.getDouble();
|
slowQueryThreshold = attribute.getNumber<double>();
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute = body.get("maxQueryStringLength");
|
attribute = body.get("maxQueryStringLength");
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
#include "unicode/timezone.h"
|
#include "unicode/timezone.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace triagens::basics;
|
using namespace triagens::basics;
|
||||||
|
@ -2436,12 +2435,13 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
|
||||||
if (par->IsObject()) {
|
if (par->IsObject()) {
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
{
|
{
|
||||||
VPackObjectBuilder b(&builder);
|
|
||||||
int res = TRI_V8ToVPack(isolate, builder, args[0], false);
|
int res = TRI_V8ToVPack(isolate, builder, args[0], false);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_V8_THROW_EXCEPTION(res);
|
TRI_V8_THROW_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VPackSlice const slice = builder.slice();
|
VPackSlice const slice = builder.slice();
|
||||||
if (slice.hasKey("journalSize")) {
|
if (slice.hasKey("journalSize")) {
|
||||||
VPackSlice maxSizeSlice = slice.get("journalSize");
|
VPackSlice maxSizeSlice = slice.get("journalSize");
|
||||||
|
@ -2461,29 +2461,6 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
|
||||||
TRI_V8_THROW_EXCEPTION_PARAMETER("indexBucket must be a two-power between 1 and 1024");
|
TRI_V8_THROW_EXCEPTION_PARAMETER("indexBucket must be a two-power between 1 and 1024");
|
||||||
}
|
}
|
||||||
info.update(slice, false, collection->_vocbase);
|
info.update(slice, false, collection->_vocbase);
|
||||||
|
|
||||||
// TODO FIXME temporary ASSERTIONS
|
|
||||||
v8::Handle<v8::Object> po = par->ToObject();
|
|
||||||
|
|
||||||
// extract doCompact flag
|
|
||||||
TRI_GET_GLOBAL_STRING(DoCompactKey);
|
|
||||||
if (po->Has(DoCompactKey)) {
|
|
||||||
TRI_ASSERT(info.doCompact() == TRI_ObjectToBoolean(po->Get(DoCompactKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract sync flag
|
|
||||||
TRI_GET_GLOBAL_STRING(WaitForSyncKey);
|
|
||||||
if (po->Has(WaitForSyncKey)) {
|
|
||||||
TRI_ASSERT(info.waitForSync() == TRI_ObjectToBoolean(po->Get(WaitForSyncKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract the journal size
|
|
||||||
TRI_GET_GLOBAL_STRING(JournalSizeKey);
|
|
||||||
if (po->Has(JournalSizeKey)) {
|
|
||||||
auto maximalSize = (TRI_voc_size_t) TRI_ObjectToUInt64(po->Get(JournalSizeKey), false);
|
|
||||||
TRI_ASSERT(info.maximalSize() == maximalSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = ClusterInfo::instance()->setCollectionPropertiesCoordinator(databaseName, StringUtils::itoa(collection->_cid), &info);
|
int res = ClusterInfo::instance()->setCollectionPropertiesCoordinator(databaseName, StringUtils::itoa(collection->_cid), &info);
|
||||||
|
@ -2493,7 +2470,6 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// return the current parameter set
|
// return the current parameter set
|
||||||
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
||||||
|
|
||||||
|
|
|
@ -1592,6 +1592,7 @@ static void CreateVocBase (const v8::FunctionCallbackInfo<v8::Value>& args,
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_V8_THROW_EXCEPTION(res);
|
TRI_V8_THROW_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
infoSlice = builder.slice();
|
infoSlice = builder.slice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1805,7 +1806,6 @@ void TRI_InitV8indexArangoDB (v8::Isolate* isolate,
|
||||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("_createDocumentCollection"), JS_CreateDocumentCollectionVocbase);
|
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("_createDocumentCollection"), JS_CreateDocumentCollectionVocbase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TRI_InitV8indexCollection (v8::Isolate* isolate,
|
void TRI_InitV8indexCollection (v8::Isolate* isolate,
|
||||||
v8::Handle<v8::ObjectTemplate> rt) {
|
v8::Handle<v8::ObjectTemplate> rt) {
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
#include "VocBase/server.h"
|
#include "VocBase/server.h"
|
||||||
#include "VocBase/vocbase.h"
|
#include "VocBase/vocbase.h"
|
||||||
|
|
||||||
|
#include <velocypack/Collection.h>
|
||||||
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace triagens::arango;
|
using namespace triagens::arango;
|
||||||
|
|
||||||
|
@ -1257,13 +1260,31 @@ VocbaseCollectionInfo VocbaseCollectionInfo::fromFile (char const* path,
|
||||||
|
|
||||||
std::string filePath(filename, strlen(filename));
|
std::string filePath(filename, strlen(filename));
|
||||||
std::shared_ptr<VPackBuilder> content = triagens::basics::VelocyPackHelper::velocyPackFromFile(filePath);
|
std::shared_ptr<VPackBuilder> content = triagens::basics::VelocyPackHelper::velocyPackFromFile(filePath);
|
||||||
VPackSlice const slice = content->slice();
|
VPackSlice slice = content->slice();
|
||||||
if (! slice.isObject()) {
|
if (! slice.isObject()) {
|
||||||
LOG_ERROR("cannot open '%s', collection parameters are not readable", filename);
|
LOG_ERROR("cannot open '%s', collection parameters are not readable", filename);
|
||||||
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_ILLEGAL_PARAMETER_FILE);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_ILLEGAL_PARAMETER_FILE);
|
||||||
}
|
}
|
||||||
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
||||||
|
|
||||||
|
// fiddle "isSystem" value, which is not contained in the JSON file
|
||||||
|
bool isSystemValue = false;
|
||||||
|
if (slice.hasKey("name")) {
|
||||||
|
auto name = slice.get("name").copyString();
|
||||||
|
if (! name.empty()) {
|
||||||
|
isSystemValue = name[0] == '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VPackBuilder bx;
|
||||||
|
bx.openObject();
|
||||||
|
bx.add("isSystem", VPackValue(isSystemValue));
|
||||||
|
bx.close();
|
||||||
|
VPackSlice isSystem = bx.slice();
|
||||||
|
VPackBuilder b2 = VPackCollection::merge(slice, isSystem, false);
|
||||||
|
slice = b2.slice();
|
||||||
|
|
||||||
VocbaseCollectionInfo info(vocbase, collectionName, slice);
|
VocbaseCollectionInfo info(vocbase, collectionName, slice);
|
||||||
|
|
||||||
// warn about wrong version of the collection
|
// warn about wrong version of the collection
|
||||||
|
|
|
@ -302,6 +302,10 @@ namespace triagens {
|
||||||
// Use with caution!
|
// Use with caution!
|
||||||
void rename (char const*);
|
void rename (char const*);
|
||||||
|
|
||||||
|
void setIsSystem (bool value) {
|
||||||
|
_isSystem = value;
|
||||||
|
}
|
||||||
|
|
||||||
void setRevision (TRI_voc_rid_t,
|
void setRevision (TRI_voc_rid_t,
|
||||||
bool);
|
bool);
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ TRI_json_t* VelocyPackHelper::velocyPackToJson (VPackSlice const& slice) {
|
||||||
|
|
||||||
std::shared_ptr<VPackBuilder> VelocyPackHelper::velocyPackFromFile (std::string const& path) {
|
std::shared_ptr<VPackBuilder> VelocyPackHelper::velocyPackFromFile (std::string const& path) {
|
||||||
size_t length;
|
size_t length;
|
||||||
|
// TODO: Fix memleak
|
||||||
char* content = TRI_SlurpFile(TRI_UNKNOWN_MEM_ZONE, path.c_str(), &length);
|
char* content = TRI_SlurpFile(TRI_UNKNOWN_MEM_ZONE, path.c_str(), &length);
|
||||||
// The Parser might THROW
|
// The Parser might THROW
|
||||||
return VPackParser::fromJson(reinterpret_cast<uint8_t const*>(content), length);
|
return VPackParser::fromJson(reinterpret_cast<uint8_t const*>(content), length);
|
||||||
|
|
Loading…
Reference in New Issue