1
0
Fork 0

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

This commit is contained in:
Michael Hackstein 2016-03-22 11:37:14 +01:00
commit 6a1f392efe
14 changed files with 45 additions and 150 deletions

View File

@ -49,6 +49,10 @@ Overview
versions. Additionally the checksum calculation algorithm was changed in 3.0,
so 3.0 will create different checksums than previous versions for the same data.
13. the HTTP API for modifying documents (/_api/document) does not return the `error`
attribute with a value of `false` in case an operation succeeds.
### New capabilities:
1. Babies for document queries.

View File

@ -31,15 +31,12 @@ describe ArangoDB do
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
id = doc.parsed_response['_id']
cmd = api + "/" + id
doc = ArangoDB.log_get("#{prefix}-create-empty-name", cmd)
doc.parsed_response.should_not have_key('')
doc.parsed_response.should have_key('')
doc.parsed_response.should have_key('foo')
end
@ -53,7 +50,6 @@ describe ArangoDB do
doc = ArangoDB.log_post("#{prefix}-query-empty-name", cmd, :body => body)
doc.code.should eq(201)
doc.parsed_response['error'].should eq(false)
cmd = "/_api/simple/all"
body = "{ \"collection\" : \"" + @cn + "\" }"
@ -62,7 +58,7 @@ describe ArangoDB do
documents = doc.parsed_response['result']
documents.length.should eq(1)
documents[0].should_not have_key('')
documents[0].should have_key('')
documents[0].should have_key('foo')
end
@ -78,8 +74,6 @@ describe ArangoDB do
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
id = doc.parsed_response['_id']
cmd = api + "/" + id
@ -87,8 +81,8 @@ describe ArangoDB do
doc.parsed_response['_id'].should eq(id)
doc.parsed_response['_rev'].should_not eq('99')
doc.parsed_response.should_not have_key('_from')
doc.parsed_response.should_not have_key('_to')
doc.parsed_response.should have_key('_from')
doc.parsed_response.should have_key('_to')
doc.parsed_response.should have_key('_test')
doc.parsed_response['_test'].should eq('c')
doc.parsed_response.should have_key('meow')
@ -107,8 +101,6 @@ describe ArangoDB do
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
id = doc.parsed_response['_id']
cmd = api + "/" + id
@ -118,14 +110,14 @@ describe ArangoDB do
doc.parsed_response['a'].should eq('1')
doc.parsed_response.should have_key('b')
doc.parsed_response['b'].should_not have_key('')
doc.parsed_response['b'].should have_key('')
doc.parsed_response['b'].should have_key('_from')
doc.parsed_response['b'].should have_key('_key')
doc.parsed_response['b'].should have_key('_lol')
doc.parsed_response['b'].should have_key('b')
doc.parsed_response['b'].should have_key('a')
doc.parsed_response['b'].should have_key('c')
doc.parsed_response['b'].should eq({ "b" => "2", "a" => "3", "_key" => "moetoer", "_from" => "5", "_lol" => false, "c" => 6 })
doc.parsed_response['b'].should eq({ "" => "4", "b" => "2", "a" => "3", "_key" => "moetoer", "_from" => "5", "_lol" => false, "c" => 6 })
end
################################################################################

View File

@ -37,10 +37,10 @@ describe ArangoDB do
cmd = "/_api/document/123456"
doc = ArangoDB.log_delete("#{prefix}-bad-handle", cmd)
doc.code.should eq(400)
doc.code.should eq(404)
doc.parsed_response['error'].should eq(true)
doc.parsed_response['errorNum'].should eq(400)
doc.parsed_response['code'].should eq(400)
doc.parsed_response['errorNum'].should eq(1203) # collection not found
doc.parsed_response['code'].should eq(404)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
end

View File

@ -981,9 +981,10 @@ describe ArangoDB do
e_key = doc.parsed_response['edge']['_key']
e_id = doc.parsed_response['edge']['_id']
e_to = doc.parsed_response['edge']['_to']
e_from = doc.parsed_response['edge']['_from']
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc1.code.should eq(201)
doc1.parsed_response['error'].should eq(false)
@ -1020,9 +1021,10 @@ describe ArangoDB do
e_key = doc.parsed_response['edge']['_key']
e_id = doc.parsed_response['edge']['_id']
e_to = doc.parsed_response['edge']['_to']
e_from = doc.parsed_response['edge']['_from']
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc1.code.should eq(202)
doc1.parsed_response['error'].should eq(false)
@ -1035,7 +1037,7 @@ describe ArangoDB do
doc1.parsed_response['edge']['$label'].should eq("label1")
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}?waitForSync=true"
body = "{\"_key\" : \"edge4711\", \"optional1\" : \"val1_huhu\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional1\" : \"val1_huhu\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc1.code.should eq(201)
doc1.parsed_response['error'].should eq(false)
@ -1046,7 +1048,6 @@ describe ArangoDB do
doc1.parsed_response['edge']['optional2'].should eq(nil)
doc1.parsed_response['edge']['optional1'].should eq("val1_huhu")
doc1.parsed_response['edge']['$label'].should eq("label1")
end
it "checks replace edge properties with if-match" do
@ -1060,6 +1061,8 @@ describe ArangoDB do
e_key = doc.parsed_response['edge']['_key']
e_rev = doc.parsed_response['edge']['_rev']
e_from = doc.parsed_response['edge']['_from']
e_to = doc.parsed_response['edge']['_to']
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}?rev=123"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
@ -1069,7 +1072,7 @@ describe ArangoDB do
doc1.parsed_response['code'].should eq(412)
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}?rev=#{e_rev}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc2 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc2.code.should eq(201)
doc2.parsed_response['error'].should eq(false)
@ -1079,13 +1082,13 @@ describe ArangoDB do
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}"
hdr = { "if-match" => "123456" }
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc3 = ArangoDB.log_put("#{prefix}", cmd, :body => body, :headers => hdr)
doc3.code.should eq(412)
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}"
hdr = { "if-match" => "#{e_rev}" }
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc3 = ArangoDB.log_put("#{prefix}", cmd, :body => body, :headers => hdr)
doc3.code.should eq(201)

View File

@ -78,24 +78,6 @@ TRI_document_collection_t* Collection::documentCollection() const {
return collection->_collection;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is an edge collection
////////////////////////////////////////////////////////////////////////////////
bool Collection::isEdgeCollection() const {
auto document = documentCollection();
return (document->_info.type() == TRI_COL_TYPE_EDGE);
}
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is a document collection
//////////////////////////////////////////////////////////////////////////////
bool Collection::isDocumentCollection() const {
auto document = documentCollection();
return (document->_info.type() == TRI_COL_TYPE_DOCUMENT);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief count the number of documents in the collection
////////////////////////////////////////////////////////////////////////////////
@ -189,30 +171,6 @@ std::vector<Index const*> Collection::getIndexes() const {
return indexes;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
////////////////////////////////////////////////////////////////////////////////
Index const* Collection::getIndex(TRI_idx_iid_t id) const {
fillIndexes();
for (auto const& idx : indexes) {
if (idx->id == id) {
return idx;
}
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
////////////////////////////////////////////////////////////////////////////////
Index const* Collection::getIndex(std::string const& id) const {
return getIndex(arangodb::basics::StringUtils::uint64(id));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection uses the default sharding
////////////////////////////////////////////////////////////////////////////////

View File

@ -88,18 +88,6 @@ struct Collection {
TRI_document_collection_t* documentCollection() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is an edge collection
//////////////////////////////////////////////////////////////////////////////
bool isEdgeCollection() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is a document collection
//////////////////////////////////////////////////////////////////////////////
bool isDocumentCollection() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief count the LOCAL number of documents in the collection
//////////////////////////////////////////////////////////////////////////////
@ -130,18 +118,6 @@ struct Collection {
std::vector<Index const*> getIndexes() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
//////////////////////////////////////////////////////////////////////////////
Index const* getIndex(TRI_idx_iid_t) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
//////////////////////////////////////////////////////////////////////////////
Index const* getIndex(std::string const&) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection uses the default sharding
//////////////////////////////////////////////////////////////////////////////

View File

@ -121,32 +121,6 @@ bool Index::supportsSortCondition(
itemsInIndex, estimatedCost);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get an iterator for the index
////////////////////////////////////////////////////////////////////////////////
arangodb::IndexIterator* Index::getIterator(
arangodb::Transaction* trx, arangodb::IndexIteratorContext* context,
arangodb::aql::Ast* ast, arangodb::aql::AstNode const* condition,
arangodb::aql::Variable const* reference, bool reverse) const {
TRI_ASSERT(hasInternals());
return getInternals()->iteratorForCondition(trx, context, ast, condition,
reference, reverse);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief specialize the condition for the index
/// this will remove all nodes from the condition that the index cannot
/// handle
////////////////////////////////////////////////////////////////////////////////
arangodb::aql::AstNode* Index::specializeCondition(
arangodb::aql::AstNode* node,
arangodb::aql::Variable const* reference) const {
TRI_ASSERT(hasInternals());
return getInternals()->specializeCondition(node, reference);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief append the index to an output stream
////////////////////////////////////////////////////////////////////////////////

View File

@ -181,26 +181,6 @@ struct Index {
arangodb::aql::Variable const*, size_t,
double&) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief get an iterator for the index
//////////////////////////////////////////////////////////////////////////////
arangodb::IndexIterator* getIterator(arangodb::Transaction*,
arangodb::IndexIteratorContext*,
arangodb::aql::Ast*,
arangodb::aql::AstNode const*,
arangodb::aql::Variable const*,
bool) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief specialize the condition for the index
/// this will remove all nodes from the condition that the index cannot
/// handle
//////////////////////////////////////////////////////////////////////////////
arangodb::aql::AstNode* specializeCondition(
arangodb::aql::AstNode*, arangodb::aql::Variable const*) const;
public:
TRI_idx_iid_t const id;
arangodb::Index::IndexType type;

View File

@ -619,7 +619,7 @@ QueryResult Query::execute(QueryRegistry* registry) {
AqlItemBlock* value = nullptr;
auto resultBuilder = std::make_shared<VPackBuilder>();
try {
VPackArrayBuilder guard(resultBuilder.get());
resultBuilder->openArray();
// this is the RegisterId our results can be found in
auto const resultRegister = _engine->resultRegister();
@ -639,6 +639,10 @@ QueryResult Query::execute(QueryRegistry* registry) {
delete value;
value = nullptr;
}
// must close result array here because it must be passed as a closed array
// to the query cache
resultBuilder->close();
if (_warnings.empty()) {
// finally store the generated result in the query cache
@ -666,6 +670,9 @@ QueryResult Query::execute(QueryRegistry* registry) {
delete value;
value = nullptr;
}
// must close result array
resultBuilder->close();
}
} catch (...) {
delete value;

View File

@ -340,6 +340,8 @@ bool HttpCommTask::processRead() {
TRI_invalidatesocket(&_commSocket);
// might delete this
// note that as we closed the socket above, the response will not make it to
// the client! will result in a "Empty reply from server" error in curl etc.
handleResponse(&response);
return false;

View File

@ -222,18 +222,14 @@ void RestJobHandler::getJobByType(std::string const& type) {
}
try {
VPackBuilder json;
json.add(VPackValue(VPackValueType::Array));
VPackBuilder result;
result.add(VPackValue(VPackValueType::Array));
size_t const n = ids.size();
for (size_t i = 0; i < n; ++i) {
char* idString = TRI_StringUInt64(ids[i]);
if (idString != nullptr) {
json.add(VPackValue(idString));
}
result.add(VPackValue(std::to_string(ids[i])));
}
json.close();
VPackSlice slice(json.start());
generateResult(slice);
result.close();
generateResult(result.slice());
} catch (...) {
generateError(HttpResponse::SERVER_ERROR, TRI_ERROR_OUT_OF_MEMORY);
}

View File

@ -782,6 +782,12 @@ function update_graph_edge (req, res, g, isPatch) {
}
var shallow = json._shallowCopy;
if (json.hasOwnProperty('_from')) {
shallow._from = json._from;
}
if (json.hasOwnProperty('_to')) {
shallow._to = json._to;
}
shallow.$label = e._properties.$label;
var id2 = null;

View File

@ -32,9 +32,6 @@
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief shallow copies properties
////////////////////////////////////////////////////////////////////////////////

View File

@ -205,7 +205,7 @@ SimpleQueryNear.prototype.execute = function () {
"@collection": this._collection.name(),
latitude: this._latitude,
longitude: this._longitude,
limit: this._limit
limit: parseInt(this._limit + this._skip, 10)
};
var mustSort = false;