DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Sql.Tables.NaturallyJoinedTable Class Reference
Inheritance diagram for Deveel.Data.Sql.Tables.NaturallyJoinedTable:
Deveel.Data.Sql.Tables.JoinedTable Deveel.Data.Sql.Tables.Table Deveel.Data.Sql.Tables.IQueryTable Deveel.Data.Transactions.ILockable Deveel.Data.Sql.Tables.ITable Deveel.Data.Sql.IDbObject

Public Member Functions

 NaturallyJoinedTable (ITable left, ITable right)
 
- Public Member Functions inherited from Deveel.Data.Sql.Tables.JoinedTable
 JoinedTable (IEnumerable< ITable > tables)
 
 JoinedTable (ITable table)
 
override void Lock ()
 
override void Release ()
 
override DataObject GetValue (long rowNumber, int columnOffset)
 Gets a single cell within the table that is located at the given column offset and row. More...
 
override IEnumerator< RowGetEnumerator ()
 
- Public Member Functions inherited from Deveel.Data.Sql.Tables.Table
void Dispose ()
 
ColumnIndex GetIndex (int columnOffset)
 Gets an index for given column that can be used to select values from this table. More...
 

Protected Member Functions

override IEnumerable< int > ResolveRowsForTable (IEnumerable< int > rowSet, int tableNum)
 
- Protected Member Functions inherited from Deveel.Data.Sql.Tables.JoinedTable
virtual void Init (IEnumerable< ITable > tables)
 
override int IndexOfColumn (ObjectName columnName)
 
override RawTableInfo GetRawTableInfo (RawTableInfo rootInfo)
 
override ObjectName GetResolvedColumnName (int column)
 
override ColumnIndex GetIndex (int column, int originalColumn, ITable table)
 
override IEnumerable< int > ResolveRows (int column, IEnumerable< int > rowSet, ITable ancestor)
 
int ResolveRowForTable (int rowNumber, int tableNum)
 
- Protected Member Functions inherited from Deveel.Data.Sql.Tables.Table
virtual void Dispose (bool disposing)
 
virtual void OnLockAcquired (Lock @lock)
 
virtual void OnLockReleased (Lock @lock)
 
int FindColumn (ObjectName columnName)
 

Properties

override int RowCount [get]
 
- Properties inherited from Deveel.Data.Sql.Tables.JoinedTable
ColumnIndex[] ColumnIndices [get]
 
int[] ColumnTable [get]
 
int[] ColumnFilter [get]
 
override int ColumnCount [get]
 
override IContext Context [get]
 
override TableInfo TableInfo [get]
 
ITable[] ReferenceTables [get]
 
int SortColumn [get, set]
 
- Properties inherited from Deveel.Data.Sql.Tables.Table
abstract IContext Context [get]
 
abstract TableInfo TableInfo [get]
 
bool IsLocked [get, private set]
 
object ILockable. RefId [get]
 
int IQueryTable. ColumnCount [get]
 
virtual int ColumnCount [get]
 
abstract int RowCount [get]
 
ObjectName FullName [get]
 
DbObjectType IDbObject. ObjectType [get]
 
- Properties inherited from Deveel.Data.Sql.Tables.IQueryTable
int ColumnCount [get]
 
- Properties inherited from Deveel.Data.Sql.Tables.ITable
IContext Context [get]
 
TableInfo TableInfo [get]
 Gets the metadata information of the table, used to resolve the column sources. More...
 
int RowCount [get]
 Gets the total number of rows in the table. More...
 
- Properties inherited from Deveel.Data.Sql.IDbObject
ObjectName FullName [get]
 Gets the fully qualified name of the object used to resolve it uniquely within the database. More...
 
DbObjectType ObjectType [get]
 Gets the type of database object that the implementation is for More...
 
- Properties inherited from Deveel.Data.Transactions.ILockable
object RefId [get]
 

Private Member Functions

int GetLeftRowIndex (int rowIndex)
 
int GetRightRowIndex (int rowIndex)
 

Private Attributes

readonly int leftRowCount
 
readonly int rightRowCount
 
