23 namespace Deveel.Data.Store {
24 [DebuggerDisplay(
"[{Id}] {Name}")]
33 : base(system.IsReadOnly) {
39 public string Name {
get;
private set; }
41 public int Id {
get;
private set; }
43 public bool IsOpen {
get;
private set; }
45 private object CheckPointLock {
49 protected override long DataAreaEndOffset {
50 get {
return DataLength; }
53 public long DataLength {
55 return dataStream == null ? 0 : dataStream.Length;
60 lock (CheckPointLock) {
61 if (dataStream != null)
62 dataStream.SetLength(length);
66 internal void Create(
int bufferSize) {
67 lock (CheckPointLock) {
68 dataStream =
new MemoryStream(bufferSize);
73 public override void Lock() {
86 lock (CheckPointLock) {
87 dataStream =
new MemoryStream();
90 if (inputStream != null) {
91 inputStream.Seek(0, SeekOrigin.Begin);
92 inputStream.CopyTo(dataStream);
100 lock (CheckPointLock) {
106 protected override int Read(
long offset, byte[] buffer,
int index,
int length) {
107 lock (CheckPointLock) {
108 if (dataStream == null || !IsOpen)
111 dataStream.Seek(offset, SeekOrigin.Begin);
112 return dataStream.Read(buffer, index, length);
116 protected override void Write(
long offset, byte[] buffer,
int index,
int length) {
117 lock (CheckPointLock) {
118 if (dataStream != null && IsOpen) {
119 dataStream.Seek(offset, SeekOrigin.Begin);
120 dataStream.Write(buffer, index, length);
127 protected override void Dispose(
bool disposing) {
129 base.Dispose(disposing);
132 lock (CheckPointLock) {
133 if (dataStream != null)
134 dataStream.Dispose();
146 lock (CheckPointLock) {
147 if (dataStream != null) {
148 dataStream.Seek(0, SeekOrigin.Begin);
149 dataStream.CopyTo(stream);
override void CloseStore()
override void Dispose(bool disposing)
Stream LoadStoreData(int id)
override void Lock()
This method is called before the start of a sequence of Write commands between consistant states of s...
override void SetDataAreaSize(long length)
SingleFileStoreSystem system
SingleFileStore(SingleFileStoreSystem system, string name, int id)
override void OpenStore(bool readOnly)
override void Write(long offset, byte[] buffer, int index, int length)
override int Read(long offset, byte[] buffer, int index, int length)
void WriteTo(Stream stream)
void Create(int bufferSize)
override void Unlock()
This method is called after the end of a sequence of Write commands between consistant states of some...