DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | Package Functions | Properties | Private Attributes | List of all members
Deveel.Data.Store.SingleFileStore Class Reference
Inheritance diagram for Deveel.Data.Store.SingleFileStore:
Deveel.Data.Store.StoreBase Deveel.Data.Store.IStore

Public Member Functions

override void Lock ()
 This method is called before the start of a sequence of Write commands between consistant states of some data structure represented by the store. More...
 
override void Unlock ()
 This method is called after the end of a sequence of Write commands between consistant states of some data structure represented by the store. More...
 
- Public Member Functions inherited from Deveel.Data.Store.StoreBase
bool Open ()
 
void Close ()
 
void Dispose ()
 
IArea CreateArea (long size)
 Allocates a block of memory in the store of the specified size and returns an IArea object that can be used to initialize the contents of the area. More...
 
void DeleteArea (long id)
 Deletes an area that was previously allocated by the CreateArea method by the area id. More...
 
IArea GetArea (long id, bool readOnly)
 Returns an object that allows for the contents of an area (represented by the id parameter) to be Read. More...
 
IEnumerable< long > GetAllAreas ()
 Returns a complete list of pointers to all areas in the Store as long objects sorted from lowest pointer to highest. More...
 

Protected Member Functions

override void SetDataAreaSize (long length)
 
override void OpenStore (bool readOnly)
 
override void CloseStore ()
 
override int Read (long offset, byte[] buffer, int index, int length)
 
override void Write (long offset, byte[] buffer, int index, int length)
 
override void Dispose (bool disposing)
 
- Protected Member Functions inherited from Deveel.Data.Store.StoreBase
 StoreBase (bool isReadOnly)
 
void ReadAreaHeader (long offset, long[] header)
 
void SplitArea (long offset, long newBoundary)
 
int ReadByte (long offset)
 
void Write (long offset, byte value)
 

Package Functions

 SingleFileStore (SingleFileStoreSystem system, string name, int id)
 
void Create (int bufferSize)
 
void WriteTo (Stream stream)
 
- Package Functions inherited from Deveel.Data.Store.StoreBase
IEnumerable< long > FindAllocatedAreasNotIn (List< long > usedAreas)
 

Properties

string Name [get, private set]
 
int Id [get, private set]
 
bool IsOpen [get, private set]
 
object CheckPointLock [get]
 
override long DataAreaEndOffset [get]
 
long DataLength [get]
 
- Properties inherited from Deveel.Data.Store.StoreBase
long WildernessOffset [get, set]
 
bool IsReadOnly [get, private set]
 
abstract long DataAreaEndOffset [get]
 
bool ClosedClean [get, private set]
 
- Properties inherited from Deveel.Data.Store.IStore
bool ClosedClean [get]
 Indicates if the store was closed cleanly last time was accessed. More...
 

Private Attributes

SingleFileStoreSystem system
 
Stream dataStream
 
int lockCount
 
bool disposed
 

Detailed Description

Definition at line 25 of file SingleFileStore.cs.

Constructor & Destructor Documentation

Deveel.Data.Store.SingleFileStore.SingleFileStore ( SingleFileStoreSystem  system,
string  name,
int  id 
)
inlinepackage

Definition at line 32 of file SingleFileStore.cs.

Member Function Documentation

override void Deveel.Data.Store.SingleFileStore.CloseStore ( )
inlineprotectedvirtual

Implements Deveel.Data.Store.StoreBase.

Definition at line 99 of file SingleFileStore.cs.

99  {
100  lock (CheckPointLock) {
101  if (lockCount == 0)
102  IsOpen = false;
103  }
104  }
void Deveel.Data.Store.SingleFileStore.Create ( int  bufferSize)
inlinepackage

Definition at line 66 of file SingleFileStore.cs.

66  {
67  lock (CheckPointLock) {
68  dataStream = new MemoryStream(bufferSize);
69  IsOpen = true;
70  }
71  }
override void Deveel.Data.Store.SingleFileStore.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented from Deveel.Data.Store.StoreBase.

Definition at line 127 of file SingleFileStore.cs.

127  {
128  if (!disposed) {
129  base.Dispose(disposing);
130 
131  if (disposing) {
132  lock (CheckPointLock) {
133  if (dataStream != null)
134  dataStream.Dispose();
135  }
136  }
137 
138  dataStream = null;
139  system = null;
140  IsOpen = false;
141  disposed = true;
142  }
143  }
override void Deveel.Data.Store.SingleFileStore.Lock ( )
inlinevirtual

This method is called before the start of a sequence of Write commands between consistant states of some data structure represented by the store.

This Lock mechanism is intended to inform the store when it is not safe to checkpoint the data in a log, ensuring that no partial updates are committed to a transaction log and the data can be restored in a consistant manner.

