mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
* DataContainer.cs - added. Provides implementation for data containers that holds data in arrays of primitives or objects. Each data container belongs to specific DataColumn. * DbDataAdapter.cs - changes to complete data storage redesign. Bug fix in FillTable ( to fetch exact number of records required ). svn path=/trunk/mcs/; revision=27655
73 lines
1.2 KiB
C#
73 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
|
|
namespace System.Data.Common
|
|
{
|
|
internal class RecordCache
|
|
{
|
|
#region Fields
|
|
|
|
const int MIN_CACHE_SIZE = 128;
|
|
|
|
Stack _records = new Stack(16);
|
|
int _nextFreeIndex = 0;
|
|
int _currentCapacity = 0;
|
|
DataTable _table;
|
|
|
|
#endregion // Fields
|
|
|
|
#region Constructors
|
|
|
|
internal RecordCache(DataTable table)
|
|
{
|
|
_table = table;
|
|
}
|
|
|
|
#endregion //Constructors
|
|
|
|
#region Properties
|
|
|
|
internal int CurrentCapacity
|
|
{
|
|
get {
|
|
return _currentCapacity;
|
|
}
|
|
}
|
|
|
|
#endregion // Properties
|
|
|
|
#region Methods
|
|
|
|
internal int NewRecord()
|
|
{
|
|
if (_records.Count > 0) {
|
|
return (int)_records.Pop();
|
|
}
|
|
else {
|
|
DataColumnCollection cols = _table.Columns;
|
|
if (_nextFreeIndex >= _currentCapacity) {
|
|
_currentCapacity *= 2;
|
|
if ( _currentCapacity < MIN_CACHE_SIZE ) {
|
|
_currentCapacity = MIN_CACHE_SIZE;
|
|
}
|
|
foreach(DataColumn col in cols) {
|
|
col.DataContainer.Capacity = _currentCapacity;
|
|
}
|
|
}
|
|
return _nextFreeIndex++;
|
|
}
|
|
}
|
|
|
|
internal void DisposeRecord(int index)
|
|
{
|
|
if ( index < 0 ) {
|
|
throw new ArgumentException();
|
|
}
|
|
_records.Push(index);
|
|
}
|
|
|
|
#endregion // Methods
|
|
|
|
}
|
|
}
|