1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/arangodb into devel

This commit is contained in:
hkernbach 2016-04-29 10:29:16 +02:00
commit f79ba1c20d
7 changed files with 45 additions and 65 deletions

View File

@ -548,7 +548,7 @@ static void RequestEdges(VPackSlice const& vertexSlice,
THROW_ARANGO_EXCEPTION(vertexResult.code); THROW_ARANGO_EXCEPTION(vertexResult.code);
} }
} else { } else {
result.add("vertex", vertexResult.slice()); result.add("vertex", vertexResult.slice().resolveExternal());
} }
} }
} }
@ -596,51 +596,28 @@ static void RegisterCollectionInTransaction(
/// @brief Helper function to get a document by it's identifier /// @brief Helper function to get a document by it's identifier
/// Lazy Locks the collection if necessary. /// Lazy Locks the collection if necessary.
static void GetDocumentByIdentifier(arangodb::AqlTransaction* trx, static void GetDocumentByIdentifier(arangodb::AqlTransaction* trx,
std::string const& collectionName, std::string& collectionName,
std::string const& identifier, std::string const& identifier,
bool ignoreError, bool ignoreError,
VPackBuilder& result) { VPackBuilder& result) {
OperationOptions options; OperationOptions options;
OperationResult opRes; OperationResult opRes;
VPackBuilder searchBuilder; TransactionBuilderLeaser searchBuilder(trx);
searchBuilder.openObject();
searchBuilder.add(VPackValue(TRI_VOC_ATTRIBUTE_KEY)); searchBuilder->openObject();
searchBuilder->add(VPackValue(TRI_VOC_ATTRIBUTE_KEY));
std::vector<std::string> parts = std::vector<std::string> parts =
arangodb::basics::StringUtils::split(identifier, "/"); arangodb::basics::StringUtils::split(identifier, "/");
if (parts.size() == 1) { if (parts.size() == 1) {
searchBuilder.add(VPackValue(identifier)); searchBuilder->add(VPackValue(identifier));
searchBuilder.close(); searchBuilder->close();
try {
TRI_voc_cid_t cid;
RegisterCollectionInTransaction(trx, collectionName, cid);
} catch (arangodb::basics::Exception const&) {
if (ignoreError) {
return;
}
throw;
}
opRes = trx->document(collectionName, searchBuilder.slice(), options);
} else if (parts.size() == 2) { } else if (parts.size() == 2) {
if (collectionName.empty()) { if (collectionName.empty()) {
searchBuilder.add(VPackValue(parts[1])); searchBuilder->add(VPackValue(parts[1]));
searchBuilder.close(); searchBuilder->close();
collectionName = parts[0];
try {
TRI_voc_cid_t cid;
RegisterCollectionInTransaction(trx, parts[0], cid);
} catch (arangodb::basics::Exception const&) {
if (ignoreError) {
return;
}
throw;
}
opRes = trx->document(parts[0], searchBuilder.slice(), options);
} else if (parts[0] != collectionName) { } else if (parts[0] != collectionName) {
// Reqesting an _id that cannot be stored in this collection // Reqesting an _id that cannot be stored in this collection
if (ignoreError) { if (ignoreError) {
@ -648,20 +625,8 @@ static void GetDocumentByIdentifier(arangodb::AqlTransaction* trx,
} }
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_CROSS_COLLECTION_REQUEST); THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_CROSS_COLLECTION_REQUEST);
} else { } else {
searchBuilder.add(VPackValue(parts[1])); searchBuilder->add(VPackValue(parts[1]));
searchBuilder.close(); searchBuilder->close();
try {
TRI_voc_cid_t cid;
RegisterCollectionInTransaction(trx, collectionName, cid);
} catch (arangodb::basics::Exception const&) {
if (ignoreError) {
return;
}
throw;
}
opRes = trx->document(collectionName, searchBuilder.slice(), options);
} }
} else { } else {
if (ignoreError) { if (ignoreError) {
@ -669,6 +634,16 @@ static void GetDocumentByIdentifier(arangodb::AqlTransaction* trx,
} }
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD); THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DOCUMENT_HANDLE_BAD);
} }
try {
opRes = trx->document(collectionName, searchBuilder->slice(), options);
} catch (arangodb::basics::Exception const&) {
if (ignoreError) {
return;
}
throw;
}
if (opRes.failed()) { if (opRes.failed()) {
if (ignoreError) { if (ignoreError) {
return; return;
@ -766,7 +741,8 @@ static AqlValue VertexIdsToAqlValueVPack(arangodb::aql::Query* query,
if (includeData) { if (includeData) {
for (auto& it : ids) { for (auto& it : ids) {
// THROWS ERRORS if the Document was not found // THROWS ERRORS if the Document was not found
GetDocumentByIdentifier(trx, "", it, false, *builder.get()); std::string colName;
GetDocumentByIdentifier(trx, colName, it, false, *builder.get());
} }
} else { } else {
for (auto& it : ids) { for (auto& it : ids) {
@ -2436,7 +2412,8 @@ AqlValue Functions::Document(arangodb::aql::Query* query,
TransactionBuilderLeaser builder(trx); TransactionBuilderLeaser builder(trx);
if (id.isString()) { if (id.isString()) {
std::string identifier(id.slice().copyString()); std::string identifier(id.slice().copyString());
GetDocumentByIdentifier(trx, "", identifier, true, *builder.get()); std::string colName;
GetDocumentByIdentifier(trx, colName, identifier, true, *builder.get());
if (builder->isEmpty()) { if (builder->isEmpty()) {
// not found // not found
return AqlValue(arangodb::basics::VelocyPackHelper::NullValue()); return AqlValue(arangodb::basics::VelocyPackHelper::NullValue());
@ -2450,7 +2427,8 @@ AqlValue Functions::Document(arangodb::aql::Query* query,
for (auto const& next : VPackArrayIterator(idSlice)) { for (auto const& next : VPackArrayIterator(idSlice)) {
if (next.isString()) { if (next.isString()) {
std::string identifier = next.copyString(); std::string identifier = next.copyString();
GetDocumentByIdentifier(trx, "", identifier, true, *builder.get()); std::string colName;
GetDocumentByIdentifier(trx, colName, identifier, true, *builder.get());
} }
} }
builder->close(); builder->close();
@ -2463,7 +2441,7 @@ AqlValue Functions::Document(arangodb::aql::Query* query,
if (!collectionValue.isString()) { if (!collectionValue.isString()) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL);
} }
std::string const collectionName(collectionValue.slice().copyString()); std::string collectionName(collectionValue.slice().copyString());
bool notFound = false; // TODO: what does this do? bool notFound = false; // TODO: what does this do?

View File

@ -101,7 +101,8 @@ void Graph::toVelocyPack(VPackBuilder& builder, bool verbose) const {
} }
} }
Graph::Graph(VPackSlice const& slice) : _vertexColls(), _edgeColls() { Graph::Graph(VPackSlice const& info) : _vertexColls(), _edgeColls() {
VPackSlice const slice = info.resolveExternal();
if (slice.hasKey(_attrEdgeDefs)) { if (slice.hasKey(_attrEdgeDefs)) {
auto edgeDefs = slice.get(_attrEdgeDefs); auto edgeDefs = slice.get(_attrEdgeDefs);

View File

@ -344,9 +344,10 @@ void RestVocbaseBaseHandler::generateNotModified(TRI_voc_rid_t rid) {
/// @brief generates next entry from a result set /// @brief generates next entry from a result set
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestVocbaseBaseHandler::generateDocument(VPackSlice const& document, void RestVocbaseBaseHandler::generateDocument(VPackSlice const& input,
bool generateBody, bool generateBody,
VPackOptions const* options) { VPackOptions const* options) {
VPackSlice document = input.resolveExternal();
std::string rev; std::string rev;
if (document.isObject()) { if (document.isObject()) {
rev = VelocyPackHelper::getStringValue(document, Transaction::RevString, ""); rev = VelocyPackHelper::getStringValue(document, Transaction::RevString, "");

View File

@ -708,14 +708,14 @@ void Transaction::buildDocumentIdentity(TRI_document_collection_t* document,
builder.add("_oldRev", oldRid); builder.add("_oldRev", oldRid);
} }
if (oldMptr != nullptr) { if (oldMptr != nullptr) {
builder.add("old", VPackSlice(oldMptr->vpack())); // builder.add("old", VPackSlice(oldMptr->vpack()));
// TODO: add externals later. // TODO: add externals later.
//builder.add("old", VPackValue(VPackValueType::External, oldMptr->vpack())); builder.add("old", VPackValue(oldMptr->vpack(), VPackValueType::External));
} }
if (newMptr != nullptr) { if (newMptr != nullptr) {
builder.add("new", VPackSlice(newMptr->vpack())); // builder.add("new", VPackSlice(newMptr->vpack()));
// TODO: add externals later. // TODO: add externals later.
//builder.add("new", VPackValue(VPackValueType::External, newMptr->vpack())); builder.add("new", VPackValue(newMptr->vpack(), VPackValueType::External));
} }
builder.close(); builder.close();
} }
@ -1110,9 +1110,7 @@ OperationResult Transaction::documentLocal(std::string const& collectionName,
} }
if (!options.silent) { if (!options.silent) {
//resultBuilder.add(VPackValue(static_cast<void const*>(mptr.vpack()), VPackValueType::External)); resultBuilder.add(VPackValue(static_cast<void const*>(mptr.vpack()), VPackValueType::External));
// This is the future, for now, we have to do this:
resultBuilder.add(VPackSlice(mptr.vpack()));
} else if (isMultiple) { } else if (isMultiple) {
resultBuilder.add(VPackSlice::nullSlice()); resultBuilder.add(VPackSlice::nullSlice());
} }

View File

@ -1,4 +1,4 @@
//////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER /// DISCLAIMER
/// ///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany /// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
@ -183,7 +183,8 @@ ExampleMatcher::ExampleMatcher(VPackSlice const& example,
/// @brief Checks if the given velocyPack matches the examples in this class /// @brief Checks if the given velocyPack matches the examples in this class
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool ExampleMatcher::matches(VPackSlice const toMatch) const { bool ExampleMatcher::matches(VPackSlice const test) const {
VPackSlice toMatch = test.resolveExternal();
for (auto const& def : definitions) { for (auto const& def : definitions) {
VPackSlice const compareValue = def.slice(); VPackSlice const compareValue = def.slice();
size_t i = 0; size_t i = 0;

View File

@ -238,7 +238,7 @@ bool TraverserExpression::matchesCheck(arangodb::Transaction* trx,
VPackSlice const& element) const { VPackSlice const& element) const {
TRI_ASSERT(trx != nullptr); TRI_ASSERT(trx != nullptr);
VPackSlice value = element; VPackSlice value = element.resolveExternal();
// initialize compare value to Null // initialize compare value to Null
VPackSlice result = arangodb::basics::VelocyPackHelper::NullValue(); VPackSlice result = arangodb::basics::VelocyPackHelper::NullValue();

View File

@ -2319,7 +2319,8 @@ void TRI_FillVPackSub(TRI_vpack_sub_t* sub,
/// @brief extract the _rev attribute from a slice /// @brief extract the _rev attribute from a slice
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TRI_voc_rid_t TRI_ExtractRevisionId(VPackSlice const slice) { TRI_voc_rid_t TRI_ExtractRevisionId(VPackSlice slice) {
slice = slice.resolveExternal();
TRI_ASSERT(slice.isObject()); TRI_ASSERT(slice.isObject());
VPackSlice r(slice.get(TRI_VOC_ATTRIBUTE_REV)); VPackSlice r(slice.get(TRI_VOC_ATTRIBUTE_REV));