mirror of https://gitee.com/bigwinds/arangodb
merge
This commit is contained in:
commit
6582ce9b8a
12
CHANGELOG
12
CHANGELOG
|
@ -1,3 +1,15 @@
|
|||
v2.2.0 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* removed sorting of attribute names for use in a collection's shaper
|
||||
|
||||
sorting attribute names was done on document insert to keep attributes
|
||||
of a collection in sorted order for faster comparisons. The sort order
|
||||
of attributes was only used in one particular and unlikey case, so it
|
||||
was removed. Collections with many different attribute names should
|
||||
benefit from this change by faster inserts and slightly less memory usage.
|
||||
|
||||
|
||||
v2.1.0 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
|
|
|
@ -536,8 +536,8 @@ SkiplistIndex* SkiplistIndex_new (TRI_primary_collection_t* primary,
|
|||
skiplistIndex->_numFields = numFields;
|
||||
skiplistIndex->unique = unique;
|
||||
skiplistIndex->sparse = sparse;
|
||||
skiplistIndex->skiplist = TRI_InitSkipList(CmpElmElm,CmpKeyElm,skiplistIndex,
|
||||
FreeElm,unique);
|
||||
skiplistIndex->skiplist = TRI_InitSkipList(CmpElmElm, CmpKeyElm, skiplistIndex,
|
||||
FreeElm, unique);
|
||||
if (skiplistIndex->skiplist == NULL) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, skiplistIndex);
|
||||
return NULL;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -47,11 +47,6 @@ struct TRI_document_collection_s;
|
|||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup VocBase
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief datafile attribute marker
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -75,19 +70,10 @@ typedef struct TRI_df_shape_marker_s {
|
|||
}
|
||||
TRI_df_shape_marker_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup VocBase
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a shaper
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -107,19 +93,10 @@ void TRI_DestroyVocShaper (TRI_shaper_t*);
|
|||
|
||||
void TRI_FreeVocShaper (TRI_shaper_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup VocBase
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys a shaper, but does not free the pointer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -182,10 +159,6 @@ int TRI_CompareShapeTypes (TRI_doc_mptr_t* leftDocument,
|
|||
TRI_shaper_t* leftShaper,
|
||||
TRI_shaper_t* rightShaper);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -204,7 +204,7 @@ static void ParseProgramOptions (int argc, char* argv[]) {
|
|||
("batch-size", &BatchSize, "number of operations in one batch (0 disables batching)")
|
||||
("keep-alive", &KeepAlive, "use HTTP keep-alive")
|
||||
("collection", &Collection, "collection name to use in tests")
|
||||
("test-case", &TestCase, "test case to use")
|
||||
("test-case", &TestCase, "test case to use (possible values: version, document, collection, hash, skiplist, edge, shapes, shapes-append, random-shapes, crud, crud-append, counttrx, multitrx)")
|
||||
("complexity", &Complexity, "complexity parameter for the test")
|
||||
("delay", &Delay, "use a startup delay (necessary only when run in series)")
|
||||
("progress", &Progress, "show progress")
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
# remove-on-drop = true
|
||||
|
||||
[server]
|
||||
disable-authentication = false
|
||||
endpoint = tcp://0.0.0.0:8888
|
||||
disable-authentication = true
|
||||
endpoint = tcp://localhost:8529
|
||||
threads = 5
|
||||
# reuse-address = false
|
||||
|
||||
|
@ -15,7 +15,7 @@ threads = 3
|
|||
[javascript]
|
||||
startup-directory = ./js
|
||||
app-path = ./js/apps
|
||||
frontend-development = true
|
||||
frontend-development = false
|
||||
|
||||
[ruby]
|
||||
action-directory = ./mr/actions/system
|
||||
|
@ -29,8 +29,8 @@ severity = human
|
|||
username = root
|
||||
password =
|
||||
|
||||
disable-dispatcher-kickstarter = false
|
||||
disable-dispatcher-frontend = false
|
||||
disable-dispatcher-kickstarter = true
|
||||
disable-dispatcher-frontend = true
|
||||
data-path = ./cluster/data
|
||||
log-path = ./cluster/log
|
||||
agent-path = ./bin/etcd-arango
|
||||
|
|
|
@ -33,7 +33,7 @@ var ArangoCollection = require("org/arangodb/arango-collection").ArangoCollectio
|
|||
|
||||
var arangodb = require("org/arangodb");
|
||||
|
||||
var ArangoError = arangodb.ArrangoError;
|
||||
var ArangoError = arangodb.ArangoError;
|
||||
var sprintf = arangodb.sprintf;
|
||||
var db = arangodb.db;
|
||||
|
||||
|
@ -528,29 +528,42 @@ ArangoCollection.prototype.closedRange = function (name, left, right) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a geo index selection
|
||||
///
|
||||
/// @FUN{@FA{collection}.geo(@FA{location})}
|
||||
////////////////////////////////////////////
|
||||
/// @FUN{@FA{collection}.geo(@FA{location-attribute})}
|
||||
//////////////////////////////////////////////////////
|
||||
///
|
||||
/// The next @FN{near} or @FN{within} operator will use the specific geo-spatial
|
||||
/// index.
|
||||
/// Looks up a geo index defined on attribute @FA{location-attribute}.
|
||||
///
|
||||
/// @FUN{@FA{collection}.geo(@FA{location}, @LIT{true})}
|
||||
////////////////////////////////////////////////////////
|
||||
/// Returns a geo index object if an index was found. The @FN{near} or
|
||||
/// @FN{within} operators can then be used to execute a geo-spatial query on
|
||||
/// this particular index.
|
||||
///
|
||||
/// The next @FN{near} or @FN{within} operator will use the specific geo-spatial
|
||||
/// index.
|
||||
/// This is useful for collections with multiple defined geo indexes.
|
||||
///
|
||||
/// @FUN{@FA{collection}.geo(@FA{latitude}, @FA{longitude})}
|
||||
////////////////////////////////////////////////////////////
|
||||
/// @FUN{@FA{collection}.geo(@FA{location-attribute}, @LIT{true})}
|
||||
//////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// The next @FN{near} or @FN{within} operator will use the specific geo-spatial
|
||||
/// index.
|
||||
/// Looks up a geo index on a compound attribute @FA{location-attribute}.
|
||||
///
|
||||
/// Returns a geo index object if an index was found. The @FN{near} or
|
||||
/// @FN{within} operators can then be used to execute a geo-spatial query on
|
||||
/// this particular index.
|
||||
///
|
||||
/// @FUN{@FA{collection}.geo(@FA{latitude-attribute}, @FA{longitude-attribute})}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// Looks up a geo index defined on the two attributes @FA{latitude-attribute}
|
||||
/// and @FA{longitude-attribute}.
|
||||
///
|
||||
/// Returns a geo index object if an index was found. The @FN{near} or
|
||||
/// @FN{within} operators can then be used to execute a geo-spatial query on
|
||||
/// this particular index.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Assume you have a location stored as list in the attribute @LIT{home}
|
||||
/// and a destination stored in the attribute @LIT{work}. Than you can use the
|
||||
/// @FN{geo} operator to select, which coordinates to use in a near query.
|
||||
/// and a destination stored in the attribute @LIT{work}. Then you can use the
|
||||
/// @FN{geo} operator to select which geo-spatial attributes (and thus which
|
||||
/// index) to use in a near query.
|
||||
///
|
||||
/// @TINYEXAMPLE{simple-query-geo,use a specific index}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -30,8 +30,9 @@
|
|||
|
||||
|
||||
var arangodb = require("org/arangodb"),
|
||||
ArangoCollection = arangodb.ArangoCollection,
|
||||
db = arangodb.db;
|
||||
ArangoCollection = arangodb.ArangoCollection,
|
||||
db = arangodb.db,
|
||||
_ = require("underscore");
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -48,10 +49,10 @@ var arangodb = require("org/arangodb"),
|
|||
|
||||
|
||||
var stringToArray = function (x) {
|
||||
if (typeof(x) === "string") {
|
||||
return [x];
|
||||
}
|
||||
return x;
|
||||
if (typeof(x) === "string") {
|
||||
return [x];
|
||||
}
|
||||
return x;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -61,16 +62,16 @@ var stringToArray = function (x) {
|
|||
|
||||
|
||||
var isValidCollectionsParameter = function (x) {
|
||||
if (!x) {
|
||||
return false;
|
||||
}
|
||||
if (Array.isArray(x) && x.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (typeof(x) !== "string" && !Array.isArray(x)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!x) {
|
||||
return false;
|
||||
}
|
||||
if (Array.isArray(x) && x.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (typeof(x) !== "string" && !Array.isArray(x)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -78,20 +79,20 @@ var isValidCollectionsParameter = function (x) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var findOrCreateCollectionByName = function (name, type) {
|
||||
var col = db._collection(name),res = false;
|
||||
if (col === null) {
|
||||
if (type === ArangoCollection.TYPE_DOCUMENT) {
|
||||
col = db._create(name);
|
||||
} else {
|
||||
col = db._createEdgeCollection(name);
|
||||
}
|
||||
res = true;
|
||||
} else if (!(col instanceof ArangoCollection) || col.type() !== type) {
|
||||
throw "<" + name + "> must be a " +
|
||||
(type === ArangoCollection.TYPE_DOCUMENT ? "document" : "edge")
|
||||
+ " collection";
|
||||
}
|
||||
return res;
|
||||
var col = db._collection(name),res = false;
|
||||
if (col === null) {
|
||||
if (type === ArangoCollection.TYPE_DOCUMENT) {
|
||||
col = db._create(name);
|
||||
} else {
|
||||
col = db._createEdgeCollection(name);
|
||||
}
|
||||
res = true;
|
||||
} else if (!(col instanceof ArangoCollection) || col.type() !== type) {
|
||||
throw "<" + name + "> must be a " +
|
||||
(type === ArangoCollection.TYPE_DOCUMENT ? "document" : "edge")
|
||||
+ " collection";
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -109,23 +110,23 @@ var findOrCreateCollectionByName = function (name, type) {
|
|||
|
||||
var _undirectedRelationDefinition = function (relationName, vertexCollections) {
|
||||
|
||||
if (arguments.length < 2) {
|
||||
throw "method _undirectedRelationDefinition expects 2 arguments";
|
||||
}
|
||||
if (arguments.length < 2) {
|
||||
throw "method _undirectedRelationDefinition expects 2 arguments";
|
||||
}
|
||||
|
||||
if (typeof relationName !== "string" || relationName === "") {
|
||||
throw "<relationName> must be a not empty string";
|
||||
}
|
||||
if (typeof relationName !== "string" || relationName === "") {
|
||||
throw "<relationName> must be a not empty string";
|
||||
}
|
||||
|
||||
if (!isValidCollectionsParameter(vertexCollections)) {
|
||||
throw "<vertexCollections> must be a not empty string or array";
|
||||
}
|
||||
if (!isValidCollectionsParameter(vertexCollections)) {
|
||||
throw "<vertexCollections> must be a not empty string or array";
|
||||
}
|
||||
|
||||
return {
|
||||
collection: "relationName",
|
||||
from: stringToArray(vertexCollections),
|
||||
to: stringToArray(vertexCollections)
|
||||
};
|
||||
return {
|
||||
collection: relationName,
|
||||
from: stringToArray(vertexCollections),
|
||||
to: stringToArray(vertexCollections)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
@ -135,29 +136,29 @@ var _undirectedRelationDefinition = function (relationName, vertexCollections) {
|
|||
|
||||
|
||||
var _directedRelationDefinition = function (
|
||||
relationName, fromVertexCollections, toVertexCollections) {
|
||||
relationName, fromVertexCollections, toVertexCollections) {
|
||||
|
||||
if (arguments.length < 3) {
|
||||
throw "method _undirectedRelationDefinition expects 3 arguments";
|
||||
}
|
||||
if (arguments.length < 3) {
|
||||
throw "method _undirectedRelationDefinition expects 3 arguments";
|
||||
}
|
||||
|
||||
if (typeof relationName !== "string" || relationName === "") {
|
||||
throw "<relationName> must be a not empty string";
|
||||
}
|
||||
if (typeof relationName !== "string" || relationName === "") {
|
||||
throw "<relationName> must be a not empty string";
|
||||
}
|
||||
|
||||
if (!isValidCollectionsParameter(fromVertexCollections)) {
|
||||
throw "<fromVertexCollections> must be a not empty string or array";
|
||||
}
|
||||
if (!isValidCollectionsParameter(fromVertexCollections)) {
|
||||
throw "<fromVertexCollections> must be a not empty string or array";
|
||||
}
|
||||
|
||||
if (!isValidCollectionsParameter(toVertexCollections)) {
|
||||
throw "<toVertexCollections> must be a not empty string or array";
|
||||
}
|
||||
if (!isValidCollectionsParameter(toVertexCollections)) {
|
||||
throw "<toVertexCollections> must be a not empty string or array";
|
||||
}
|
||||
|
||||
return {
|
||||
collection: "relationName",
|
||||
from: stringToArray(fromVertexCollections),
|
||||
to: stringToArray(toVertexCollections)
|
||||
};
|
||||
return {
|
||||
collection: relationName,
|
||||
from: stringToArray(fromVertexCollections),
|
||||
to: stringToArray(toVertexCollections)
|
||||
};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -167,12 +168,12 @@ var _directedRelationDefinition = function (
|
|||
|
||||
var edgeDefinitions = function () {
|
||||
|
||||
var res = [], args = arguments;
|
||||
Object.keys(args).forEach(function (x) {
|
||||
res.push(args[x]);
|
||||
});
|
||||
var res = [], args = arguments;
|
||||
Object.keys(args).forEach(function (x) {
|
||||
res.push(args[x]);
|
||||
});
|
||||
|
||||
return res;
|
||||
return res;
|
||||
|
||||
};
|
||||
|
||||
|
@ -183,54 +184,51 @@ var edgeDefinitions = function () {
|
|||
|
||||
var _create = function (graphName, edgeDefinitions) {
|
||||
|
||||
var gdb = db._collection("_graphs"),
|
||||
g,
|
||||
graphAlreadyExists = true,
|
||||
createdCollections = []
|
||||
;
|
||||
var gdb = db._collection("_graphs"),
|
||||
g,
|
||||
graphAlreadyExists = true;
|
||||
|
||||
if (gdb === null) {
|
||||
throw "_graphs collection does not exist.";
|
||||
}
|
||||
if (gdb === null) {
|
||||
throw "_graphs collection does not exist.";
|
||||
}
|
||||
|
||||
if (!graphName) {
|
||||
throw "a graph name is required to create a graph.";
|
||||
}
|
||||
if (!Array.isArray(edgeDefinitions) || edgeDefinitions.length === 0) {
|
||||
throw "at least one edge definition is required to create a graph.";
|
||||
}
|
||||
if (!graphName) {
|
||||
throw "a graph name is required to create a graph.";
|
||||
}
|
||||
if (!Array.isArray(edgeDefinitions) || edgeDefinitions.length === 0) {
|
||||
throw "at least one edge definition is required to create a graph.";
|
||||
}
|
||||
|
||||
try {
|
||||
g = gdb.document(graphName);
|
||||
} catch (e) {
|
||||
if (e.errorNum !== 1202) {
|
||||
throw e;
|
||||
}
|
||||
graphAlreadyExists = false;
|
||||
}
|
||||
try {
|
||||
g = gdb.document(graphName);
|
||||
} catch (e) {
|
||||
if (e.errorNum !== 1202) {
|
||||
throw e;
|
||||
}
|
||||
graphAlreadyExists = false;
|
||||
}
|
||||
|
||||
if (graphAlreadyExists) {
|
||||
throw "graph " + graphName + " already exists.";
|
||||
}
|
||||
if (graphAlreadyExists) {
|
||||
throw "graph " + graphName + " already exists.";
|
||||
}
|
||||
|
||||
edgeDefinitions.forEach(function (e) {
|
||||
e.from.concat(e.to).forEach(function (v) {
|
||||
if (findOrCreateCollectionByName(v, ArangoCollection.TYPE_DOCUMENT)) {
|
||||
createdCollections.push(v);
|
||||
}
|
||||
});
|
||||
if (findOrCreateCollectionByName(e.collection, ArangoCollection.TYPE_EDGE)) {
|
||||
createdCollections.push(e.collection);
|
||||
}
|
||||
});
|
||||
var vertexCollections = {};
|
||||
var edgeCollections = {};
|
||||
edgeDefinitions.forEach(function (e) {
|
||||
e.from.concat(e.to).forEach(function (v) {
|
||||
findOrCreateCollectionByName(v, ArangoCollection.TYPE_DOCUMENT);
|
||||
vertexCollections[v] = db[v];
|
||||
});
|
||||
findOrCreateCollectionByName(e.collection, ArangoCollection.TYPE_EDGE);
|
||||
edgeCollections[e.collection] = db[e.collection];
|
||||
});
|
||||
|
||||
gdb.save({
|
||||
'edgeDefinitions' : edgeDefinitions,
|
||||
'_key' : graphName
|
||||
});
|
||||
|
||||
return new Graph(graphName, edgeDefinitions);
|
||||
gdb.save({
|
||||
'edgeDefinitions' : edgeDefinitions,
|
||||
'_key' : graphName
|
||||
});
|
||||
|
||||
return new Graph(graphName, edgeDefinitions, vertexCollections, edgeCollections);
|
||||
};
|
||||
|
||||
|
||||
|
@ -239,7 +237,20 @@ var _create = function (graphName, edgeDefinitions) {
|
|||
/// @brief load a graph.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var Graph = function(graphName, edgeDefinitions) {
|
||||
var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollections) {
|
||||
var self = this;
|
||||
this.__vertexCollections = vertexCollections;
|
||||
this.__edgeCollections = edgeCollections;
|
||||
this.__edgeDefinitions = edgeDefinitions;
|
||||
|
||||
|
||||
_.each(vertexCollections, function(obj, key) {
|
||||
self[key] = obj;
|
||||
});
|
||||
|
||||
_.each(edgeCollections, function(obj, key) {
|
||||
self[key] = obj;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
@ -247,14 +258,20 @@ var _graph = function() {
|
|||
return new Graph();
|
||||
};
|
||||
|
||||
Graph.prototype.edgeCollections = function() {
|
||||
//testdummy
|
||||
return [require("internal").db.w3];
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return all edge collections of the graph.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype._edgeCollections = function() {
|
||||
return _.values(this.__edgeCollections);
|
||||
};
|
||||
|
||||
Graph.prototype.vertexCollections = function() {
|
||||
//testdummy
|
||||
return [require("internal").db.a, require("internal").db.b];
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return all vertex collections of the graph.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype._vertexCollections = function() {
|
||||
return _.values(this.__vertexCollections);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -262,7 +279,7 @@ Graph.prototype.vertexCollections = function() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.edges = function(vertexId) {
|
||||
var edgeCollections = this.edgeCollections();
|
||||
var edgeCollections = this._edgeCollections();
|
||||
var result = [];
|
||||
|
||||
|
||||
|
@ -280,7 +297,7 @@ Graph.prototype.edges = function(vertexId) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.inEdges = function(vertexId) {
|
||||
var edgeCollections = this.edgeCollections();
|
||||
var edgeCollections = this._edgeCollections();
|
||||
var result = [];
|
||||
|
||||
|
||||
|
@ -298,7 +315,7 @@ Graph.prototype.inEdges = function(vertexId) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.outEdges = function(vertexId) {
|
||||
var edgeCollections = this.edgeCollections();
|
||||
var edgeCollections = this._edgeCollections();
|
||||
var result = [];
|
||||
|
||||
|
||||
|
@ -316,11 +333,11 @@ Graph.prototype.outEdges = function(vertexId) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.getInVertex = function(edgeId) {
|
||||
var edgeCollection = this.getEdgeCollectionByName(edgeId.split("/")[0]);
|
||||
var edgeCollection = this._getEdgeCollectionByName(edgeId.split("/")[0]);
|
||||
var document = edgeCollection.document(edgeId);
|
||||
if (document) {
|
||||
var vertexId = document._from;
|
||||
var vertexCollection = this.getVertexCollectionByName(vertexId.split("/")[0]);
|
||||
var vertexCollection = this._getVertexCollectionByName(vertexId.split("/")[0]);
|
||||
return vertexCollection.document(vertexId);
|
||||
}
|
||||
};
|
||||
|
@ -330,11 +347,11 @@ Graph.prototype.getInVertex = function(edgeId) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.getOutVertex = function(edgeId) {
|
||||
var edgeCollection = this.getEdgeCollectionByName(edgeId.split("/")[0]);
|
||||
var edgeCollection = this._getEdgeCollectionByName(edgeId.split("/")[0]);
|
||||
var document = edgeCollection.document(edgeId);
|
||||
if (document) {
|
||||
var vertexId = document._to;
|
||||
var vertexCollection = this.getVertexCollectionByName(vertexId.split("/")[0]);
|
||||
var vertexCollection = this._getVertexCollectionByName(vertexId.split("/")[0]);
|
||||
return vertexCollection.document(vertexId);
|
||||
}
|
||||
};
|
||||
|
@ -344,16 +361,9 @@ Graph.prototype.getOutVertex = function(edgeId) {
|
|||
/// @brief get edge collection by name.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.getEdgeCollectionByName = function(name) {
|
||||
var edgeCollections = this.edgeCollections();
|
||||
var results = edgeCollections.filter(
|
||||
function(edgeCollection) {
|
||||
return edgeCollection.name() === name;
|
||||
}
|
||||
);
|
||||
|
||||
if (results.length === 1) {
|
||||
return results[0];
|
||||
Graph.prototype._getEdgeCollectionByName = function(name) {
|
||||
if (this.__edgeCollections[name]) {
|
||||
return this.__edgeCollections[name];
|
||||
}
|
||||
throw "Collection " + name + " does not exist in graph.";
|
||||
};
|
||||
|
@ -362,16 +372,9 @@ Graph.prototype.getEdgeCollectionByName = function(name) {
|
|||
/// @brief get vertex collection by name.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Graph.prototype.getVertexCollectionByName = function(name) {
|
||||
var vertexCollections = this.vertexCollections();
|
||||
var results = vertexCollections.filter(
|
||||
function(vertexCollection) {
|
||||
return vertexCollection.name() === name;
|
||||
}
|
||||
);
|
||||
|
||||
if (results.length === 1) {
|
||||
return results[0];
|
||||
Graph.prototype._getVertexCollectionByName = function(name) {
|
||||
if (this.__vertexCollections[name]) {
|
||||
return this.__vertexCollections[name];
|
||||
}
|
||||
throw "Collection " + name + " does not exist in graph.";
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Florian Bartels
|
||||
/// @author Florian Bartels, Michael Hackstein
|
||||
/// @author Copyright 2014, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -33,7 +33,7 @@ var jsunity = require("jsunity");
|
|||
var arangodb = require("org/arangodb");
|
||||
|
||||
var console = require("console");
|
||||
var graph = require("org/arangodb/general-graph")
|
||||
var graph = require("org/arangodb/general-graph");
|
||||
|
||||
var print = arangodb.print;
|
||||
|
||||
|
@ -223,7 +223,6 @@ function GeneralGraphCreationSuite() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*test_create : function () {
|
||||
|
||||
|
||||
|
@ -242,11 +241,160 @@ function GeneralGraphCreationSuite() {
|
|||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- Simple Queries
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function GeneralGraphSimpleQueriesSuite() {
|
||||
|
||||
var dropInclExcl = function() {
|
||||
var col = require("internal").db._collection("_graphs");
|
||||
try {
|
||||
col.remove("graph");
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
var createInclExcl = function() {
|
||||
dropInclExcl();
|
||||
var inc = graph._directedRelationDefinition("included", ["v1"], ["v1", "v2"]);
|
||||
var exc = graph._directedRelationDefinition("excluded", ["v1"], ["v3"]);
|
||||
var g = graph._create("graph", [inc, exc]);
|
||||
return g;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test: restrict construct on edges
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
test_restrictOnEdges: function() {
|
||||
var g = createInclExcl();
|
||||
var incEdge1 = g.included.save(
|
||||
"v1/1",
|
||||
"v2/1",
|
||||
{
|
||||
included: true
|
||||
}
|
||||
);
|
||||
var incEdge2 = g.included.save(
|
||||
"v1/2",
|
||||
"v1/1",
|
||||
{
|
||||
included: true
|
||||
}
|
||||
);
|
||||
var excEdge = g.excluded.save(
|
||||
"v1/1",
|
||||
"v3/1",
|
||||
{
|
||||
included: false
|
||||
}
|
||||
);
|
||||
/*
|
||||
var result = g.edges().restrict("v1");
|
||||
assertEqual(result.length, 2);
|
||||
assertNotEqual(result.indexOf(incEdge1), -1);
|
||||
assertNotEqual(result.indexOf(incEdge2), -1);
|
||||
assertEqual(result.indexOf(excEdge), -1);
|
||||
*/
|
||||
dropInclExcl();
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test: restrict construct on inEdges
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
test_restrictOnInEdges: function() {
|
||||
var g = createInclExcl();
|
||||
var excEdge1 = g.included.save(
|
||||
"v1/1",
|
||||
"v2/1",
|
||||
{
|
||||
included: false
|
||||
}
|
||||
);
|
||||
var incEdge = g.included.save(
|
||||
"v1/2",
|
||||
"v1/1",
|
||||
{
|
||||
included: true
|
||||
}
|
||||
);
|
||||
var excEdge2 = g.excluded.save(
|
||||
"v1/1",
|
||||
"v3/1",
|
||||
{
|
||||
included: false
|
||||
}
|
||||
);
|
||||
/*
|
||||
var result = g.edges().restrict("v1");
|
||||
assertEqual(result.length, 1);
|
||||
assertEqual(result.indexOf(excEdge1), -1);
|
||||
assertNotEqual(result.indexOf(incEdge), -1);
|
||||
assertEqual(result.indexOf(excEdge2), -1);
|
||||
*/
|
||||
dropInclExcl();
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test: restrict construct on outEdges
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
test_restrictOnOutEdges: function() {
|
||||
var g = createInclExcl();
|
||||
var incEdge = g.included.save(
|
||||
"v1/1",
|
||||
"v2/1",
|
||||
{
|
||||
included: true
|
||||
}
|
||||
);
|
||||
var excEdge1 = g.included.save(
|
||||
"v1/2",
|
||||
"v1/1",
|
||||
{
|
||||
included: false
|
||||
}
|
||||
);
|
||||
var excEdge2 = g.excluded.save(
|
||||
"v1/1",
|
||||
"v3/1",
|
||||
{
|
||||
included: false
|
||||
}
|
||||
);
|
||||
/*
|
||||
var result = g.edges().restrict("v1");
|
||||
assertEqual(result.length, 1);
|
||||
assertNotEqual(result.indexOf(incEdge), -1);
|
||||
assertEqual(result.indexOf(excEdge1), -1);
|
||||
assertEqual(result.indexOf(excEdge2), -1);
|
||||
*/
|
||||
dropInclExcl();
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test: filter construct on Edges
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
test_filterOnEdges: function() {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- main
|
||||
|
@ -257,6 +405,7 @@ function GeneralGraphCreationSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
jsunity.run(GeneralGraphCreationSuite);
|
||||
jsunity.run(GeneralGraphSimpleQueriesSuite);
|
||||
|
||||
return jsunity.done();
|
||||
|
||||
|
|
|
@ -505,6 +505,14 @@ TRI_shape_t* TRI_LookupBasicShapeShaper (TRI_shape_t const* shape) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the first id for user-defined shapes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_shape_sid_t TRI_FirstCustomShapeIdShaper () {
|
||||
return 7;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialises global basic shape types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -555,6 +563,8 @@ void TRI_InitialiseShaper () {
|
|||
shape->_type = TRI_SHAPE_LIST;
|
||||
shape->_dataSize = TRI_SHAPE_SIZE_VARIABLE;
|
||||
shape->_sid = BasicShapes._sidList = 6;
|
||||
|
||||
assert(shape->_sid + 1 == TRI_FirstCustomShapeIdShaper());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -165,6 +165,12 @@ TRI_shape_t* TRI_LookupSidBasicShapeShaper (TRI_shape_sid_t);
|
|||
|
||||
TRI_shape_t* TRI_LookupBasicShapeShaper (TRI_shape_t const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the first id for user-defined shapes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_shape_sid_t TRI_FirstCustomShapeIdShaper (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialises global basic shape types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -75,25 +75,8 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc
|
|||
paids = (TRI_shape_aid_t*) (((char const*) path) + sizeof(TRI_shape_path_t));
|
||||
|
||||
// collect the bytecode
|
||||
// we need at least 4 entries in the vector to store an accessor
|
||||
TRI_InitVectorPointer2(&ops, shaper->_memoryZone, 4);
|
||||
|
||||
// start with the shape
|
||||
res = TRI_PushBackVectorPointer(&ops, (void*) TRI_SHAPE_AC_SHAPE_PTR);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("out of memory");
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
return false;
|
||||
}
|
||||
|
||||
res = TRI_PushBackVectorPointer(&ops, CONST_CAST(shape));
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("out of memory");
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
return false;
|
||||
}
|
||||
// we need at least 2 entries in the vector to store an accessor
|
||||
TRI_InitVectorPointer2(&ops, shaper->_memoryZone, 2);
|
||||
|
||||
// and follow it
|
||||
for (i = 0; i < path->_aidLength; ++i, ++paids) {
|
||||
|
@ -179,22 +162,6 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc
|
|||
return false;
|
||||
}
|
||||
|
||||
res = TRI_PushBackVectorPointer(&ops, (void*) TRI_SHAPE_AC_SHAPE_PTR);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("out of memory");
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
return false;
|
||||
}
|
||||
|
||||
res = TRI_PushBackVectorPointer(&ops, CONST_CAST(shape));
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("out of memory");
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -240,22 +207,6 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc
|
|||
return false;
|
||||
}
|
||||
|
||||
res = TRI_PushBackVectorPointer(&ops, (void*) TRI_SHAPE_AC_SHAPE_PTR);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("out of memory");
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
return false;
|
||||
}
|
||||
|
||||
res = TRI_PushBackVectorPointer(&ops, CONST_CAST(shape));
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_ERROR("out of memory");
|
||||
TRI_DestroyVectorPointer(&ops);
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -333,10 +284,6 @@ static bool ExecuteBytecodeShapeAccessor (TRI_shape_access_t const* accessor,
|
|||
case TRI_SHAPE_AC_DONE:
|
||||
return true;
|
||||
|
||||
case TRI_SHAPE_AC_SHAPE_PTR:
|
||||
ops++;
|
||||
break;
|
||||
|
||||
case TRI_SHAPE_AC_OFFSET_FIX:
|
||||
b = (TRI_shape_size_t) (uintptr_t) *ops++; // offset is always smaller than 4 GByte
|
||||
e = (TRI_shape_size_t) (uintptr_t) *ops++; // offset is always smaller than 4 GByte
|
||||
|
@ -478,13 +425,6 @@ void TRI_PrintShapeAccessor (TRI_shape_access_t* accessor) {
|
|||
case TRI_SHAPE_AC_DONE:
|
||||
return;
|
||||
|
||||
case TRI_SHAPE_AC_SHAPE_PTR:
|
||||
shape = static_cast<TRI_shape_t const*>(*ops++);
|
||||
|
||||
printf(" OP: shape %lu\n",
|
||||
(unsigned long) shape->_sid);
|
||||
break;
|
||||
|
||||
case TRI_SHAPE_AC_OFFSET_FIX:
|
||||
b = (TRI_shape_size_t) (uintptr_t) *ops++; // offset is always smaller than 4 GByte
|
||||
e = (TRI_shape_size_t) (uintptr_t) *ops++; // offset is always smaller than 4 GByte
|
||||
|
|
|
@ -62,14 +62,13 @@ typedef struct TRI_shape_access_s {
|
|||
TRI_shape_access_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief size of short strings
|
||||
/// @brief shape accessor bytecode operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
TRI_SHAPE_AC_DONE = 1,
|
||||
TRI_SHAPE_AC_SHAPE_PTR = 2,
|
||||
TRI_SHAPE_AC_OFFSET_FIX = 3,
|
||||
TRI_SHAPE_AC_OFFSET_VAR = 4
|
||||
TRI_SHAPE_AC_DONE = 1,
|
||||
TRI_SHAPE_AC_OFFSET_FIX = 2,
|
||||
TRI_SHAPE_AC_OFFSET_VAR = 3
|
||||
}
|
||||
TRI_shape_ac_bc_e;
|
||||
|
||||
|
|
Loading…
Reference in New Issue