If the store does not implement a check point log or is otherwise not interested in consistant states of the data, then it is not necessary for this method to do anything.

This method prevents a check point from happening during some sequence of operations. This method should not Lock unless a check point is in progress. This method does not prevent concurrent writes to the store.

See also
Unlock

Implements Deveel.Data.Store.StoreBase.

Definition at line 73 of file SingleFileStore.cs.

73  {
74  lockCount++;
75  }
override void Deveel.Data.Store.SingleFileStore.OpenStore ( bool  readOnly)
inlineprotectedvirtual

Implements Deveel.Data.Store.StoreBase.

Definition at line 85 of file SingleFileStore.cs.

85  {
86  lock (CheckPointLock) {
87  dataStream = new MemoryStream();
88 
89  var inputStream = system.LoadStoreData(Id);
90  if (inputStream != null) {
91  inputStream.Seek(0, SeekOrigin.Begin);
92  inputStream.CopyTo(dataStream);
93  }
94 
95  IsOpen = true;
96  }
97  }
override int Deveel.Data.Store.SingleFileStore.Read ( long  offset,
byte[]  buffer,
int  index,
int  length 
)
inlineprotectedvirtual

Implements Deveel.Data.Store.StoreBase.

Definition at line 106 of file SingleFileStore.cs.

106  {
107  lock (CheckPointLock) {
108  if (dataStream == null || !IsOpen)
109  return 0;
110 
111  dataStream.Seek(offset, SeekOrigin.Begin);
112  return dataStream.Read(buffer, index, length);
113  }
114  }
override void Deveel.Data.Store.SingleFileStore.SetDataAreaSize ( long  length)
inlineprotectedvirtual

Implements Deveel.Data.Store.StoreBase.

Definition at line 59 of file SingleFileStore.cs.

59  {
60  lock (CheckPointLock) {
61  if (dataStream != null)
62  dataStream.SetLength(length);
63  }
64  }
override void Deveel.Data.Store.SingleFileStore.Unlock ( )
inlinevirtual

This method is called after the end of a sequence of Write commands between consistant states of some data structure represented by the store.

See the Lock method for a further description of the operation of this locking mechanism.

See also
Lock

Implements Deveel.Data.Store.StoreBase.

Definition at line 77 of file SingleFileStore.cs.

77  {
78  lockCount--;
79  }
override void Deveel.Data.Store.SingleFileStore.Write ( long  offset,
byte[]  buffer,
int  index,
int  length 
)
inlineprotectedvirtual

Implements Deveel.Data.Store.StoreBase.

Definition at line 116 of file SingleFileStore.cs.

116  {
117  lock (CheckPointLock) {
118  if (dataStream != null && IsOpen) {
119  dataStream.Seek(offset, SeekOrigin.Begin);
120  dataStream.Write(buffer, index, length);
121  }
122  }
123  }
void Deveel.Data.Store.SingleFileStore.WriteTo ( Stream  stream)
inlinepackage

Definition at line 145 of file SingleFileStore.cs.

145  {
146  lock (CheckPointLock) {
147  if (dataStream != null) {
148  dataStream.Seek(0, SeekOrigin.Begin);
149  dataStream.CopyTo(stream);
150  }
151  }
152  }

Member Data Documentation

Stream Deveel.Data.Store.SingleFileStore.dataStream
private

Definition at line 27 of file SingleFileStore.cs.

bool Deveel.Data.Store.SingleFileStore.disposed
private

Definition at line 125 of file SingleFileStore.cs.

int Deveel.Data.Store.SingleFileStore.lockCount
private

Definition at line 30 of file SingleFileStore.cs.

SingleFileStoreSystem Deveel.Data.Store.SingleFileStore.system
private

Definition at line 26 of file SingleFileStore.cs.

Property Documentation

object Deveel.Data.Store.SingleFileStore.CheckPointLock
getprivate

Definition at line 45 of file SingleFileStore.cs.

override long Deveel.Data.Store.SingleFileStore.DataAreaEndOffset
getprotected

Definition at line 49 of file SingleFileStore.cs.

long Deveel.Data.Store.SingleFileStore.DataLength
get

Definition at line 53 of file SingleFileStore.cs.

int Deveel.Data.Store.SingleFileStore.Id
getprivate set

Definition at line 41 of file SingleFileStore.cs.

bool Deveel.Data.Store.SingleFileStore.IsOpen
getprivate set

Definition at line 43 of file SingleFileStore.cs.

string Deveel.Data.Store.SingleFileStore.Name
getprivate set

Definition at line 39 of file SingleFileStore.cs.


The documentation for this class was generated from the following file: