2017-09-27 4 views
1

J'ai créé un graphe dans CosmosDB avec deux types de vertex, un vertex d'acteur et un vertex de film. Le seul type de contour existant est un type "acté dans". Vous pouvez imaginer le graphique comme ayant de nombreux acteurs et de nombreux films et n'importe quel acteur peut avoir joué dans un certain nombre de films. J'essaye d'écrire une requête qui va découvrir et retourner le chemin entre deux acteurs. Par exemple, Keanu Reeves a joué dans Matrix avec Laurence Fishburn. Laurence Fishburn a joué dans le film Apocalypse Now avec Marlon Brando. Par conséquent, le chemin entre Keanu Reeves et Marlon Brando est Keanu Reeves -> La Matrice -> Laurence Fishburn -> Apocalypse Maintenant -> Marlon Brando.Le chemin entre les requêtes de nœuds ne se termine jamais

Voici la requête que j'ai trouvée.

g.V('keanureeves') 
.repeat(both().simplePath()) 
.until(hasId('marlonbrando')) 
.path() 
.limit(1) 

La requête fonctionne pour les petits graphiques. Je peux interroger et construire le chemin. Cependant, une fois que j'ai atteint une certaine taille de graphique, la requête expire et ne se termine jamais. J'utilise l'émulateur CosmosDB localement, pas le véritable CosmosDB sur Azure. Il est difficile de dire combien de documents se trouvent dans la base de données, car l'interface utilisateur de l'émulateur ne me permet pas de rechercher un nombre. Puis-je accélérer ma requête sans modifier mon modèle de données? Si je dois changer mon modèle de données, qu'est-ce qui pourrait fonctionner mieux? Je suis nouveau pour les bases de données graphiques et Gremlin.

Modifier: Il semble arriver entre 1200 et 1300 documents. Sous 1200 documents, les résultats reviennent. Voici la répartition des types de documents:

540 movie vertexes 
112 actor vertexes 
681 actedIn edges 

Edit # 2: J'utilise le paquet Microsoft.Azure.Graphs NuGet et il semble que la méthode que je me invoque est lancer une exception OutOfMemory. Mon code:

public async Task<IList<T>> ExecuteQueryAsync<T>(string gremlinQuery) 
{ 
     var query = _documentClient.CreateGremlinQuery(_graph, gremlinQuery); 

     var results = new List<T>(); 
     while (query.HasMoreResults) 
     { 
      var feed = await query.ExecuteNextAsync<T>(); 
      results.AddRange(feed.Select(x => x)); 
     } 
     return results; 
} 

Trace de la pile:

System.AggregateException: One or more errors occurred. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.GetTaskForResult(TResult result) 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetResult(TResult result) 
    at Microsoft.Azure.Graphs.Runtime.Operators.ProjectOperator.<NextAsync>d__4.MoveNext() 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine) 
    at Microsoft.Azure.Graphs.Runtime.Operators.ProjectOperator.NextAsync() 
    at Microsoft.Azure.Graphs.Runtime.ScalarSubqueryFunction.<EvaluateAsync>d__3.MoveNext() 
    --- End of inner exception stack trace --- 
    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 
    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) 
    at System.Threading.Tasks.Task`1.get_Result() 
    at Microsoft.Azure.Graphs.Runtime.Operators.PathOperator.GetStepProjectionResult(FieldObject step, Int32& activeByFuncIndex) 
    at Microsoft.Azure.Graphs.Runtime.Operators.PathOperator.<NextAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.SimplePathOperator.<NextAsync>d__3.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.PathOperator.<NextAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.ProjectOperator.<NextAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.RepeatOperator.<NextAsync>d__18.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.PathOperator.<NextAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.RangeOperator.<NextAsync>d__5.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.Runtime.Operators.ProjectOperator.<NextAsync>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.GraphTraversal.GraphTraversalIterator.<CurrentOperatorNextAsync>d__14.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.GraphTraversal.GraphTraversalIterator.<MoveNextAsync>d__5.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.GraphTraversal.<MoveNextAsync>d__17.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.Azure.Graphs.GremlinDocumentQuery`1.<ExecuteNextAsync>d__15`1.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Octogami.SixDegreesOfNetflix.Application.Data.GremlinClient.<ExecuteQueryAsync>d__3`1.MoveNext() in C:\dev\SixDegreesOfNetflix\Application\Data\GremlinClient.cs:line 28 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Octogami.SixDegreesOfNetflix.Application.Data.ActorPathRepository.<GetPathBetweenActors>d__2.MoveNext() in C:\dev\SixDegreesOfNetflix\Application\Data\ActorPathRepository.cs:line 20 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Octogami.SixDegreesOfNetflix.Application.Feature.GetPathBetweenActorsCommandHandler.<Handle>d__3.MoveNext() in C:\dev\SixDegreesOfNetflix\Application\Feature\GetPathBetweenActors.cs:line 42 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Octogami.SixDegreesOfNetflix.Website.Controllers.ActorController.<DegreesOfSeparation>d__5.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context) 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) 
    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext() 
---> (Inner Exception #0) System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.GetTaskForResult(TResult result) 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetResult(TResult result) 
    at Microsoft.Azure.Graphs.Runtime.Operators.ProjectOperator.<NextAsync>d__4.MoveNext() 
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine) 
    at Microsoft.Azure.Graphs.Runtime.Operators.ProjectOperator.NextAsync() 
    at Microsoft.Azure.Graphs.Runtime.ScalarSubqueryFunction.<EvaluateAsync>d__3.MoveNext()<--- 

Répondre

0

Dans le paquet Nuget 0.2.4-aperçu, la limite() clause n'a pas été comporte correctement. Dans le package Nuget de l'aperçu 0.3.0, une optimisation a été ajoutée pour l'étape de traversée limit(). Quand j'ai mis à jour le paquet, mon problème a été résolu. Voir le journal des modifications sur le Graph SDK page.