Definition at line 28 of file SingleFileStoreSystem.cs.
Definition at line 45 of file SingleFileStoreSystem.cs.
47 throw new ArgumentNullException(
"context");
void Configure(IConfiguration config)
Deveel.Data.Store.SingleFileStoreSystem.~SingleFileStoreSystem |
( |
| ) |
|
|
inlineprivate |
bool IStoreSystem. Deveel.Data.Store.SingleFileStoreSystem.CloseStore |
( |
IStore |
store | ) |
|
|
inlineprivate |
Closes a store that has been either created or opened with the CreateStore or OpenStore methods.
- Parameters
-
- Returns
- Returns true if the store was successfully closed.
Implements Deveel.Data.Store.IStoreSystem.
Definition at line 277 of file SingleFileStoreSystem.cs.
bool IStoreSystem. CloseStore(IStore store)
Closes a store that has been either created or opened with the CreateStore or OpenStore methods...
bool Deveel.Data.Store.SingleFileStoreSystem.CloseStore |
( |
SingleFileStore |
store | ) |
|
|
inline |
Definition at line 281 of file SingleFileStoreSystem.cs.
283 SingleFileStore fileStore;
285 throw new IOException(
"The store was not found in this database.");
289 }
catch (IOException) {
291 }
catch (Exception ex) {
292 throw new IOException(
"Unable to close the store.", ex);
bool TryFindStore(string storeName, out SingleFileStore store)
void Deveel.Data.Store.SingleFileStoreSystem.Configure |
( |
IConfiguration |
config | ) |
|
|
inlineprivate |
Definition at line 60 of file SingleFileStoreSystem.cs.
61 var basePath = config.GetString(
"database.basePath");
62 var fileName = config.GetString(
"database.fileName");
63 var fullPath = config.GetString(
"database.fullPath");
65 if (
String.IsNullOrEmpty(basePath)) {
66 if (
String.IsNullOrEmpty(fullPath)) {
71 }
else if (
String.IsNullOrEmpty(fileName)) {
72 if (!
String.IsNullOrEmpty(basePath)) {
75 }
else if (!
String.IsNullOrEmpty(fullPath)) {
78 }
else if (
String.IsNullOrEmpty(fullPath)) {
A long string in the system.
const string DefaultFileExtension
string CombinePath(string path1, string path2)
IStore IStoreSystem. Deveel.Data.Store.SingleFileStoreSystem.CreateStore |
( |
string |
name | ) |
|
|
inlineprivate |
SingleFileStore Deveel.Data.Store.SingleFileStoreSystem.CreateStore |
( |
string |
name | ) |
|
|
inline |
Definition at line 241 of file SingleFileStoreSystem.cs.
243 SingleFileStore store;
245 throw new IOException(
string.Format(
"The store '{0}' already exists in this database.", name));
248 nameIdMap =
new Dictionary<string, int>();
251 stores =
new Dictionary<int, SingleFileStore>();
254 store =
new SingleFileStore(
this, name,
id);
bool TryFindStore(string storeName, out SingleFileStore store)
IDictionary< string, int > nameIdMap
readonly object checkPointLock
IDictionary< int, SingleFileStore > stores
bool IStoreSystem. Deveel.Data.Store.SingleFileStoreSystem.DeleteStore |
( |
IStore |
store | ) |
|
|
inlineprivate |
Permanently deletes a store from the system - use with care!
- Parameters
-
Note that it is quite likely that a store may fail to delete in which case the delete operation should be re-tried after a short timeout.
- Returns
- Returns true if the store was successfully deleted and the resources associated with it were freed. Returns false if the store could not be deleted.
Implements Deveel.Data.Store.IStoreSystem.
Definition at line 296 of file SingleFileStoreSystem.cs.
bool IStoreSystem. DeleteStore(IStore store)
Permanently deletes a store from the system - use with care!
bool Deveel.Data.Store.SingleFileStoreSystem.DeleteStore |
( |
SingleFileStore |
store | ) |
|
|
inline |
Definition at line 300 of file SingleFileStoreSystem.cs.
305 return stores.Remove(store.Id);
306 }
catch (IOException) {
308 }
catch (Exception ex) {
309 throw new IOException(
"Unable to delete the store.", ex);
IDictionary< string, int > nameIdMap
IDictionary< int, SingleFileStore > stores
void Deveel.Data.Store.SingleFileStoreSystem.Dispose |
( |
| ) |
|
|
inline |
void Deveel.Data.Store.SingleFileStoreSystem.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprivate |
Definition at line 103 of file SingleFileStoreSystem.cs.
106 foreach (var store
in stores.Values) {
IDictionary< int, StoreInfo > storeInfo
IDictionary< int, SingleFileStore > stores
int Deveel.Data.Store.SingleFileStoreSystem.FindMaxStoreId |
( |
| ) |
|
|
inlineprivate |
long Deveel.Data.Store.SingleFileStoreSystem.GetDataStartOffset |
( |
| ) |
|
|
inlineprivate |
Definition at line 344 of file SingleFileStoreSystem.cs.
347 foreach (var store
in stores.Values) {
348 var nameLength = Encoding.Unicode.GetByteCount(store.Name);
350 offset += 4 + nameLength + 4 + 8 + 8;
IDictionary< int, SingleFileStore > stores
void Deveel.Data.Store.SingleFileStoreSystem.LoadHeaders |
( |
BinaryReader |
reader | ) |
|
|
inlineprivate |
Definition at line 169 of file SingleFileStoreSystem.cs.
170 var magic = reader.ReadInt32();
173 throw new IOException(
"The magic number in the header is invalid.");
175 var version = reader.ReadInt32();
176 var lastModified = reader.ReadInt64();
177 var storeCount = reader.ReadInt32();
182 storeInfo =
new Dictionary<int, StoreInfo>(storeCount);
184 for (
int i = 0; i < storeCount; i++) {
185 var strLength = reader.ReadInt32();
186 var nameChars = reader.ReadChars(strLength);
188 var name =
new string(nameChars);
189 var
id = reader.ReadInt32();
190 var offset = reader.ReadInt64();
191 var size = reader.ReadInt64();
193 storeInfo[id] =
new StoreInfo(name,
id, offset, size);
196 nameIdMap =
new Dictionary<string, int>();
IDictionary< string, int > nameIdMap
IDictionary< int, StoreInfo > storeInfo
Stream Deveel.Data.Store.SingleFileStoreSystem.LoadStoreData |
( |
int |
id | ) |
|
|
inlinepackage |
Definition at line 202 of file SingleFileStoreSystem.cs.
208 var size = info.Size;
209 var offset = info.Offset;
212 using (var stream =
new FileStream(dataFile)) {
213 stream.Seek(offset, SeekOrigin.Begin);
215 var buffer =
new byte[size];
217 var outputStream =
new MemoryStream();
220 stream.Read(buffer, 0, (
int) size);
222 outputStream.Write(buffer, 0, buffer.Length);
224 if (outputStream.Length != size)
225 throw new IOException(
"Corruption when reading the store.");
IDictionary< int, StoreInfo > storeInfo
IFile OpenFile(string path, bool readOnly)
void Deveel.Data.Store.SingleFileStoreSystem.LoadStores |
( |
IFile |
dataFile | ) |
|
|
inlineprivate |
Definition at line 161 of file SingleFileStoreSystem.cs.
162 using (var fileStream =
new FileStream(dataFile)) {
163 using (var reader =
new BinaryReader(fileStream, Encoding.Unicode)) {
void LoadHeaders(BinaryReader reader)
void Deveel.Data.Store.SingleFileStoreSystem.Lock |
( |
string |
lockName | ) |
|
|
inline |
Definition at line 426 of file SingleFileStoreSystem.cs.
427 SingleFileStore store;
bool TryFindStore(string storeName, out SingleFileStore store)
void Deveel.Data.Store.SingleFileStoreSystem.OpenOrCreateFile |
( |
| ) |
|
|
inlineprivate |
Definition at line 130 of file SingleFileStoreSystem.cs.
131 bool created =
false;
138 throw new InvalidOperationException(
139 string.Format(
"The file '{0}' does not exist and the store is configured to be read-only.",
FileName));
149 using (var stream =
new FileStream(dataFile)) {
156 if (dataFile != null)
bool FileExists(string path)
void LoadStores(IFile dataFile)
void WriteHeaders(Stream stream, long dataStartOffset)
IFile CreateFile(string path)
IFile OpenFile(string path, bool readOnly)
IStore IStoreSystem. Deveel.Data.Store.SingleFileStoreSystem.OpenStore |
( |
string |
name | ) |
|
|
inlineprivate |
SingleFileStore Deveel.Data.Store.SingleFileStoreSystem.OpenStore |
( |
string |
name | ) |
|
|
inline |
Definition at line 266 of file SingleFileStoreSystem.cs.
268 SingleFileStore store;
270 throw new IOException(
string.Format(
"The store '{0}' does not exist in this database.", name));
bool TryFindStore(string storeName, out SingleFileStore store)
readonly object checkPointLock
void Deveel.Data.Store.SingleFileStoreSystem.SetCheckPoint |
( |
| ) |
|
|
inline |
Sets a new check point at the current state of this store system.
This is intended to help journalling check point and recovery systems. A check point is set whenever data is committed to the database. Some systems can be designed to be able to roll forward or backward to different check points. Each check point represents a stable state in the database life cycle.
A checkpoint based system greatly improves stability because if a crash occurs in an intermediate state the changes can simply be rolled back to the last stable state.
An implementation may choose not to implement check points in which case this would be a no-op.
Implements Deveel.Data.Store.IStoreSystem.
Definition at line 316 of file SingleFileStoreSystem.cs.
323 using (var stream =
new FileStream(dataFile)) {
336 }
catch (IOException) {
338 }
catch (Exception ex) {
339 throw new IOException(
"An error occurred while saving data to database file.", ex);
long GetDataStartOffset()
bool DeleteFile(string path)
bool FileExists(string path)
readonly object checkPointLock
void WriteHeaders(Stream stream, long dataStartOffset)
void WriteStores(Stream stream)
IFile CreateFile(string path)
bool RenameFile(string sourcePath, string destPath)
bool Deveel.Data.Store.SingleFileStoreSystem.StoreExists |
( |
string |
name | ) |
|
|
inline |
Definition at line 232 of file SingleFileStoreSystem.cs.
233 SingleFileStore store;
bool TryFindStore(string storeName, out SingleFileStore store)
bool Deveel.Data.Store.SingleFileStoreSystem.TryFindStore |
( |
string |
storeName, |
|
|
out SingleFileStore |
store |
|
) |
| |
|
inlineprivate |
Definition at line 411 of file SingleFileStoreSystem.cs.
418 if (
stores == null || !
stores.TryGetValue(
id, out store)) {
IDictionary< string, int > nameIdMap
IDictionary< int, SingleFileStore > stores
void Deveel.Data.Store.SingleFileStoreSystem.Unlock |
( |
string |
lockName | ) |
|
|
inline |
Definition at line 434 of file SingleFileStoreSystem.cs.
435 SingleFileStore store;
bool TryFindStore(string storeName, out SingleFileStore store)
void Deveel.Data.Store.SingleFileStoreSystem.WriteHeaders |
( |
Stream |
stream, |
|
|
long |
dataStartOffset |
|
) |
| |
|
inlineprivate |
Definition at line 384 of file SingleFileStoreSystem.cs.
385 var writer =
new BinaryWriter(stream, Encoding.Unicode);
388 writer.Write(
DateTime.UtcNow.Ticks);
393 writer.Write(storeCount);
396 long offset = dataStartOffset;
401 foreach (var store
in stores.Values) {
IDictionary< int, StoreInfo > storeInfo
IDictionary< int, SingleFileStore > stores
long WriteStoreInfo(BinaryWriter writer, long offset, SingleFileStore store)
long Deveel.Data.Store.SingleFileStoreSystem.WriteStoreInfo |
( |
BinaryWriter |
writer, |
|
|
long |
offset, |
|
|
SingleFileStore |
store |
|
) |
| |
|
inlineprivate |
Definition at line 364 of file SingleFileStoreSystem.cs.
365 var nameLength = store.Name.Length;
366 var name = store.Name;
368 var size = store.DataLength;
370 writer.Write(nameLength);
371 writer.Write(name.ToCharArray());
374 writer.Write(offset);
377 storeInfo[store.Id] =
new StoreInfo(name,
id, offset, size);
379 offset += store.DataLength;
IDictionary< int, StoreInfo > storeInfo
void Deveel.Data.Store.SingleFileStoreSystem.WriteStores |
( |
Stream |
stream | ) |
|
|
inlineprivate |
Definition at line 356 of file SingleFileStoreSystem.cs.
358 foreach (var store
in stores.Values) {
359 store.WriteTo(stream);
IDictionary< int, SingleFileStore > stores
readonly object Deveel.Data.Store.SingleFileStoreSystem.checkPointLock = new object() |
|
private |
const string Deveel.Data.Store.SingleFileStoreSystem.DefaultFileExtension = "db" |
bool Deveel.Data.Store.SingleFileStoreSystem.disposed |
|
private |
const int Deveel.Data.Store.SingleFileStoreSystem.Magic = 0xf09a671 |
|
private |
IDictionary<string, int> Deveel.Data.Store.SingleFileStoreSystem.nameIdMap |
|
private |
int Deveel.Data.Store.SingleFileStoreSystem.storeId |
|
private |
IDictionary<int, StoreInfo> Deveel.Data.Store.SingleFileStoreSystem.storeInfo |
|
private |
IDictionary<int, SingleFileStore> Deveel.Data.Store.SingleFileStoreSystem.stores |
|
private |
object Deveel.Data.Store.SingleFileStoreSystem.CheckPointLock |
|
get |
string Deveel.Data.Store.SingleFileStoreSystem.FileName |
|
getset |
IFileSystem Deveel.Data.Store.SingleFileStoreSystem.FileSystem |
|
getprivate |
bool Deveel.Data.Store.SingleFileStoreSystem.IsReadOnly |
|
getset |
string Deveel.Data.Store.SingleFileStoreSystem.LockFileName |
|
getprivate |
bool Deveel.Data.Store.SingleFileStoreSystem.ReadOnly |
|
getset |
string Deveel.Data.Store.SingleFileStoreSystem.TempFileName |
|
getprivate |
The documentation for this class was generated from the following file: