diff --git a/CHANGELOG b/CHANGELOG index 25d52eb95a..30edd0bfdc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,11 @@ v2.2.0 (XXXX-XX-XX) * added mountedApp function for foxx-manager +* fixed issue #883: arango 2.1 - when starting multi-machine cluster, UI web + does not change to cluster overview + +* fixed dfdb: should not start any other V8 threads + * cleanup of version-check, added module org/arangodb/database-version, added --check-version option diff --git a/Documentation/Books/Makefile b/Documentation/Books/Makefile index 5e6fa9f36a..a1aac950ea 100644 --- a/Documentation/Books/Makefile +++ b/Documentation/Books/Makefile @@ -3,6 +3,7 @@ all: build-books .PHONY: md-files MDPP_FILES = $(wildcard *.mdpp */*.mdpp */*/*.mdpp) +MD_FILES = $(wildcard Users/*/*.md) md-files: @for file in $(basename $(MDPP_FILES)); do echo "converting $${file}.mdpp"; markdown-pp.py $${file}.mdpp $${file}.md; done @@ -18,3 +19,5 @@ build-book: @test -d books/$(NAME) || mkdir books/$(NAME) cd $(NAME) && gitbook build -o ../books/$(NAME) cp Users/arangodb_logo2.png books/Users/ + @for file in $(basename $(MD_FILES)); do echo "remove $${file}.md";rm $${file}.md;done + \ No newline at end of file diff --git a/Documentation/Books/Users/Collections/CollectionAddress.mdpp b/Documentation/Books/Users/Collections/CollectionAddress.mdpp deleted file mode 100644 index 51f7528fd5..0000000000 --- a/Documentation/Books/Users/Collections/CollectionAddress.mdpp +++ /dev/null @@ -1,32 +0,0 @@ -!CHAPTER Address of a Collection - -All collections in ArangoDB have an unique identifier and an unique -name. ArangoDB internally uses the collection's unique identifier to look up -collections. This identifier, however, is managed by ArangoDB and the user has -no control over it. In order to allow users to use their own names, each collection - also has an unique name which is specified by the user. To access a collection -from the user perspective, the collection name should be used, i.e.: - -*db._collection(collection-name)* - -A collection is created by a ["db._create"](../Collections/DatabaseMethods.md) call. - -For example: Assume that the collection identifier is `7254820` and the name is -`demo`, then the collection can be accessed as: - - db._collection("demo") - -If no collection with such a name exists, then *null* is returned. - -There is a short-cut that can be used for non-system collections: - -*db.collection-name* - -This call will either return the collection named *db.collection-name* or create -a new one with that name and a set of default properties. - -Note: Creating a collection on the fly using *db.collection-name* is -not recommend and does not work in _arangosh_. To create a new collection, please -use - -*db._create(collection-name)* diff --git a/Documentation/Books/Users/Collections/CollectionMethods.mdpp b/Documentation/Books/Users/Collections/CollectionMethods.mdpp index acce41fad0..78d6839c88 100644 --- a/Documentation/Books/Users/Collections/CollectionMethods.mdpp +++ b/Documentation/Books/Users/Collections/CollectionMethods.mdpp @@ -1,6 +1,7 @@ !CHAPTER Collection Methods `collection.drop()` + Drops a collection and all its indexes. *Examples* diff --git a/Documentation/Books/Users/Collections/README.mdpp b/Documentation/Books/Users/Collections/README.mdpp index 63f173a91a..c07b5367a8 100644 --- a/Documentation/Books/Users/Collections/README.mdpp +++ b/Documentation/Books/Users/Collections/README.mdpp @@ -7,4 +7,40 @@ corresponding language API. The most import call is the call to create a new collection \ No newline at end of file +--> + + +!SECTION Address of a Collection + +All collections in ArangoDB have an unique identifier and an unique +name. ArangoDB internally uses the collection's unique identifier to look up +collections. This identifier, however, is managed by ArangoDB and the user has +no control over it. In order to allow users to use their own names, each collection + also has an unique name which is specified by the user. To access a collection +from the user perspective, the collection name should be used, i.e.: + +`db._collection(collection-name)`` + +A collection is created by a ["db._create"](../Collections/DatabaseMethods.md) call. + +For example: Assume that the collection identifier is `7254820` and the name is +`demo`, then the collection can be accessed as: + + db._collection("demo") + +If no collection with such a name exists, then *null* is returned. + +There is a short-cut that can be used for non-system collections: + +*db.collection-name* + +This call will either return the collection named *db.collection-name* or create +a new one with that name and a set of default properties. + +Note: Creating a collection on the fly using *db.collection-name* is +not recommend and does not work in _arangosh_. To create a new collection, please +use + +`db._create(collection-name)` + +This call will create a new collection called *collection-name*. \ No newline at end of file diff --git a/Documentation/Books/Users/Databases/Notes.mdpp b/Documentation/Books/Users/Databases/Notes.mdpp index 2f15d6617b..cbaf967283 100644 --- a/Documentation/Books/Users/Databases/Notes.mdpp +++ b/Documentation/Books/Users/Databases/Notes.mdpp @@ -1,10 +1,12 @@ !CHAPTER Notes about Databases Please keep in mind that each database contains its own system collections, -which need to set up when a database is created. This will make the creation -of a database take a while. Replication is configured on a per-database level, -meaning that any replication logging or applying for a new database must -be configured explicitly after a new database has been created. Foxx applications +which need to set up when a database is created. This will make the creation of a database take a while. + +Replication is configured on a per-database level, meaning that any replication logging or applying for a new database must +be configured explicitly after a new database has been created. + +Foxx applications are also available only in the context of the database they have been installed in. A new database will only provide access to the system applications shipped with ArangoDB (that is the web interface at the moment) and no other Foxx diff --git a/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp b/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp index ab200607aa..e99b443980 100644 --- a/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp +++ b/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp @@ -1,10 +1,19 @@ !CHAPTER Fluent AQL Interface -TODO: write intro +This chapter describes a fluent interface to query your graph. +The philosophy of this interface is to at first select a group of starting elements (vertices or edges) and from there on explore the graph with your query by selecting connected elements. +As an example you can start with a set of vertices, select their direct neighbors and finally their outgoing edges. +The result of this query will be the set of outgoing edges. +For each part of the query it is possible to further refine the resulting set of elements by giving examples for them. !SECTION Starting Points -TODO: write intro +This section describes the entry points for the fluent interface. +In the philosophy of this module you have to start with a specific subset of vertices or edges and from there on iterate over the graph. +Therefore you get exactly this two entry points: + +* Select a set of edges +* Select a set of vertices !SUBSECTION Edges @@ -24,7 +33,7 @@ The resulting set of edges can be filtered by defining one or more `examples`. * A string, only the edge having this value as it's id is returned. * An example object, defining a set of attributes. Only edges having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All edges matching at least one of the elements in the list are returned.
@EXAMPLES @@ -67,7 +76,7 @@ The resulting set of edges can be filtered by defining one or more `examples`. * A string, only the vertex having this value as it's id is returned. * An example object, defining a set of attributes. Only vertices having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All vertices matching at least one of the elements in the list are returned.
@EXAMPLES @@ -92,7 +101,13 @@ g._vertices([{name: "Alice"}, {name: "Bob"}]).toArray(); @END_EXAMPLE_ARANGOSH_OUTPUT -!SECTION Fluent query options +!SECTION Working with the query cursor + +The fluent query object handles cursor creation and maintenance for you. +A cursor will be created as soon as you request the first result. +If you are unhappy with the current result and want to refine it further you can execute a further step in the query which cleans up the cursor for you. +In this interface you get the complete functionality available for general AQL cursors directly on your query. +The cursor functionality is described in this section. !SUBSECTION ToArray @@ -219,6 +234,13 @@ query.count(); @END_EXAMPLE_ARANGOSH_OUTPUT +!SECTION Fluent queries + +After the selection of the entry point you can now query your graph in +a fluent way, meaning each of the functions on your query returns the query again. +Hence it is possible to chain arbitrary many executions one after the other. +In this section all available query statements are described. + !SUBSECTION Edges @@ -236,7 +258,7 @@ The resulting set of edges can be filtered by defining one or more `examples`. * A string, only the edge having this value as it's id is returned. * An example object, defining a set of attributes. Only edges having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All edges matching at least one of the elements in the list are returned.
@EXAMPLES @@ -287,7 +309,7 @@ The resulting set of edges can be filtered by defining one or more `examples`. * A string, only the edge having this value as it's id is returned. * An example object, defining a set of attributes. Only edges having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All edges matching at least one of the elements in the list are returned.
@EXAMPLES @@ -338,7 +360,7 @@ The resulting set of edges can be filtered by defining one or more `examples`. * A string, only the edge having this value as it's id is returned. * An example object, defining a set of attributes. Only edges having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All edges matching at least one of the elements in the list are returned.
@EXAMPLES @@ -390,7 +412,7 @@ The resulting set of vertices can be filtered by defining one or more `examples` * A string, only the vertex having this value as it's id is returned. * An example object, defining a set of attributes. Only vertices having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All vertices matching at least one of the elements in the list are returned.
@EXAMPLES @@ -442,7 +464,7 @@ The resulting set of vertices can be filtered by defining one or more `examples` * A string, only the vertex having this value as it's id is returned. * An example object, defining a set of attributes. Only vertices having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All vertices matching at least one of the elements in the list are returned.
@EXAMPLES @@ -494,7 +516,7 @@ The resulting set of vertices can be filtered by defining one or more `examples` * A string, only the vertex having this value as it's id is returned. * An example object, defining a set of attributes. Only vertices having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All vertices matching at least one of the elements in the list are returned.
@EXAMPLES @@ -545,7 +567,7 @@ The resulting set of vertices can be filtered by defining one or more `examples` * A string, only the vertex having this value as it's id is returned. * An example object, defining a set of attributes. Only vertices having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All vertices matching at least one of the elements in the list are returned.
@EXAMPLES @@ -643,7 +665,7 @@ The result set is reduced to the set of elements that matches the given `example * A string, only the elements having this value as it's id is returned. * An example object, defining a set of attributes. Only elements having these attributes are matched. -* A list containing example objects andor strings. +* A list containing example objects and/or strings. All elements matching at least one of the elements in the list are returned.
@EXAMPLES diff --git a/Documentation/Books/Users/General-Graphs/GeneralGraphFunctions.mdpp b/Documentation/Books/Users/General-Graphs/GeneralGraphFunctions.mdpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Documentation/Books/Users/General-Graphs/README.mdpp b/Documentation/Books/Users/General-Graphs/README.mdpp new file mode 100644 index 0000000000..cb189d49af --- /dev/null +++ b/Documentation/Books/Users/General-Graphs/README.mdpp @@ -0,0 +1,6 @@ +!CHAPTER General Graphs + +This chapter describes the multi-collection graph module. +It allows you to define a graph that is spread across several edge and document collections. +This allows you to structure your models in line with your domain and group them logically in collections and giving you the power to query them in the same graph queries. +There is no need to include the referenced collections within the query, this module will handle it for you. diff --git a/Documentation/Books/Users/README.mdpp b/Documentation/Books/Users/README.mdpp index f5d65163fb..3cf2bd97f3 100644 --- a/Documentation/Books/Users/README.mdpp +++ b/Documentation/Books/Users/README.mdpp @@ -36,7 +36,6 @@ If you have any questions don't hesitate to ask on: - [github](https://github.com/triAGENS/ArangoDB/issues) - [google groups](https://groups.google.com/forum/?hl=de#!forum/arangodb) -or - [stackoverflow](http://stackoverflow.com/questions/tagged/arangodb) We will respond as soon as possible. diff --git a/Documentation/Books/Users/SUMMARY.md b/Documentation/Books/Users/SUMMARY.md index 52c138ef68..7f6e608ebb 100644 --- a/Documentation/Books/Users/SUMMARY.md +++ b/Documentation/Books/Users/SUMMARY.md @@ -24,7 +24,6 @@ * [Notes about Databases](Databases/Notes.md) * [Handling Collections](Collections/README.md) - * [Address of a Collection](Collections/CollectionAddress.md) * [Collection Methods](Collections/CollectionMethods.md) * [Database Methods](Collections/DatabaseMethods.md) @@ -68,6 +67,7 @@ * [Edge Methods](Blueprint-Graphs/EdgeMethods.md) * [General-Graphs](General-Graphs/README.md) + * [Graph Functions](General-Graphs/GeneralGraphFunctions.md) * [Fluent AQL Interface](General-Graphs/FluentAQLInterface.md) * [Traversals](Traversals/README.md) diff --git a/Documentation/Books/codeBlockReader.py b/Documentation/Books/codeBlockReader.py index ef57cffc9e..165ed6d6b8 100644 --- a/Documentation/Books/codeBlockReader.py +++ b/Documentation/Books/codeBlockReader.py @@ -1,6 +1,7 @@ import os import inspect - + + def file_content(filepath): """ Fetches and formats file's content to perform the required operation. """ @@ -28,7 +29,7 @@ def fetch_comments(dirpath): """ comments_filename = "allComments.txt" - fh = open(comments_filename, "w") + fh = open(comments_filename, "a") for root, directories, files in os.walk(dirpath): for filename in files: @@ -37,7 +38,7 @@ def fetch_comments(dirpath): for comment in file_comments: fh.write("\n\n" % filename) for _com in comment: - _text = _com.replace("/", "") + _text = _com.replace("///", "") if len(_text.strip()) == 0: _text = _text.replace("\n", "
") _text = _text.strip() @@ -51,5 +52,15 @@ def fetch_comments(dirpath): fh.close() if __name__ == "__main__": - dirpath = "/Users/Thomas/code/ArangoDB" - fetch_comments(dirpath) + open("allComments.txt", "w").close() + path = ["arangod/cluster","arangod/RestHandler","arangod/V8Server", + "lib/Admin","lib/HttpServer", + "js/actions","js/client","js/apps","js/common","js/server"] + for i in path: + dirpath = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir,"ArangoDB/../../"+i)) + fetch_comments(dirpath) + print dirpath + + + os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'templates')) + \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index c5e5425d24..78740d0919 100644 --- a/Makefile.am +++ b/Makefile.am @@ -170,7 +170,8 @@ noinst_LIBRARIES = \ lib/libarango.a \ lib/libarango_v8.a \ lib/libarango_fe.a \ - lib/libarango_client.a + lib/libarango_client.a \ + arangod/libarangod.a if ENABLE_MRUBY noinst_LIBRARIES += lib/libarango_mruby.a diff --git a/arangod/HashIndex/hash-index.cpp b/arangod/HashIndex/hash-index.cpp index 84c1713c5e..76ba25a08a 100644 --- a/arangod/HashIndex/hash-index.cpp +++ b/arangod/HashIndex/hash-index.cpp @@ -157,7 +157,7 @@ static int HashIndexHelper (TRI_hash_index_t const* hashIndex, acc = TRI_FindAccessorVocShaper(shaper, shapedJson._sid, path); // field not part of the object - if (acc == NULL || acc->_shape == NULL) { + if (acc == NULL || acc->_resultSid == 0) { shapedSub._sid = TRI_LookupBasicSidShaper(TRI_SHAPE_NULL); shapedSub._length = 0; shapedSub._offset = 0; diff --git a/arangod/Makefile.files b/arangod/Makefile.files index 3e2cd93ead..2fc5f0a551 100644 --- a/arangod/Makefile.files +++ b/arangod/Makefile.files @@ -1,25 +1,18 @@ # -*- mode: Makefile; -*- -################################################################################ -## --SECTION-- PROGRAM -################################################################################ +## ----------------------------------------------------------------------------- +## --SECTION-- LIBRARY +## ----------------------------------------------------------------------------- ################################################################################ -### @brief program "arangod" +### @brief library "libarangod.a" ################################################################################ -bin_arangod_CPPFLAGS = \ +arangod_libarangod_a_CPPFLAGS = \ -I@top_srcdir@/arangod \ $(AM_CPPFLAGS) -bin_arangod_LDADD = \ - lib/libarango_fe.a \ - lib/libarango_v8.a \ - lib/libarango.a \ - $(LIBS) \ - @V8_LIBS@ - -bin_arangod_SOURCES = \ +arangod_libarangod_a_SOURCES = \ arangod/Actions/actions.cpp \ arangod/Actions/RestActionHandler.cpp \ arangod/Ahuacatl/ahuacatl-access-optimiser.c \ @@ -127,7 +120,7 @@ bin_arangod_SOURCES = \ if ENABLE_CLUSTER -bin_arangod_SOURCES += \ +arangod_libarangod_a_SOURCES += \ arangod/Cluster/AgencyComm.cpp \ arangod/Cluster/ApplicationCluster.cpp \ arangod/Cluster/ClusterComm.cpp \ @@ -141,15 +134,43 @@ bin_arangod_SOURCES += \ endif +if ENABLE_MRUBY + +arangod_libarangod_a_SOURCES += \ + arangod/MRServer/ApplicationMR.cpp \ + arangod/MRServer/mr-actions.cpp + +endif + +## ----------------------------------------------------------------------------- +## --SECTION-- PROGRAM +## ----------------------------------------------------------------------------- + +################################################################################ +### @brief program "arangod" +################################################################################ + +bin_arangod_CPPFLAGS = \ + -I@top_srcdir@/arangod \ + $(AM_CPPFLAGS) + +bin_arangod_LDADD = \ + arangod/libarangod.a \ + lib/libarango_fe.a \ + lib/libarango_v8.a \ + lib/libarango.a \ + $(LIBS) \ + @V8_LIBS@ + +bin_arangod_SOURCES = \ + arangod/RestServer/arango.cpp + if ENABLE_MRUBY bin_arangod_LDADD += \ lib/libarango_mruby.a \ @MRUBY_LIBS@ -bin_arangod_SOURCES += \ - arangod/MRServer/ApplicationMR.cpp \ - arangod/MRServer/mr-actions.cpp endif ################################################################################ diff --git a/arangod/V8Server/v8-vocbase.cpp b/arangod/V8Server/v8-vocbase.cpp index 9b2ac7f7f4..1a63b9b01a 100644 --- a/arangod/V8Server/v8-vocbase.cpp +++ b/arangod/V8Server/v8-vocbase.cpp @@ -10074,7 +10074,7 @@ static v8::Handle PropertyQueryShapedJson (v8::Local na TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(shaper, sid, pid); // key not found - if (acc == 0 || acc->_shape == 0) { + if (acc == 0 || acc->_resultSid == 0) { return scope.Close(v8::Handle()); } diff --git a/arangod/VocBase/index.cpp b/arangod/VocBase/index.cpp index f7381e950a..935ad02338 100644 --- a/arangod/VocBase/index.cpp +++ b/arangod/VocBase/index.cpp @@ -1195,7 +1195,7 @@ static int SkiplistIndexHelper (const TRI_skiplist_index_t* skiplistIndex, TRI_shape_access_t const* acc = TRI_FindAccessorVocShaper(skiplistIndex->base._collection->_shaper, shapedJson._sid, shape); - if (acc == NULL || acc->_shape == NULL) { + if (acc == NULL || acc->_resultSid == 0) { return TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING; } @@ -2035,7 +2035,7 @@ static int BitarrayIndexHelper(const TRI_bitarray_index_t* baIndex, acc = TRI_FindAccessorVocShaper(baIndex->base._collection->_shaper, shapedDoc->_sid, shape); - if (acc == NULL || acc->_shape == NULL) { + if (acc == NULL || acc->_resultSid == 0) { return TRI_ERROR_ARANGO_INDEX_BITARRAY_UPDATE_ATTRIBUTE_MISSING; } @@ -2078,7 +2078,7 @@ static int BitarrayIndexHelper(const TRI_bitarray_index_t* baIndex, acc = TRI_FindAccessorVocShaper(baIndex->base._collection->_shaper, shapedJson._sid, shape); - if (acc == NULL || acc->_shape == NULL) { + if (acc == NULL || acc->_resultSid == 0) { return TRI_ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING; } diff --git a/arangod/VocBase/voc-shaper.cpp b/arangod/VocBase/voc-shaper.cpp index edf2b43de7..b65e540a62 100644 --- a/arangod/VocBase/voc-shaper.cpp +++ b/arangod/VocBase/voc-shaper.cpp @@ -908,20 +908,28 @@ bool TRI_ExtractShapedJsonVocShaper (TRI_shaper_t* shaper, return false; } - *shape = accessor->_shape; - - if (accessor->_shape == NULL) { + if (accessor->_resultSid == 0) { LOG_TRACE("expecting any object for path %lu, got nothing", (unsigned long) pid); return sid == 0; } - if (sid != 0 && sid != accessor->_shape->_sid) { + *shape = shaper->lookupShapeId(shaper, accessor->_resultSid); + + if (*shape == nullptr) { + LOG_TRACE("expecting any object for path %lu, got unknown shape id %lu", + (unsigned long) pid, + (unsigned long) accessor->_resultSid); + + return sid == 0; + } + + if (sid != 0 && sid != accessor->_resultSid) { LOG_TRACE("expecting sid %lu for path %lu, got sid %lu", (unsigned long) sid, (unsigned long) pid, - (unsigned long) accessor->_shape->_sid); + (unsigned long) accessor->_resultSid); return false; } diff --git a/js/common/modules/org/arangodb/general-graph.js b/js/common/modules/org/arangodb/general-graph.js index f495b33f22..35a7c99881 100644 --- a/js/common/modules/org/arangodb/general-graph.js +++ b/js/common/modules/org/arangodb/general-graph.js @@ -2018,8 +2018,6 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, "ex2": ex2 }; return db._query(query, bindVars, {count: true}).toArray(); - - }; //////////////////////////////////////////////////////////////////////////////// diff --git a/js/common/tests/shell-general-graph.js b/js/common/tests/shell-general-graph.js index 1548d51ba9..a3aefb2657 100644 --- a/js/common/tests/shell-general-graph.js +++ b/js/common/tests/shell-general-graph.js @@ -1408,7 +1408,7 @@ function ChainedFluentAQLResultsSuite() { test_getExampleNeighborsOfSelectedVerticesResultingAQL: function() { var query = g._vertices({name: uaName}) .neighbors([{ - name: uaName + name: ubName },{ name: p1Name }]); @@ -1420,31 +1420,27 @@ function ChainedFluentAQLResultsSuite() { assertEqual(query.bindVars.options_0, {}); assertEqual(query.bindVars.options_1, { neighborExamples: [{ - name: uaName + name: ubName },{ name: p1Name }] }); }, - /* Not yet working, neighbors requires vertex-examples in AQL - test_getExampleNeighborsOfSelectedVertices: function() { var result = g._vertices({name: uaName}) .neighbors([{ - name: uaName + name: ubName },{ name: p1Name }]) .toArray(); assertEqual(result.length, 2); var sorted = _.sortBy(result, "name"); - assertEqual(sorted[0].name, uaName); + assertEqual(sorted[0].name, ubName); assertEqual(sorted[1].name, p1Name); }, - */ - test_getEdgesOfNeighborsResultingAQL: function() { var query = g._vertices({name: uaName}) .neighbors() @@ -1940,10 +1936,26 @@ function EdgesAndVerticesSuite() { function GeneralGraphCommonNeighborsSuite() { - var vertex = null; - var edge = null; var testGraph, actual; + var v1ColName = "UnitTestsAhuacatlVertex1"; + var v2ColName = "UnitTestsAhuacatlVertex2"; + var eColName = "UnitTestsAhuacatlEdge1"; + var v1; + var v2; + var v3; + var v4; + var v5; + var v6; + var v7; + var v8; + + var createKeyValueObject = function(key, value) { + var res = {}; + res[key] = value; + return res; + }; + return { //////////////////////////////////////////////////////////////////////////////// @@ -1951,48 +1963,48 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// setUp: function () { - db._drop("UnitTestsAhuacatlVertex1"); - db._drop("UnitTestsAhuacatlVertex2"); - db._drop("UnitTestsAhuacatlEdge1"); + db._drop(v1ColName); + db._drop(v2ColName); + db._drop(eColName); - vertex1 = db._create("UnitTestsAhuacatlVertex1"); - vertex2 = db._create("UnitTestsAhuacatlVertex2"); - edge1 = db._createEdgeCollection("UnitTestsAhuacatlEdge1"); + var vertex1 = db._create(v1ColName); + var vertex2 = db._create(v2ColName); + var edge1 = db._createEdgeCollection(eColName); - vertex1.save({ _key: "v1" , hugo : true}); - vertex1.save({ _key: "v2" ,hugo : true}); - vertex1.save({ _key: "v3" , heinz : 1}); - vertex1.save({ _key: "v4" , harald : "meier"}); - vertex2.save({ _key: "v5" , ageing : true}); - vertex2.save({ _key: "v6" , harald : "meier", ageing : true}); - vertex2.save({ _key: "v7" ,harald : "meier"}); - vertex2.save({ _key: "v8" ,heinz : 1, harald : "meier"}); + v1 = vertex1.save({ _key: "v1" , hugo : true})._id; + v2 = vertex1.save({ _key: "v2" ,hugo : true})._id; + v3 = vertex1.save({ _key: "v3" , heinz : 1})._id; + v4 = vertex1.save({ _key: "v4" , harald : "meier"})._id; + v5 = vertex2.save({ _key: "v5" , ageing : true})._id; + v6 = vertex2.save({ _key: "v6" , harald : "meier", ageing : true})._id; + v7 = vertex2.save({ _key: "v7" ,harald : "meier"})._id; + v8 = vertex2.save({ _key: "v8" ,heinz : 1, harald : "meier"})._id; function makeEdge(from, to, collection) { collection.save(from, to, { what: from.split("/")[1] + "->" + to.split("/")[1] }); } - makeEdge("UnitTestsAhuacatlVertex1/v1", "UnitTestsAhuacatlVertex1/v2", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v2", "UnitTestsAhuacatlVertex1/v3", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v5", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v2", "UnitTestsAhuacatlVertex2/v6", edge1); - makeEdge("UnitTestsAhuacatlVertex2/v6", "UnitTestsAhuacatlVertex2/v7", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v4", "UnitTestsAhuacatlVertex2/v7", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v7", edge1); - makeEdge("UnitTestsAhuacatlVertex2/v8", "UnitTestsAhuacatlVertex1/v1", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v5", edge1); - makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v8", edge1); + makeEdge(v1, v2, edge1); + makeEdge(v2, v3, edge1); + makeEdge(v3, v5, edge1); + makeEdge(v2, v6, edge1); + makeEdge(v6, v7, edge1); + makeEdge(v4, v7, edge1); + makeEdge(v3, v7, edge1); + makeEdge(v8, v1, edge1); + makeEdge(v3, v5, edge1); + makeEdge(v3, v8, edge1); try { - db._collection("_graphs").remove("_graphs/bla3") - } catch (err) { + db._collection("_graphs").remove("_graphs/bla3"); + } catch (ignore) { } testGraph = graph._create( "bla3", graph._edgeDefinitions( - graph._directedRelationDefinition("UnitTestsAhuacatlEdge1", - ["UnitTestsAhuacatlVertex1", "UnitTestsAhuacatlVertex2"], - ["UnitTestsAhuacatlVertex1", "UnitTestsAhuacatlVertex2"] + graph._directedRelationDefinition(eColName, + [v1ColName, v2ColName], + [v1ColName, v2ColName] ) ) ); @@ -2003,12 +2015,12 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// tearDown: function () { - db._drop("UnitTestsAhuacatlVertex1"); - db._drop("UnitTestsAhuacatlVertex2"); - db._drop("UnitTestsAhuacatlEdge1"); + db._drop(v1ColName); + db._drop(v2ColName); + db._drop(eColName); try { - db._collection("_graphs").remove("_graphs/bla3") - } catch (err) { + db._collection("_graphs").remove("_graphs/bla3"); + } catch (ignore) { } }, @@ -2017,14 +2029,11 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// testCommonNeighborsAny: function () { - actual = testGraph._listCommonNeighbors('UnitTestsAhuacatlVertex1/v3' , 'UnitTestsAhuacatlVertex2/v6', {direction : 'any'}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v2"); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][1]._id , "UnitTestsAhuacatlVertex2/v7"); - - - actual = testGraph._amountCommonNeighbors('UnitTestsAhuacatlVertex1/v3' , 'UnitTestsAhuacatlVertex2/v6', {direction : 'any'}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"][0]["UnitTestsAhuacatlVertex2/v6"] , 2); - + actual = testGraph._listCommonNeighbors(v3 , v6, {direction : 'any'}); + assertEqual(actual[0][v3][v6][0]._id , v2); + assertEqual(actual[0][v3][v6][1]._id , v7); + actual = testGraph._amountCommonNeighbors(v3 , v6, {direction : 'any'}); + assertEqual(actual[0][v3][0][v6] , 2); }, //////////////////////////////////////////////////////////////////////////////// /// @brief checks GRAPH_COMMON_NEIGHBORS() @@ -2032,28 +2041,25 @@ function GeneralGraphCommonNeighborsSuite() { testCommonNeighborsIn: function () { actual = testGraph._listCommonNeighbors({} , {}, {direction : 'inbound'}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v2"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"]["UnitTestsAhuacatlVertex2/v7"][0]._id , "UnitTestsAhuacatlVertex1/v3"); - - - assertEqual(actual[2]["UnitTestsAhuacatlVertex2/v6"]["UnitTestsAhuacatlVertex1/v3"][0]._id , "UnitTestsAhuacatlVertex1/v2"); - assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex1/v3"); - assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3"); - - assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex1/v3"); - assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"]["UnitTestsAhuacatlVertex2/v7"][0]._id , "UnitTestsAhuacatlVertex1/v3"); + assertEqual(actual[0][v3][v6][0]._id, v2); + assertEqual(actual[1][v5][v8][0]._id, v3); + assertEqual(actual[1][v5][v7][0]._id, v3); + assertEqual(actual[2][v6][v3][0]._id, v2); + assertEqual(actual[3][v7][v5][0]._id, v3); + assertEqual(actual[3][v7][v8][0]._id, v3); + assertEqual(actual[4][v8][v5][0]._id, v3); + assertEqual(actual[4][v8][v7][0]._id, v3); actual = testGraph._amountCommonNeighbors({} , {}, {direction : 'inbound'}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"][0]["UnitTestsAhuacatlVertex2/v6"] , 1); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"][0]["UnitTestsAhuacatlVertex2/v8"] , 1); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"][1]["UnitTestsAhuacatlVertex2/v7"] , 1); - assertEqual(actual[2]["UnitTestsAhuacatlVertex2/v6"][0]["UnitTestsAhuacatlVertex1/v3"] , 1); - assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"][0]["UnitTestsAhuacatlVertex2/v5"] , 1); - assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"][1]["UnitTestsAhuacatlVertex2/v8"] , 1); + assertEqual(actual[0][v3][0][v6] , 1); + assertEqual(actual[1][v5][0][v8] , 1); + assertEqual(actual[1][v5][1][v7] , 1); + assertEqual(actual[2][v6][0][v3] , 1); + assertEqual(actual[3][v7][0][v5] , 1); + assertEqual(actual[3][v7][1][v8] , 1); - assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"][0]["UnitTestsAhuacatlVertex2/v5"] , 1); - assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"][1]["UnitTestsAhuacatlVertex2/v7"] , 1); + assertEqual(actual[4][v8][0][v5] , 1); + assertEqual(actual[4][v8][1][v7] , 1); }, @@ -2063,26 +2069,30 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// testCommonNeighborsOut: function () { - actual = testGraph._listCommonNeighbors( { hugo : true } , {heinz : 1}, {direction : 'outbound', minDepth : 1, maxDepth : 3}); - assertEqual(Object.keys(actual[1])[0] , "UnitTestsAhuacatlVertex1/v2"); - assertEqual(Object.keys(actual[1][Object.keys(actual[1])[0]]) , ["UnitTestsAhuacatlVertex2/v8", "UnitTestsAhuacatlVertex1/v3"]); + actual = testGraph._listCommonNeighbors( + {hugo: true}, {heinz: 1}, + {direction: 'outbound', minDepth: 1, maxDepth: 3} + ); + assertEqual(Object.keys(actual[1])[0], v2); + assertEqual(Object.keys(actual[1][Object.keys(actual[1])[0]]), [v8, v3]); - assertEqual(actual[1][Object.keys(actual[1])[0]]["UnitTestsAhuacatlVertex2/v8"].length , 3); - assertEqual(actual[1][Object.keys(actual[1])[0]]["UnitTestsAhuacatlVertex1/v3"].length , 4); + assertEqual(actual[1][Object.keys(actual[1])[0]][v8].length, 3); + assertEqual(actual[1][Object.keys(actual[1])[0]][v3].length, 4); - assertEqual(Object.keys(actual[0])[0] , "UnitTestsAhuacatlVertex1/v1"); - assertEqual(Object.keys(actual[0][Object.keys(actual[0])[0]]) , ["UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v8"]); - - assertEqual(actual[0][Object.keys(actual[0])[0]]["UnitTestsAhuacatlVertex1/v3"].length , 4); - assertEqual(actual[0][Object.keys(actual[0])[0]]["UnitTestsAhuacatlVertex2/v8"].length , 3); - - actual = testGraph._amountCommonNeighbors({ hugo : true } , {heinz : 1}, {direction : 'outbound', minDepth : 1, maxDepth : 3}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][0]["UnitTestsAhuacatlVertex1/v3"] , 4); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][1]["UnitTestsAhuacatlVertex2/v8"] , 3); - assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][0]["UnitTestsAhuacatlVertex2/v8"] , 3); - assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][1]["UnitTestsAhuacatlVertex1/v3"] , 4); + assertEqual(Object.keys(actual[0])[0], v1); + assertEqual(Object.keys(actual[0][Object.keys(actual[0])[0]]), [v3, v8]); + assertEqual(actual[0][Object.keys(actual[0])[0]][v3].length, 4); + assertEqual(actual[0][Object.keys(actual[0])[0]][v8].length, 3); + actual = testGraph._amountCommonNeighbors( + {hugo: true }, {heinz: 1}, + {direction: 'outbound', minDepth: 1, maxDepth: 3} + ); + assertEqual(actual[0][v1][0][v3], 4); + assertEqual(actual[0][v1][1][v8], 3); + assertEqual(actual[1][v2][0][v8], 3); + assertEqual(actual[1][v2][1][v3], 4); }, //////////////////////////////////////////////////////////////////////////////// @@ -2090,78 +2100,50 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// testCommonProperties: function () { - actual = testGraph._listCommonProperties( { } , {}, {}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][0]._id , "UnitTestsAhuacatlVertex1/v2"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][0]._id , "UnitTestsAhuacatlVertex1/v1"); - assertEqual(actual[2]["UnitTestsAhuacatlVertex1/v3"][0]._id , "UnitTestsAhuacatlVertex2/v8"); - assertEqual(actual[3]["UnitTestsAhuacatlVertex1/v4"][0]._id , "UnitTestsAhuacatlVertex2/v6"); - assertEqual(actual[3]["UnitTestsAhuacatlVertex1/v4"][1]._id , "UnitTestsAhuacatlVertex2/v8"); - assertEqual(actual[3]["UnitTestsAhuacatlVertex1/v4"][2]._id , "UnitTestsAhuacatlVertex2/v7"); + actual = testGraph._listCommonProperties({} ,{} ,{}); + assertEqual(actual[0][v1][0]._id , v2); + assertEqual(actual[1][v2][0]._id , v1); + assertEqual(actual[2][v3][0]._id , v8); + assertEqual(actual[3][v4][0]._id , v6); + assertEqual(actual[3][v4][1]._id , v8); + assertEqual(actual[3][v4][2]._id , v7); + assertEqual(actual[4][v5][0]._id , v6); + assertEqual(actual[5][v6][0]._id , v4); + assertEqual(actual[5][v6][1]._id , v5); + assertEqual(actual[5][v6][2]._id , v8); + assertEqual(actual[5][v6][3]._id , v7); + assertEqual(actual[6][v7][0]._id , v4); + assertEqual(actual[6][v7][1]._id , v6); + assertEqual(actual[6][v7][2]._id , v8); + assertEqual(actual[7][v8][0]._id , v3); + assertEqual(actual[7][v8][1]._id , v4); + assertEqual(actual[7][v8][2]._id , v6); + assertEqual(actual[7][v8][3]._id , v7); - assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex2/v6"); - assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v4"); - assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][1]._id , "UnitTestsAhuacatlVertex2/v5"); - assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][2]._id , "UnitTestsAhuacatlVertex2/v8"); - assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][3]._id , "UnitTestsAhuacatlVertex2/v7"); - - - assertEqual(actual[6]["UnitTestsAhuacatlVertex2/v7"][0]._id , "UnitTestsAhuacatlVertex1/v4"); - assertEqual(actual[6]["UnitTestsAhuacatlVertex2/v7"][1]._id , "UnitTestsAhuacatlVertex2/v6"); - assertEqual(actual[6]["UnitTestsAhuacatlVertex2/v7"][2]._id , "UnitTestsAhuacatlVertex2/v8"); - - assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3"); - assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][1]._id , "UnitTestsAhuacatlVertex1/v4"); - assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][2]._id , "UnitTestsAhuacatlVertex2/v6"); - assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][3]._id , "UnitTestsAhuacatlVertex2/v7"); - - - actual = testGraph._amountCommonProperties( { } , {}, {}); + actual = testGraph._amountCommonProperties({} ,{} ,{}); assertEqual(actual, [ - { - "UnitTestsAhuacatlVertex1/v1" : 1 - }, - { - "UnitTestsAhuacatlVertex1/v2" : 1 - }, - { - "UnitTestsAhuacatlVertex1/v3" : 1 - }, - { - "UnitTestsAhuacatlVertex1/v4" : 3 - }, - { - "UnitTestsAhuacatlVertex2/v5" : 1 - }, - { - "UnitTestsAhuacatlVertex2/v6" : 4 - }, - { - "UnitTestsAhuacatlVertex2/v7" : 3 - }, - { - "UnitTestsAhuacatlVertex2/v8" : 4 - } + createKeyValueObject(v1, 1), + createKeyValueObject(v2, 1), + createKeyValueObject(v3, 1), + createKeyValueObject(v4, 3), + createKeyValueObject(v5, 1), + createKeyValueObject(v6, 4), + createKeyValueObject(v7, 3), + createKeyValueObject(v8, 4) ]); - - - }, testCommonPropertiesWithFilters: function () { actual = testGraph._listCommonProperties({ageing : true} , {harald : 'meier'}, {}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex2/v6"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v4"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v6"][1]._id , "UnitTestsAhuacatlVertex2/v8"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v6"][2]._id , "UnitTestsAhuacatlVertex2/v7"); + assertEqual(actual[0][v5][0]._id , v6); + assertEqual(actual[1][v6][0]._id , v4); + assertEqual(actual[1][v6][1]._id , v8); + assertEqual(actual[1][v6][2]._id , v7); actual = testGraph._amountCommonProperties({ageing : true} , {harald : 'meier'}, {}); assertEqual(actual, [ - { - "UnitTestsAhuacatlVertex2/v5" : 1 - }, - { - "UnitTestsAhuacatlVertex2/v6" : 3 - } + createKeyValueObject(v5, 1), + createKeyValueObject(v6, 3) ]); }, @@ -2169,40 +2151,24 @@ function GeneralGraphCommonNeighborsSuite() { testCommonPropertiesWithFiltersAndIgnoringKeyHarald: function () { actual = testGraph._listCommonProperties( {} , {}, {ignoreProperties : 'harald'}); - assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][0]._id , "UnitTestsAhuacatlVertex1/v2"); - assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][0]._id , "UnitTestsAhuacatlVertex1/v1"); - assertEqual(actual[2]["UnitTestsAhuacatlVertex1/v3"][0]._id , "UnitTestsAhuacatlVertex2/v8"); - - assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex2/v6"); - - assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex2/v5"); - assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3"); + assertEqual(actual[0][v1][0]._id , v2); + assertEqual(actual[1][v2][0]._id , v1); + assertEqual(actual[2][v3][0]._id , v8); + assertEqual(actual[3][v5][0]._id , v6); + assertEqual(actual[4][v6][0]._id , v5); + assertEqual(actual[5][v8][0]._id , v3); actual = testGraph._amountCommonProperties({} , {}, {ignoreProperties : 'harald'}); assertEqual(actual, [ - { - "UnitTestsAhuacatlVertex1/v1" : 1 - }, - { - "UnitTestsAhuacatlVertex1/v2" : 1 - }, - { - "UnitTestsAhuacatlVertex1/v3" : 1 - }, - { - "UnitTestsAhuacatlVertex2/v5" : 1 - }, - { - "UnitTestsAhuacatlVertex2/v6" : 1 - }, - { - "UnitTestsAhuacatlVertex2/v8" : 1 - } + createKeyValueObject(v1, 1), + createKeyValueObject(v2, 1), + createKeyValueObject(v3, 1), + createKeyValueObject(v5, 1), + createKeyValueObject(v6, 1), + createKeyValueObject(v8, 1) ]); - - } - } + }; } diff --git a/lib/ShapedJson/shape-accessor.cpp b/lib/ShapedJson/shape-accessor.cpp index 94052485a3..d6013bffd2 100644 --- a/lib/ShapedJson/shape-accessor.cpp +++ b/lib/ShapedJson/shape-accessor.cpp @@ -70,6 +70,7 @@ 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 2 entries in the vector to store an accessor TRI_InitVectorPointer2(&ops, shaper->_memoryZone, 2); @@ -214,7 +215,7 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc TRI_DestroyVectorPointer(&ops); - accessor->_shape = NULL; + accessor->_resultSid = 0; accessor->_code = NULL; return true; @@ -222,7 +223,7 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc else { TRI_DestroyVectorPointer(&ops); - accessor->_shape = NULL; + accessor->_resultSid = 0; accessor->_code = NULL; return true; @@ -238,7 +239,8 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc return false; } - accessor->_shape = shape; + // remember resulting sid + accessor->_resultSid = shape->_sid; // steal buffer from ops vector so we don't need to copy it accessor->_code = const_cast(ops._buffer); @@ -262,7 +264,7 @@ static bool ExecuteBytecodeShapeAccessor (TRI_shape_access_t const* accessor, TRI_shape_size_t pos; TRI_shape_size_t* offsetsV; - if (accessor->_shape == NULL) { + if (accessor->_resultSid == 0) { return false; } @@ -364,7 +366,7 @@ bool TRI_ExecuteShapeAccessor (TRI_shape_access_t const* accessor, return false; } - result->_sid = accessor->_shape->_sid; + result->_sid = accessor->_resultSid; result->_data.data = (char*) begin; result->_data.length = (uint32_t) (((char const*) end) - ((char const*) begin)); @@ -384,12 +386,12 @@ void TRI_PrintShapeAccessor (TRI_shape_access_t* accessor) { (unsigned long) accessor->_sid, (unsigned long) accessor->_pid); - if (accessor->_shape == NULL) { + if (accessor->_resultSid == 0) { printf(" result shape: -\n"); return; } - printf(" result shape: %lu\n", (unsigned long) accessor->_shape->_sid); + printf(" result shape: %lu\n", (unsigned long) accessor->_resultSid); void const** ops = static_cast(accessor->_code); diff --git a/lib/ShapedJson/shape-accessor.h b/lib/ShapedJson/shape-accessor.h index ab1a93bda4..ac739541d8 100644 --- a/lib/ShapedJson/shape-accessor.h +++ b/lib/ShapedJson/shape-accessor.h @@ -54,7 +54,7 @@ typedef struct TRI_shape_access_s { TRI_shape_sid_t _sid; // shaped identifier of the shape we are looking at TRI_shape_pid_t _pid; // path identifier of the attribute path - TRI_shape_t const* _shape; // resulting shape + TRI_shape_sid_t _resultSid; // resulting shape void const** _code; // bytecode TRI_memory_zone_t* _memoryZone;