-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastDBGraphRepository.cs
More file actions
180 lines (149 loc) · 6.3 KB
/
FastDBGraphRepository.cs
File metadata and controls
180 lines (149 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using LiteGraph;
using Stellar.Collections;
namespace WebNet.LiteGraphExtensions.GraphRepositories
{
/// <summary>
/// FastDB Graph Repository implementation.
/// Provides high-performance graph storage using Stellar.FastDB with MessagePack serialization.
/// FastDB is a key-value collection-based embedded database (~100x faster than similar products).
/// </summary>
/// <remarks>
/// FastDB uses collection-based storage (similar to ConcurrentDictionary) with built-in persistence.
/// It supports MessagePack serialization for optimal storage footprint and performance.
/// Note: Implementation pending - LiteGraph interface requires additional parameters in method signatures.
/// </remarks>
public class FastDBGraphRepository : LiteGraph.GraphRepositories.GraphRepositoryBase
{
#region Public-Members
/// <summary>
/// Admin methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IAdminMethods Admin { get; }
/// <summary>
/// Tenant methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.ITenantMethods Tenant { get; }
/// <summary>
/// User methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IUserMethods User { get; }
/// <summary>
/// Credential methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.ICredentialMethods Credential { get; }
/// <summary>
/// Label methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.ILabelMethods Label { get; }
/// <summary>
/// Tag methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.ITagMethods Tag { get; }
/// <summary>
/// Vector methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IVectorMethods Vector { get; }
/// <summary>
/// Graph methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IGraphMethods Graph { get; }
/// <summary>
/// Node methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.INodeMethods Node { get; }
/// <summary>
/// Edge methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IEdgeMethods Edge { get; }
/// <summary>
/// Batch methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IBatchMethods Batch { get; }
/// <summary>
/// Vector index methods.
/// </summary>
public override LiteGraph.GraphRepositories.Interfaces.IVectorIndexMethods VectorIndex { get; }
#endregion
#region Private-Members
private readonly FastDB _database;
private readonly FastDBOptions _options;
#endregion
#region Constructors-and-Factories
/// <summary>
/// Initialize the FastDB graph repository with default options.
/// </summary>
/// <param name="databasePath">Path to the FastDB database directory.</param>
public FastDBGraphRepository(string databasePath)
: this(databasePath, new FastDBOptions())
{
}
/// <summary>
/// Initialize the FastDB graph repository with custom options.
/// </summary>
/// <param name="databasePath">Path to the FastDB database directory.</param>
/// <param name="options">FastDB options for compression, encryption, serialization, etc.</param>
public FastDBGraphRepository(string databasePath, FastDBOptions options)
{
if (string.IsNullOrEmpty(databasePath))
throw new ArgumentNullException(nameof(databasePath));
// Configure options for optimal graph storage
// Note: FastDBOptions properties are init-only, so we need to create a new instance
_options = options ?? new FastDBOptions
{
Serializer = SerializerType.MessagePack_Contract // Use MessagePack for compact storage (can reduce size by ~40%)
};
_database = new FastDB(_options);
// Initialize implementation classes
Admin = new Implementations.FastDB.AdminMethods(this);
Tenant = new Implementations.FastDB.TenantMethods(this);
User = new Implementations.FastDB.UserMethods(this);
Credential = new Implementations.FastDB.CredentialMethods(this);
Label = new Implementations.FastDB.LabelMethods(this);
Tag = new Implementations.FastDB.TagMethods(this);
Vector = new Implementations.FastDB.VectorMethods(this);
Graph = new Implementations.FastDB.GraphMethods(this);
Node = new Implementations.FastDB.NodeMethods(this);
Edge = new Implementations.FastDB.EdgeMethods(this);
Batch = new Implementations.FastDB.BatchMethods(this);
VectorIndex = new Implementations.FastDB.VectorIndexMethods(this);
}
#endregion
#region Public-Methods
/// <summary>
/// Initialize the repository schema.
/// Collections are created when first used via GetCollection<TKey, TValue>()
/// </summary>
public override void InitializeRepository()
{
// FastDB automatically creates collections on first access
// No explicit initialization needed
}
/// <summary>
/// Flush database contents to disk.
/// </summary>
public override void Flush()
{
// FastDB collections are automatically flushed
// The database handles persistence internally
}
/// <summary>
/// Get the FastDB database instance.
/// </summary>
/// <returns>FastDB database instance.</returns>
internal FastDB GetDatabase()
{
return _database;
}
/// <summary>
/// Dispose the repository and close database connection.
/// </summary>
public void Dispose()
{
_database?.Close();
}
#endregion
#region Private-Methods
#endregion
}
}