10000 try to work around some assertions by jsteemann · Pull Request #3296 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

try to work around some assertions #3296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
work around some other assertions
  • Loading branch information
jsteemann committed Sep 21, 2017
commit c69496876f51c30870918f8f819d62ffb8b2cf7f
22 changes: 19 additions & 3 deletions arangod/Cluster/ClusterMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,12 @@ int fetchEdgesFromEngines(
resSlice, "readIndex", 0);
VPackSlice edges = resSlice.get("edges");
for (auto const& e : VPackArrayIterator(edges)) {
VPackSlice id = transaction::helpers::extractIdFromDocument(e);
VPackSlice id = e.get(StaticStrings::IdString);
if (!id.isString()) {
// invalid id type
LOG_TOPIC(ERR, Logger::FIXME) << "got invalid edge id type: " << id.typeName();
continue;
}
StringRef idRef(id);
auto resE = cache.find(idRef);
if (resE == cache.end()) {
Expand Down Expand Up @@ -1809,7 +1814,13 @@ void fetchVerticesFromEngines(
}
TRI_ASSERT(result.find(key) == result.end());
auto val = VPackBuilder::clone(pair.value);
VPackSlice id = transaction::helpers::extractIdFromDocument(val.slice());

VPackSlice id = val.slice().get(StaticStrings::IdString);
if (!id.isString()) {
// invalid id type
LOG_TOPIC(ERR, Logger::FIXME) << "got invalid edge id type: " << id.typeName();
continue;
}
TRI_ASSERT(id.isString());
result.emplace(StringRef(id), val.steal());
}
Expand Down Expand Up @@ -2689,7 +2700,12 @@ int fetchEdgesFromEngines(
resSlice, "readIndex", 0);
VPackSlice edges = resSlice.get("edges");
for (auto const& e : VPackArrayIterator(edges)) {
VPackSlice id = transaction::helpers::extractIdFromDocument(e);
VPackSlice id = e.get(StaticStrings::IdString);
if (!id.isString()) {
// invalid id type
LOG_TOPIC(ERR, Logger::FIXME) << "got invalid edge id type: " << id.typeName();
continue;
}
StringRef idRef(id);
auto resE = cache.find(idRef);
if (resE == cache.end()) {
Expand Down
22 changes: 20 additions & 2 deletions arangod/Cluster/TraverserEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void BaseEngine::getVertexData(VPackSlice vertex, VPackBuilder& builder) {
// Maybe handle differently
}

StringRef vertex = id.substr(pos+1);
StringRef vertex = id.substr(pos + 1);
for (std::string const& shard : shards->second) {
Result res = _trx->documentFastPathLocal(shard, vertex, mmdr, false);
if (res.ok()) {
Expand Down Expand Up @@ -262,6 +262,9 @@ void BaseTraverserEngine::getEdges(VPackSlice vertex, size_t depth,
if (edge.isString()) {
edge = _opts->cache()->lookupToken(eid);
}
if (edge.isNull()) {
return;
}
if (_opts->evaluateEdgeExpression(edge, StringRef(v), depth,
cursorId)) {
builder.add(edge);
Expand All @@ -277,6 +280,9 @@ void BaseTraverserEngine::getEdges(VPackSlice vertex, size_t depth,
if (edge.isString()) {
edge = _opts->cache()->lookupToken(eid);
}
if (edge.isNull()) {
return;
}
if (_opts->evaluateEdgeExpression(edge, StringRef(vertex), depth,
cursorId)) {
builder.add(edge);
Expand Down Expand Up @@ -307,6 +313,9 @@ void BaseTraverserEngine::getVertexData(VPackSlice vertex, size_t depth,
builder.add(VPackValue("vertices"));

auto workOnOneDocument = [&](VPackSlice v) {
if (v.isNull()) {
return;
}
StringRef id(v);
size_t pos = id.find('/');
if (pos == std::string::npos || pos + 1 == id.size()) {
Expand All @@ -325,7 +334,7 @@ void BaseTraverserEngine::getVertexData(VPackSlice vertex, size_t depth,
// Maybe handle differently
}

StringRef vertex = id.substr(pos+1);
StringRef vertex = id.substr(pos + 1);
for (std::string const& shard : shards->second) {
Result res = _trx->documentFastPathLocal(shard, vertex, mmdr, false);
if (res.ok()) {
Expand Down Expand Up @@ -402,6 +411,9 @@ void ShortestPathEngine::getEdges(VPackSlice vertex, bool backward,
builder.openArray();
if (vertex.isArray()) {
for (VPackSlice v : VPackArrayIterator(vertex)) {
if (!vertex.isString()) {
continue;
}
TRI_ASSERT(v.isString());
// result.clear();
StringRef vertexId(v);
Expand All @@ -415,6 +427,9 @@ void ShortestPathEngine::getEdges(VPackSlice vertex, bool backward,
VPackSlice edge, size_t cursorId) {
if (edge.isString()) {
edge = _opts->cache()->lookupToken(eid);
}
if (edge.isNull()) {
return;
}
builder.add(edge);
});
Expand All @@ -432,6 +447,9 @@ void ShortestPathEngine::getEdges(VPackSlice vertex, bool backward,
if (edge.isString()) {
edge = _opts->cache()->lookupToken(eid);
}
if (edge.isNull()) {
return;
}
builder.add(edge);
});
// Result now contains all valid edges, probably multiples.
Expand Down
50 changes: 24 additions & 26 deletions arangod/InternalRestHandler/InternalRestTraverserHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,34 +182,32 @@ void InternalRestTraverserHandler::queryEngine() {
}

switch (engine->getType()) {
case BaseEngine::EngineType::TRAVERSER:
{
VPackSlice depthSlice = body.get("depth");
if (!depthSlice.isInteger()) {
generateError(ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER,
"expecting 'depth' to be an integer value");
return;
}
// Save Cast BaseTraverserEngines are all of type TRAVERSER
auto eng = static_cast<BaseTraverserEngine*>(engine);
TRI_ASSERT(eng != nullptr);
eng->getEdges(keysSlice, depthSlice.getNumericValue<size_t>(), result);
break;
case BaseEngine::EngineType::TRAVERSER: {
VPackSlice depthSlice = body.get("depth");
if (!depthSlice.isInteger()) {
generateError(ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER,
"expecting 'depth' to be an integer value");
return;
}
case BaseEngine::EngineType::SHORTESTPATH:
{
VPackSlice bwSlice = body.get("backward");
if (!bwSlice.isBool()) {
generateError(ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER,
"expecting 'backward' to be a boolean value");
return;
}
// Save Cast ShortestPathEngines are all of type SHORTESTPATH
auto eng = static_cast<ShortestPathEngine*>(engine);
TRI_ASSERT(eng != nullptr);
eng->getEdges(keysSlice, bwSlice.getBoolean(), result);
break;
// Save Cast BaseTraverserEngines are all of type TRAVERSER
auto eng = static_cast<BaseTraverserEngine*>(engine);
TRI_ASSERT(eng != nullptr);
eng->getEdges(keysSlice, depthSlice.getNumericValue<size_t>(), result);
break;
}
case BaseEngine::EngineType::SHORTESTPATH: {
VPackSlice bwSlice = body.get("backward");
if (!bwSlice.isBool()) {
generateError(ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER,
"expecting 'backward' to be a boolean value");
return;
}
// Save Cast ShortestPathEngines are all of type SHORTESTPATH
auto eng = static_cast<ShortestPathEngine*>(engine);
TRI_ASSERT(eng != nullptr);
eng->getEdges(keysSlice, bwSlice.getBoolean(), result);
break;
}
default:
generateError(ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER,
"this engine does not support the requested operation.");
Expand Down
4 changes: 2 additions & 2 deletions arangod/Transaction/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ StringRef transaction::helpers::extractKeyPart(VPackSlice slice) {
/// @brief extract the _id attribute from a slice, and convert it into a
/// string, static method
std::string transaction::helpers::extractIdString(CollectionNameResolver const* resolver,
VPackSlice slice,
VPackSlice const& base) {
VPackSlice slice,
VPackSlice const& base) {
VPackSlice id;

if (slice.isExternal()) {
Expand Down
3 changes: 3 additions & 0 deletions arangod/Transaction/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ namespace helpers {
/// the document must have at least two attributes, and _id is supposed to
/// be the second one
/// note that this may return a Slice of type Custom!
/// do NOT call this method when
/// - the input slice is not a database document
/// - you are not willing to deal with slices of type Custom
VPackSlice extractIdFromDocument(VPackSlice);

/// @brief quick access to the _from attribute in a database document
Expand Down
0