readonly IList< int > leftSet
 
readonly IList< int > rightSet
 
readonly bool leftIsSimpleEnum
 
readonly bool rightIsSimpleEnum
 

Detailed Description

Definition at line 22 of file NaturallyJoinedTable.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Tables.NaturallyJoinedTable.NaturallyJoinedTable ( ITable  left,
ITable  right 
)
inline

Definition at line 31 of file NaturallyJoinedTable.cs.

32  : base(new[] {left, right}) {
33  leftRowCount = left.RowCount;
34  rightRowCount = right.RowCount;
35 
36  // Build lookup tables for the rows in the parent tables if necessary
37  // (usually it's not necessary).
38 
39  // If the left or right tables are simple enumerations, we can optimize
40  // our access procedure,
41  leftIsSimpleEnum = (left.GetEnumerator() is SimpleRowEnumerator);
42  rightIsSimpleEnum = (right.GetEnumerator() is SimpleRowEnumerator);
43 
44  leftSet = !leftIsSimpleEnum ? left.Select(x => x.RowId.RowNumber).ToList() : null;
45  rightSet = !rightIsSimpleEnum ? right.Select(x => x.RowId.RowNumber).ToList() : null;
46  }

Member Function Documentation

int Deveel.Data.Sql.Tables.NaturallyJoinedTable.GetLeftRowIndex ( int  rowIndex)
inlineprivate

Definition at line 55 of file NaturallyJoinedTable.cs.

55  {
56  if (leftIsSimpleEnum)
57  return rowIndex;
58 
59  return leftSet[rowIndex];
60  }
int Deveel.Data.Sql.Tables.NaturallyJoinedTable.GetRightRowIndex ( int  rowIndex)
inlineprivate

Definition at line 62 of file NaturallyJoinedTable.cs.

62  {
64  return rowIndex;
65 
66  return rightSet[rowIndex];
67  }
override IEnumerable<int> Deveel.Data.Sql.Tables.NaturallyJoinedTable.ResolveRowsForTable ( IEnumerable< int >  rowSet,
int  tableNum 
)
inlineprotectedvirtual

Implements Deveel.Data.Sql.Tables.JoinedTable.

Definition at line 69 of file NaturallyJoinedTable.cs.

69  {
70  var rowList = rowSet.ToList();
71  bool pickRightTable = (tableNum == 1);
72  for (int n = rowList.Count - 1; n >= 0; --n) {
73  int aa = rowList[n];
74  // Reverse map row index to parent domain
75  int parentRow;
76  if (pickRightTable) {
77  parentRow = GetRightRowIndex(aa % rightRowCount);
78  } else {
79  parentRow = GetLeftRowIndex(aa / rightRowCount);
80  }
81  rowList[n] = parentRow;
82  }
83 
84  return rowList.ToArray();
85  }

Member Data Documentation

readonly bool Deveel.Data.Sql.Tables.NaturallyJoinedTable.leftIsSimpleEnum
private

Definition at line 29 of file NaturallyJoinedTable.cs.

readonly int Deveel.Data.Sql.Tables.NaturallyJoinedTable.leftRowCount
private

Definition at line 24 of file NaturallyJoinedTable.cs.

readonly IList<int> Deveel.Data.Sql.Tables.NaturallyJoinedTable.leftSet
private

Definition at line 28 of file NaturallyJoinedTable.cs.

readonly bool Deveel.Data.Sql.Tables.NaturallyJoinedTable.rightIsSimpleEnum
private

Definition at line 29 of file NaturallyJoinedTable.cs.

readonly int Deveel.Data.Sql.Tables.NaturallyJoinedTable.rightRowCount
private

Definition at line 24 of file NaturallyJoinedTable.cs.

readonly IList<int> Deveel.Data.Sql.Tables.NaturallyJoinedTable.rightSet
private

Definition at line 28 of file NaturallyJoinedTable.cs.

Property Documentation

override int Deveel.Data.Sql.Tables.NaturallyJoinedTable.RowCount
get

Definition at line 48 of file NaturallyJoinedTable.cs.


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