1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/AvocadoDB into devel

Conflicts:
	js/common/modules/graph.js
This commit is contained in:
a-brandt 2012-04-25 16:30:18 +02:00
commit 402e49f8cc
7 changed files with 55 additions and 35 deletions

View File

@ -57,9 +57,9 @@ ERROR_AVOCADO_CORRUPTED_COLLECTION,1102,"corrupted collection","Will be raised w
ERROR_AVOCADO_MMAP_FAILED,1103,"mmap failed","Will be raised when the system call mmap failed." ERROR_AVOCADO_MMAP_FAILED,1103,"mmap failed","Will be raised when the system call mmap failed."
ERROR_AVOCADO_FILESYSTEM_FULL,1104,"filesystem full","Will be raised when the filesystem is full." ERROR_AVOCADO_FILESYSTEM_FULL,1104,"filesystem full","Will be raised when the filesystem is full."
ERROR_AVOCADO_NO_JOURNAL,1105,"no journal","Will be raised when a journal cannot be created." ERROR_AVOCADO_NO_JOURNAL,1105,"no journal","Will be raised when a journal cannot be created."
ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS,1106,"cannot create/rename datafile because it ready exists","Will be raised when the datafile cannot be created or renamed because a file of the same name already exists." ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS,1106,"cannot create/rename datafile because it already exists","Will be raised when the datafile cannot be created or renamed because a file of the same name already exists."
ERROR_AVOCADO_DATABASE_LOCKED,1107,"database is locked","Will be raised when the database is locked by a different process." ERROR_AVOCADO_DATABASE_LOCKED,1107,"database is locked","Will be raised when the database is locked by a different process."
ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS,1108,"cannot create/rename collection because directory ready exists","Will be raised when the collection cannot be created because a directory of the same name already exists." ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS,1108,"cannot create/rename collection because directory already exists","Will be raised when the collection cannot be created because a directory of the same name already exists."
################################################################################ ################################################################################
## AvocadoDB storage errors ## AvocadoDB storage errors

View File

