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

Public Member Functions

 InMemoryArea (long id, bool readOnly, byte[] data, int offset, int length)
 
void CopyTo (IArea destArea, int size)
 Copies the given amount of bytes from the current position of the this area to another one. More...
 
int Read (byte[] buffer, int offset, int length)
 Reads an array of bytes from the underlying IArea and advances the position by length . More...
 
void Write (byte[] buffer, int offset, int length)
 
void Flush ()
 

Properties

long Id [get, private set]
 
bool IsReadOnly [get, private set]
 
long Position [get, set]
 
int Capacity [get]
 
int Length [get, private set]
 
- Properties inherited from Deveel.Data.Store.IArea
long Id [get]
 Returns the unique identifier that represents this area. More...
 
bool IsReadOnly [get]
 Gets a value indicating whether this area can be written or not. More...
 
long Position [get, set]
 Returns or sets the current position of the pointer within the area. More...
 
int Length [get]
 

Private Member Functions

long CheckPositionBounds (int diff)
 

Private Attributes

readonly byte[] data
 
long position
 
readonly int startPosition
 
readonly int endPosition
 

Detailed Description

Definition at line 207 of file InMemoryStore.cs.

Constructor & Destructor Documentation

Deveel.Data.Store.InMemoryStore.InMemoryArea.InMemoryArea ( long  id,
bool  readOnly,
byte[]  data,
int  offset,
int  length 
)
inline

Member Function Documentation

long Deveel.Data.Store.InMemoryStore.InMemoryArea.CheckPositionBounds ( int  diff)
inlineprivate

Definition at line 245 of file InMemoryStore.cs.

245  {
246  var newPos = position + diff;
247  if (newPos > endPosition)
248  throw new IOException(String.Format("Attempt to read out of bounds: from {0} to {1} (position {2} to {3})",
249  startPosition, endPosition, position, newPos));
250 
251  var oldPos = position;
252  position = newPos;
253  return oldPos;
254  }
A long string in the system.
void Deveel.Data.Store.InMemoryStore.InMemoryArea.CopyTo ( IArea  destArea,
int  size 
)
inline

Copies the given amount of bytes from the current position of the this area to another one.

Parameters
destAreaThe IArea where to write.
sizeThe number of bytes to Write.

Implements Deveel.Data.Store.IArea.

Definition at line 256 of file InMemoryStore.cs.

256  {
257  const int bufferSize = 2048;
258  byte[] buf = new byte[bufferSize];
259  int toCopy = System.Math.Min(size, bufferSize);
260 
261  while (toCopy > 0) {
262  Read(buf, 0, toCopy);
263  destArea.Write(buf, 0, toCopy);
264  size -= toCopy;
265  toCopy = System.Math.Min(size, bufferSize);
266  }
267  }
int Read(byte[] buffer, int offset, int length)
Reads an array of bytes from the underlying IArea and advances the position by length ...
void Deveel.Data.Store.InMemoryStore.InMemoryArea.Flush ( )
inline

Implements Deveel.Data.Store.IArea.

Definition at line 286 of file InMemoryStore.cs.

286  {
287  }
int Deveel.Data.Store.InMemoryStore.InMemoryArea.Read ( byte[]  buffer,
int  offset,
int  length 
)
inline

Reads an array of bytes from the underlying IArea and advances the position by length .

Parameters
bufferThe destination buffer into which to Read the number of bytes given from the area.
offsetThe offset within the buffer from where to start writing the byte Read into.
lengthThe number of bytes to Read from the area. This is also the incremental size of the position of the area.
Returns
Returns the number of bytes actually Read from the IArea.

Implements Deveel.Data.Store.IArea.

Definition at line 269 of file InMemoryStore.cs.

269  {
270 #if PCL
271  Array.Copy(data, (int)CheckPositionBounds(length), buffer, offset, length);
272 #else
273  Array.Copy(data, CheckPositionBounds(length), buffer, offset, length);
274 #endif
275  return length;
276  }
void Deveel.Data.Store.InMemoryStore.InMemoryArea.Write ( byte[]  buffer,
int  offset,
int  length 
)
inline

Parameters
buffer
offset
length

Implements Deveel.Data.Store.IArea.

Definition at line 278 of file InMemoryStore.cs.

278  {
279 #if PCL
280  Array.Copy(buffer, offset, data, (int) CheckPositionBounds(length), length);
281 #else
282  Array.Copy(buffer, offset, data, CheckPositionBounds(length), length);
283 #endif
284  }

Member Data Documentation

readonly byte [] Deveel.Data.Store.InMemoryStore.InMemoryArea.data
private

Definition at line 208 of file InMemoryStore.cs.

readonly int Deveel.Data.Store.InMemoryStore.InMemoryArea.endPosition
private

Definition at line 211 of file InMemoryStore.cs.

long Deveel.Data.Store.InMemoryStore.InMemoryArea.position
private

Definition at line 209 of file InMemoryStore.cs.

readonly int Deveel.Data.Store.InMemoryStore.InMemoryArea.startPosition
private

Definition at line 210 of file InMemoryStore.cs.

Property Documentation

int Deveel.Data.Store.InMemoryStore.InMemoryArea.Capacity
get

Definition at line 239 of file InMemoryStore.cs.

long Deveel.Data.Store.InMemoryStore.InMemoryArea.Id
getprivate set

Definition at line 224 of file InMemoryStore.cs.

bool Deveel.Data.Store.InMemoryStore.InMemoryArea.IsReadOnly
getprivate set

Definition at line 226 of file InMemoryStore.cs.

int Deveel.Data.Store.InMemoryStore.InMemoryArea.Length
getprivate set

Definition at line 243 of file InMemoryStore.cs.

long Deveel.Data.Store.InMemoryStore.InMemoryArea.Position
getset

Definition at line 228 of file InMemoryStore.cs.


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