19 using System.Collections.Generic;
25 namespace Deveel.Data.Sql.Tables {
29 private readonly
object colLookupLock =
new object();
35 public abstract IEnumerator<Row> GetEnumerator();
37 IEnumerator IEnumerable.GetEnumerator() {
38 return GetEnumerator();
43 GC.SuppressFinalize(
this);
46 protected virtual void Dispose(
bool disposing) {
53 public bool IsLocked {
get;
private set; }
60 get {
return ColumnCount; }
63 protected virtual int ColumnCount {
67 public abstract int RowCount {
get; }
69 public abstract void Lock();
71 public abstract void Release();
83 OnLockAcquired(@lock);
91 OnLockReleased(@lock);
106 return GetResolvedColumnName(column);
110 return GetIndex(column, originalColumn, table);
114 return GetIndex(column);
117 protected abstract IEnumerable<int> ResolveRows(
int column, IEnumerable<int> rowSet,
ITable ancestor);
120 return ResolveRows(columnOffset, rows, ancestor);
126 return GetRawTableInfo(rootInfo);
129 public abstract DataObject GetValue(
long rowNumber,
int columnOffset);
132 return GetIndex(columnOffset, columnOffset,
this);
144 lock (colLookupLock) {
145 if (colNameLookup == null)
146 colNameLookup =
new Dictionary<ObjectName, int>(30);
149 if (!colNameLookup.TryGetValue(columnName, out index)) {
150 index = IndexOfColumn(columnName);
151 colNameLookup[columnName] = index;
159 return FindColumn(columnName);
163 return TableInfo[columnOffset].ColumnType;
167 return GetColumnType(FindColumn(columnName));
174 #region TableVariableResolver
183 this.rowIndex = rowIndex;
190 int colIndex = table.FindColumn(columnName);
191 if (colIndex == -1) {
192 throw new InvalidOperationException(
"Can't find column: " + columnName);
198 return table.GetValue(rowIndex, FindColumnName(columnName));
202 return table.GetColumnType(columnName);
DataObject Resolve(ObjectName columnName)
Returns the value of a given variable.
virtual int IndexOfColumn(ObjectName columnName)
Defines the contract to access the data contained into a table of a database.
virtual ColumnIndex GetIndex(int column, int originalColumn, ITable table)
virtual void Dispose(bool disposing)
SqlType GetColumnType(ObjectName columnName)
Dictionary< ObjectName, int > colNameLookup
Represents a database object, such as a table, a trigger, a type or a column.
int FindColumn(ObjectName columnName)
IEnumerable< int > ResolveRows(int column, IEnumerable< int > rowSet, ITable ancestor)
Describes the name of an object within a database.
ObjectName TableName
Gets the fully qualified name of the table that is ensured to be unique within the system...
virtual ObjectName GetResolvedColumnName(int column)
ITableVariableResolver GetVariableResolver()
void Acquired(Lock @lock)
int FindColumn(ObjectName columnName)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
TableVariableResolver(Table table, int rowIndex)
void Released(Lock @lock)
TableVariableResolver(Table table)
DbObjectType ObjectType
Gets the type of database object that the implementation is for
Defines the properties of a specific SQL Type and handles the values compatible.
virtual void OnLockAcquired(Lock @lock)
int FindColumnName(ObjectName columnName)
ColumnIndex GetIndex(int columnOffset)
Gets an index for given column that can be used to select values from this table. ...
int IndexOfColumn(string columnName)
Gets the offset of the column with the given name.
string Name
Gets the name of the object being referenced.
ObjectName GetResolvedColumnName(int columnOffset)
SqlType ReturnType(ObjectName columnName)
Returns the SqlType of object the given variable is.
int ColumnCount
Gets a count of the columns defined by this object.
RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
ColumnIndex GetIndex(int column, int originalColumn, ITable table)
DbObjectType
The kind of objects that can be handled by a database system and its managers
Defines the metadata properties of a table existing within a database.
SqlType GetColumnType(int columnOffset)
ITableVariableResolver ForRow(int row)
virtual void OnLockReleased(Lock @lock)