@ -42,9 +42,9 @@ void TRI_InitialiseErrorMessages (void) {
REG_ERROR(ERROR_AVOCADO_MMAP_FAILED, "mmap failed"); REG_ERROR(ERROR_AVOCADO_MMAP_FAILED, "mmap failed");
REG_ERROR(ERROR_AVOCADO_FILESYSTEM_FULL, "filesystem full"); REG_ERROR(ERROR_AVOCADO_FILESYSTEM_FULL, "filesystem full");
REG_ERROR(ERROR_AVOCADO_NO_JOURNAL, "no journal"); REG_ERROR(ERROR_AVOCADO_NO_JOURNAL, "no journal");
REG_ERROR(ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS, "cannot create/rename datafile because it ready exists"); REG_ERROR(ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS, "cannot create/rename datafile because it already exists");
REG_ERROR(ERROR_AVOCADO_DATABASE_LOCKED, "database is locked"); REG_ERROR(ERROR_AVOCADO_DATABASE_LOCKED, "database is locked");
REG_ERROR(ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS, "cannot create/rename collection because directory ready exists"); REG_ERROR(ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS, "cannot create/rename collection because directory already exists");
REG_ERROR(ERROR_AVOCADO_CONFLICT, "conflict"); REG_ERROR(ERROR_AVOCADO_CONFLICT, "conflict");
REG_ERROR(ERROR_AVOCADO_WRONG_VOCBASE_PATH, "wrong path for database"); REG_ERROR(ERROR_AVOCADO_WRONG_VOCBASE_PATH, "wrong path for database");
REG_ERROR(ERROR_AVOCADO_DOCUMENT_NOT_FOUND, "document not found"); REG_ERROR(ERROR_AVOCADO_DOCUMENT_NOT_FOUND, "document not found");

View File

@ -77,12 +77,12 @@ extern "C" {
/// Will be raised when the filesystem is full. /// Will be raised when the filesystem is full.
/// - 1105: @CODE{no journal} /// - 1105: @CODE{no journal}
/// Will be raised when a journal cannot be created. /// Will be raised when a journal cannot be created.
/// - 1106: @CODE{cannot create/rename datafile because it ready exists} /// - 1106: @CODE{cannot create/rename datafile because it already exists}
/// Will be raised when the datafile cannot be created or renamed because a /// Will be raised when the datafile cannot be created or renamed because a
/// file of the same name already exists. /// file of the same name already exists.
/// - 1107: @CODE{database is locked} /// - 1107: @CODE{database is locked}
/// Will be raised when the database is locked by a different process. /// Will be raised when the database is locked by a different process.
/// - 1108: @CODE{cannot create/rename collection because directory ready exists} /// - 1108: @CODE{cannot create/rename collection because directory already exists}
/// Will be raised when the collection cannot be created because a directory /// Will be raised when the collection cannot be created because a directory
/// of the same name already exists. /// of the same name already exists.
/// - 1200: @CODE{conflict} /// - 1200: @CODE{conflict}
@ -597,7 +597,7 @@ void TRI_InitialiseErrorMessages (void);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief 1106: ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS /// @brief 1106: ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS
/// ///
/// cannot create/rename datafile because it ready exists /// cannot create/rename datafile because it already exists
/// ///
/// Will be raised when the datafile cannot be created or renamed because a /// Will be raised when the datafile cannot be created or renamed because a
/// file of the same name already exists. /// file of the same name already exists.
@ -618,7 +618,7 @@ void TRI_InitialiseErrorMessages (void);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief 1108: ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS /// @brief 1108: ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS
/// ///
/// cannot create/rename collection because directory ready exists /// cannot create/rename collection because directory already exists
/// ///
/// Will be raised when the collection cannot be created because a directory of /// Will be raised when the collection cannot be created because a directory of
/// the same name already exists. /// the same name already exists.

View File

@ -257,7 +257,7 @@ function getVertex(req, res) {
var v = g.getVertex(id); var v = g.getVertex(id);
if (v == undefined || v._properties == undefined) { if (v == undefined || v._properties == undefined) {
throw "no vertex found"; throw "no vertex found for: " + id;
} }
actions.resultOk(req, res, actions.HTTP_OK, { "vertex" : v._properties} ); actions.resultOk(req, res, actions.HTTP_OK, { "vertex" : v._properties} );
@ -296,7 +296,7 @@ function deleteVertex(req, res) {
var v = g.getVertex(id); var v = g.getVertex(id);
if (v == undefined || v._properties == undefined) { if (v == undefined || v._properties == undefined) {
throw "no vertex found"; throw "no vertex found for: " + id;
} }
g.removeVertex(v); g.removeVertex(v);
@ -483,10 +483,11 @@ function getEdge(req, res) {
id += "/" + req.suffix[1]; id += "/" + req.suffix[1];
} }
var e = g.getVertex(id);
var e = new graph.Edge(g, id);
if (e == undefined || e._properties == undefined) { if (e == undefined || e._properties == undefined) {
throw "no edge found"; throw "no edge found for: " + id + " " + e;
} }
actions.resultOk(req, res, actions.HTTP_OK, { "edge" : e._properties} ); actions.resultOk(req, res, actions.HTTP_OK, { "edge" : e._properties} );

View File

@ -36,9 +36,9 @@ ModuleCache["/internal"].exports.errors = {
"ERROR_AVOCADO_MMAP_FAILED" : { "code" : 1103, "message" : "mmap failed" }, "ERROR_AVOCADO_MMAP_FAILED" : { "code" : 1103, "message" : "mmap failed" },
"ERROR_AVOCADO_FILESYSTEM_FULL" : { "code" : 1104, "message" : "filesystem full" }, "ERROR_AVOCADO_FILESYSTEM_FULL" : { "code" : 1104, "message" : "filesystem full" },
"ERROR_AVOCADO_NO_JOURNAL" : { "code" : 1105, "message" : "no journal" }, "ERROR_AVOCADO_NO_JOURNAL" : { "code" : 1105, "message" : "no journal" },
"ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS" : { "code" : 1106, "message" : "cannot create/rename datafile because it ready exists" }, "ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS" : { "code" : 1106, "message" : "cannot create/rename datafile because it already exists" },
"ERROR_AVOCADO_DATABASE_LOCKED" : { "code" : 1107, "message" : "database is locked" }, "ERROR_AVOCADO_DATABASE_LOCKED" : { "code" : 1107, "message" : "database is locked" },
"ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS" : { "code" : 1108, "message" : "cannot create/rename collection because directory ready exists" }, "ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS" : { "code" : 1108, "message" : "cannot create/rename collection because directory already exists" },
"ERROR_AVOCADO_CONFLICT" : { "code" : 1200, "message" : "conflict" }, "ERROR_AVOCADO_CONFLICT" : { "code" : 1200, "message" : "conflict" },
"ERROR_AVOCADO_WRONG_VOCBASE_PATH" : { "code" : 1201, "message" : "wrong path for database" }, "ERROR_AVOCADO_WRONG_VOCBASE_PATH" : { "code" : 1201, "message" : "wrong path for database" },
"ERROR_AVOCADO_DOCUMENT_NOT_FOUND" : { "code" : 1202, "message" : "document not found" }, "ERROR_AVOCADO_DOCUMENT_NOT_FOUND" : { "code" : 1202, "message" : "document not found" },

View File

@ -37,9 +37,9 @@ static string JS_common_bootstrap_errors =
" \"ERROR_AVOCADO_MMAP_FAILED\" : { \"code\" : 1103, \"message\" : \"mmap failed\" }, \n" " \"ERROR_AVOCADO_MMAP_FAILED\" : { \"code\" : 1103, \"message\" : \"mmap failed\" }, \n"
" \"ERROR_AVOCADO_FILESYSTEM_FULL\" : { \"code\" : 1104, \"message\" : \"filesystem full\" }, \n" " \"ERROR_AVOCADO_FILESYSTEM_FULL\" : { \"code\" : 1104, \"message\" : \"filesystem full\" }, \n"
" \"ERROR_AVOCADO_NO_JOURNAL\" : { \"code\" : 1105, \"message\" : \"no journal\" }, \n" " \"ERROR_AVOCADO_NO_JOURNAL\" : { \"code\" : 1105, \"message\" : \"no journal\" }, \n"
" \"ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS\" : { \"code\" : 1106, \"message\" : \"cannot create/rename datafile because it ready exists\" }, \n" " \"ERROR_AVOCADO_DATAFILE_ALREADY_EXISTS\" : { \"code\" : 1106, \"message\" : \"cannot create/rename datafile because it already exists\" }, \n"
" \"ERROR_AVOCADO_DATABASE_LOCKED\" : { \"code\" : 1107, \"message\" : \"database is locked\" }, \n" " \"ERROR_AVOCADO_DATABASE_LOCKED\" : { \"code\" : 1107, \"message\" : \"database is locked\" }, \n"
" \"ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS\" : { \"code\" : 1108, \"message\" : \"cannot create/rename collection because directory ready exists\" }, \n" " \"ERROR_AVOCADO_COLLECTION_DIRECTORY_ALREADY_EXISTS\" : { \"code\" : 1108, \"message\" : \"cannot create/rename collection because directory already exists\" }, \n"
" \"ERROR_AVOCADO_CONFLICT\" : { \"code\" : 1200, \"message\" : \"conflict\" }, \n" " \"ERROR_AVOCADO_CONFLICT\" : { \"code\" : 1200, \"message\" : \"conflict\" }, \n"
" \"ERROR_AVOCADO_WRONG_VOCBASE_PATH\" : { \"code\" : 1201, \"message\" : \"wrong path for database\" }, \n" " \"ERROR_AVOCADO_WRONG_VOCBASE_PATH\" : { \"code\" : 1201, \"message\" : \"wrong path for database\" }, \n"
" \"ERROR_AVOCADO_DOCUMENT_NOT_FOUND\" : { \"code\" : 1202, \"message\" : \"document not found\" }, \n" " \"ERROR_AVOCADO_DOCUMENT_NOT_FOUND\" : { \"code\" : 1202, \"message\" : \"document not found\" }, \n"

View File

@ -98,7 +98,8 @@ findOrCreateCollectionByName = function (name) {
if (col === null) { if (col === null) {
col = internal.db._create(name); col = internal.db._create(name);
} else if (!(col instanceof AvocadoCollection)) { }
else if (!(col instanceof AvocadoCollection)) {
throw "<" + name + "> must be a document collection"; throw "<" + name + "> must be a document collection";
} }
@ -118,7 +119,8 @@ findOrCreateEdgeCollectionByName = function (name) {
if (col === null) { if (col === null) {
col = internal.edges._create(name); col = internal.edges._create(name);
} else if (!(col instanceof AvocadoEdgesCollection)) { }
else if (!(col instanceof AvocadoEdgesCollection)) {
throw "<" + name + "> must be a document collection"; throw "<" + name + "> must be a document collection";
} }
@ -162,7 +164,8 @@ function Edge(graph, id) {
if (props) { if (props) {
// extract the custom identifier, label, edges // extract the custom identifier, label, edges
this._properties = props; this._properties = props;
} else { }
else {
// deleted // deleted
throw "accessing a deleted edge"; throw "accessing a deleted edge";
} }
@ -354,13 +357,16 @@ Edge.prototype._PRINT = function (seen, path, names) {
if (!this._id) { if (!this._id) {
internal.output("[deleted Edge]"); internal.output("[deleted Edge]");
} else if (this._properties.$id !== undefined) { }
else if (this._properties.$id !== undefined) {
if (typeof this._properties.$id === "string") { if (typeof this._properties.$id === "string") {
internal.output("Edge(\"", this._properties.$id, "\")"); internal.output("Edge(\"", this._properties.$id, "\")");
} else { }
else {
internal.output("Edge(", this._properties.$id, ")"); internal.output("Edge(", this._properties.$id, ")");
} }
} else { }
else {
internal.output("Edge(<", this._id, ">)"); internal.output("Edge(<", this._id, ">)");
} }
}; };
@ -397,7 +403,8 @@ function Vertex(graph, id) {
if (props) { if (props) {
// extract the custom identifier // extract the custom identifier
this._properties = props; this._properties = props;
} else { }
else {
// deleted // deleted
throw "accessing a deleted edge"; throw "accessing a deleted edge";
} }
@ -544,7 +551,8 @@ Vertex.prototype.getInEdges = function () {
if (arguments.length === 0) { if (arguments.length === 0) {
result = this.inbound(); result = this.inbound();
} else { }
else {
labels = {}; labels = {};
for (i = 0; i < arguments.length; ++i) { for (i = 0; i < arguments.length; ++i) {
@ -583,7 +591,8 @@ Vertex.prototype.getOutEdges = function () {
if (arguments.length === 0) { if (arguments.length === 0) {
result = this.outbound(); result = this.outbound();
} else { }
else {
labels = {}; labels = {};
for (i = 0; i < arguments.length; ++i) { for (i = 0; i < arguments.length; ++i) {
labels[arguments[i]] = true; labels[arguments[i]] = true;
@ -766,13 +775,16 @@ Vertex.prototype._PRINT = function (seen, path, names) {
if (!this._id) { if (!this._id) {
internal.output("[deleted Vertex]"); internal.output("[deleted Vertex]");
} else if (this._properties.$id !== undefined) { }
else if (this._properties.$id !== undefined) {
if (typeof this._properties.$id === "string") { if (typeof this._properties.$id === "string") {
internal.output("Vertex(\"", this._properties.$id, "\")"); internal.output("Vertex(\"", this._properties.$id, "\")");
} else { }
else {
internal.output("Vertex(", this._properties.$id, ")"); internal.output("Vertex(", this._properties.$id, ")");
} }
} else { }
else {
internal.output("Vertex(<", this._id, ">)"); internal.output("Vertex(<", this._id, ">)");
} }
}; };
@ -862,11 +874,14 @@ function Graph(name, vertices, edges) {
if (edges === null) { if (edges === null) {
throw "edge collection '" + graphProperties.edges + "' has vanished"; throw "edge collection '" + graphProperties.edges + "' has vanished";
} }
} else if (typeof vertices !== "string" || vertices === "") { }
else if (typeof vertices !== "string" || vertices === "") {
throw "<vertices> must be a string or null"; throw "<vertices> must be a string or null";
} else if (typeof edges !== "string" || edges === "") { }
else if (typeof edges !== "string" || edges === "") {
throw "<edges> must be a string or null"; throw "<edges> must be a string or null";
} else { }
else {
// Create a new graph or get an existing graph // Create a new graph or get an existing graph
vertices = findOrCreateCollectionByName(vertices); vertices = findOrCreateCollectionByName(vertices);
edges = findOrCreateEdgeCollectionByName(edges); edges = findOrCreateEdgeCollectionByName(edges);
@ -895,10 +910,12 @@ function Graph(name, vertices, edges) {
'name' : name }); 'name' : name });
graphProperties = gdb.document(graphPropertiesId); graphProperties = gdb.document(graphPropertiesId);
} else { }
else {
throw "found graph but has different <name>"; throw "found graph but has different <name>";
} }
} else { }
else {
if (graphProperties.vertices !== vertices._id) { if (graphProperties.vertices !== vertices._id) {
throw "found graph but has different <vertices>"; throw "found graph but has different <vertices>";
} }
@ -1081,6 +1098,9 @@ Graph.prototype.getVertex = function (id) {
catch (e) { catch (e) {
vertex = null; vertex = null;
} }
}
else {
vertex = null;
} }
return vertex; return vertex;
@ -1326,6 +1346,5 @@ exports.Vertex = Vertex;
// Local Variables: // Local Variables:
// mode: outline-minor // mode: outline-minor
// outline-regexp: // outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End: // End: