-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Pregel API support with 3.10 features
- Loading branch information
Showing
12 changed files
with
553 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using ArangoDBNetStandard.PregelApi.Models; | ||
using ArangoDBNetStandard.ViewApi.Models; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using static System.Net.WebRequestMethods; | ||
|
||
namespace ArangoDBNetStandard.PregelApi | ||
{ | ||
/// <summary> | ||
/// Defines a client to access the ArangoDB API for Pregel | ||
/// (Distributed Iterative Graph Processing). | ||
/// </summary> | ||
public interface IPregelApiClient | ||
{ | ||
/// <summary> | ||
/// Start the execution of a Pregel algorithm. | ||
/// POST /_api/control_pregel | ||
/// </summary> | ||
/// <remarks> | ||
/// To start an execution you need to specify the | ||
/// algorithm name and a named graph (SmartGraph in cluster). | ||
/// Alternatively you can specify the vertex and edge collections. | ||
/// Additionally you can specify custom parameters which | ||
/// vary for each algorithm | ||
/// </remarks> | ||
/// <param name="body">The body of the request containing required properties.</param> | ||
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param> | ||
/// <returns>The ID of the newly started job.</returns> | ||
Task<string> PostStartJobAsync( | ||
PostStartJobBody body, | ||
CancellationToken token = default); | ||
|
||
/// <summary> | ||
/// Get the status of a Pregel job execution. | ||
/// GET /_api/control_pregel/{id} | ||
/// </summary> | ||
/// <param name="jobId">The ID of the job.</param> | ||
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param> | ||
/// <returns></returns> | ||
Task<PregelJobStatus> GetJobStatusAsync( | ||
string jobId, | ||
CancellationToken token = default); | ||
|
||
/// <summary> | ||
/// Get the overview of currently running Pregel jobs. | ||
/// GET /_api/control_pregel | ||
/// </summary> | ||
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param> | ||
/// <returns> | ||
/// Returns a list of currently running and recently | ||
/// finished Pregel jobs without retrieving their results. | ||
/// </returns> | ||
Task<List<PregelJobStatus>> GetAllRunningJobsAsync( | ||
CancellationToken token = default); | ||
|
||
/// <summary> | ||
/// Cancel an ongoing Pregel execution. | ||
/// DELETE /_api/control_pregel/{id} | ||
/// </summary> | ||
/// <remarks> | ||
/// Cancel an execution which is still running, and | ||
/// discard any intermediate results. This will immediately | ||
/// free all memory taken up by the execution, and will | ||
/// make you lose all intermediary data. | ||
/// For more information <see cref="https://www.arangodb.com/docs/stable/http/pregel.html#cancel-pregel-job-execution"/> | ||
/// </remarks> | ||
/// <param name="jobId">The ID of the job.</param> | ||
/// <param name="token">A CancellationToken to observe while waiting for the task to complete or to cancel the task.</param> | ||
/// <returns></returns> | ||
Task<string> DeleteJobAsync( | ||
string jobId, | ||
CancellationToken token = default); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
arangodb-net-standard/PregelApi/Models/PostStartJobBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using static System.Net.WebRequestMethods; | ||
|
||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
/// <summary> | ||
/// Body parameter for | ||
/// <see cref="IPregelApiClient.PostStartJobAsync(PostStartJobBody, System.Threading.CancellationToken)"/> | ||
/// </summary> | ||
public class PostStartJobBody | ||
{ | ||
/// <summary> | ||
/// Required. Name of the algorithm. | ||
/// See <see cref="PregelAlgorithms"/> for possible values. | ||
/// </summary> | ||
public string Algorithm { get; set; } | ||
|
||
/// <summary> | ||
/// Optional. Name of a graph. Either this or the parameters | ||
/// <see cref="VertexCollections"/> and <see cref="EdgeCollections"/> | ||
/// are required. | ||
/// </summary> | ||
/// <remarks> | ||
/// Please note that there are special sharding requirements | ||
/// for graphs in order to be used with Pregel. | ||
/// </remarks> | ||
public string GraphName { get; set; } | ||
|
||
/// <summary> | ||
/// List of vertex collection names. | ||
/// </summary> | ||
/// <remarks> | ||
/// Please note that there are special sharding requirements | ||
/// for collections in order to be used with Pregel. | ||
/// </remarks> | ||
public IEnumerable<string> VertexCollections { get; set; } | ||
|
||
/// <summary> | ||
/// List of edge collection names. | ||
/// </summary> | ||
/// <remarks> | ||
/// Please note that there are special sharding requirements | ||
/// for collections in order to be used with Pregel. | ||
/// </remarks> | ||
public IEnumerable<string> EdgeCollections { get; set; } | ||
|
||
/// <summary> | ||
/// General as well as algorithm-specific options. | ||
/// </summary> | ||
/// <remarks> | ||
/// <see cref="https://www.arangodb.com/docs/stable/http/pregel.html#start-pregel-job-execution"/> | ||
/// </remarks> | ||
public Dictionary<string,object> Params { get; set; } | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
arangodb-net-standard/PregelApi/Models/PregelAlgorithms.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
/// <summary> | ||
/// List of pregel algorithm names | ||
/// </summary> | ||
public struct PregelAlgorithms | ||
{ | ||
/// <summary> | ||
/// Page Rank | ||
/// </summary> | ||
public const string PageRank = "pagerank"; | ||
|
||
/// <summary> | ||
/// Single-Source Shortest Path | ||
/// </summary> | ||
public const string SSSP = "sssp"; | ||
|
||
/// <summary> | ||
/// Connected Components | ||
/// </summary> | ||
public const string ConnectedComponents = "connectedcomponents"; | ||
|
||
/// <summary> | ||
/// Weakly Connected Components | ||
/// </summary> | ||
public const string WCC = "wcc"; | ||
|
||
/// <summary> | ||
/// Strongly Connected Components | ||
/// </summary> | ||
public const string SCC = "scc"; | ||
|
||
/// <summary> | ||
/// Hyperlink-Induced Topic Search | ||
/// </summary> | ||
public const string HITS = "hits"; | ||
|
||
/// <summary> | ||
/// Effective Closeness | ||
/// </summary> | ||
public const string EffectiveCloseness = "effectivecloseness"; | ||
|
||
/// <summary> | ||
/// LineRank | ||
/// </summary> | ||
public const string LineRank = "linerank"; | ||
|
||
/// <summary> | ||
/// Label Propagation | ||
/// </summary> | ||
public const string LabelPropagation = "labelpropagation"; | ||
|
||
/// <summary> | ||
/// Speaker-Listener Label Propagation | ||
/// </summary> | ||
public const string SLPA = "slpa"; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
arangodb-net-standard/PregelApi/Models/PregelJobAggregatedStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
public class PregelJobAggregatedStatus | ||
{ | ||
public string TimeStamp { get; set; } | ||
public PregelJobGraphStoreStatus GraphStoreStatus { get; set; } | ||
public PregelJobGssStatus AllGssStatus { get; set; } | ||
public object WorkerStatus { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
public class PregelJobDetail | ||
{ | ||
public PregelJobAggregatedStatus AggregatedStatus { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
arangodb-net-standard/PregelApi/Models/PregelJobGraphStoreStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
public class PregelJobGraphStoreStatus | ||
{ | ||
public int? VerticesLoaded { get; set; } | ||
public int? EdgesLoaded { get; set; } | ||
public long? MemoryBytesUsed { get; set; } | ||
public int? VerticesStored { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
public class PregelJobGssStatus | ||
{ | ||
public List<PregelJobGssStatusItem> Items { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
arangodb-net-standard/PregelApi/Models/PregelJobGssStatusItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace ArangoDBNetStandard.PregelApi.Models | ||
{ | ||
public class PregelJobGssStatusItem | ||
{ | ||
public int? VerticesProcessed { get; set; } | ||
public int? MessagesSent { get; set; } | ||
public int? MessagesReceived { get; set; } | ||
public long? MemoryBytesUsedForMessages { get; set; } | ||
} | ||
} |
Oops, something went wrong.