18 using System.Collections.Generic;
23 namespace Deveel.Data.Sql.Tables {
34 this.mainTable = mainTable;
35 this.composites = composites;
38 int size = composites.Length;
39 rowIndexes =
new IList<int>[size];
43 for (
int i = 0; i < size; ++i) {
44 rowIndexes[i] = composites[i].SelectAllRows().ToList();
47 RemoveDuplicates(all);
49 throw new InvalidOperationException(
"Unrecognised composite function");
56 throw new NotImplementedException();
60 : this(composites[0], composites, function, all) {
68 get {
return mainTable.
Context; }
71 protected override int ColumnCount {
72 get {
return mainTable.TableInfo.ColumnCount; }
75 public override void Lock() {
78 for (
int i = 0; i < composites.Length; ++i) {
86 for (
int i = 0; i < composites.Length; ++i) {
87 composites[i].Release();
92 var rows = this.Select(x => x.RowId.RowNumber).ToArray();
93 rootInfo.
Add(
this, rows);
97 public override int RowCount {
98 get {
return rowIndexes.Sum(t => t.Count); }
102 var index = columnIndexes[column];
105 columnIndexes[column] = index;
114 return index.GetSubset(table, originalColumn);
117 protected override IEnumerable<int>
ResolveRows(
int column, IEnumerable<int> rowSet,
ITable ancestor) {
118 if (ancestor !=
this)
119 throw new InvalidOperationException();
125 for (
int i = 0; i < rowIndexes.Length; ++i) {
126 var list = rowIndexes[i];
129 return composites[i].GetValue(list[(
int)rowNumber], columnOffset);
134 throw new ArgumentOutOfRangeException(
"rowNumber", String.Format(
"Row '{0}' out of range.", rowNumber));
138 return mainTable.GetResolvedColumnName(column);
142 return mainTable.IndexOfColumn(columnName);
150 return this == other;
Defines the contract to access the data contained into a table of a database.
void RemoveDuplicates(bool all)
override DataObject GetValue(long rowNumber, int columnOffset)
Gets a single cell within the table that is located at the given column offset and row...
bool TypeEquals(IRootTable other)
TableInfo(ObjectName tableName)
Constructs the object with the given table name.
override IEnumerable< int > ResolveRows(int column, IEnumerable< int > rowSet, ITable ancestor)
Describes the name of an object within a database.
override IEnumerator< Row > GetEnumerator()
readonly ITable[] composites
readonly ColumnIndex[] columnIndexes
CompositeTable(ITable[] composites, CompositeFunction function, bool all)
readonly IList< int >[] rowIndexes
override ColumnIndex GetIndex(int column, int originalColumn, ITable table)
override int IndexOfColumn(ObjectName columnName)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
TableInfo TableInfo
Gets the metadata information of the table, used to resolve the column sources.
void Add(IRootTable table, IList< int > rowSet)
override RawTableInfo GetRawTableInfo(RawTableInfo rootInfo)
readonly ITable mainTable
int ColumnCount
Gets a count of the columns defined by this object.
CompositeFunction
The kind of composite function in a CompositeTable.
CompositeTable(ITable mainTable, ITable[] composites, CompositeFunction function, bool all)
override ObjectName GetResolvedColumnName(int column)
Defines the metadata properties of a table existing within a database.
Interface that is implemented by all root tables.