public ReferenceTable(Table parent, ObjectName name) : base(parent) { tableInfo = new DataTableInfo(name); parent.TableInfo.CopyColumnsTo(tableInfo); tableInfo.IsReadOnly = true; }
internal ReferenceTable(Table table, DataTableInfo info) : base(table) { table_name = info.TableName; modifiedTableInfo = info; }
public TestTable CreateTable(DataTableInfo tableInfo) { var table = new TestTable(tableInfo); tables[tableInfo.TableName] = table; return(table); }
/// <summary> /// Adds a column map into this table. /// </summary> /// <param name="mapping">The array containing a map to the column in /// the parent table that we want the column number to reference.</param> /// <param name="aliases"></param> public void SetColumnMap(int[] mapping, ObjectName[] aliases) { reverse_column_map = new int[Parent.ColumnCount]; for (int i = 0; i < reverse_column_map.Length; ++i) { reverse_column_map[i] = -1; } column_map = mapping; this.aliases = aliases; DataTableInfo parentInfo = Parent.TableInfo; subsetTableInfo = new DataTableInfo(parentInfo.TableName); for (int i = 0; i < mapping.Length; ++i) { int map_to = mapping[i]; DataColumnInfo colInfo = Parent.GetColumnInfo(map_to).Clone(); colInfo.Name = aliases[i].Name; subsetTableInfo.AddColumn(colInfo); reverse_column_map[map_to] = i; } subsetTableInfo.IsReadOnly = true; }
public SubsetColumnTable(Table parent, int[] mapping, ObjectName[] aliases) : base(parent) { int[] reverseColumnMap = new int[Parent.TableInfo.ColumnCount]; for (int i = 0; i < reverseColumnMap.Length; ++i) { reverseColumnMap[i] = -1; } DataTableInfo parentInfo = Parent.TableInfo; subsetTableInfo = new SubsetTableInfo(parentInfo.Name); for (int i = 0; i < mapping.Length; ++i) { int mapTo = mapping[i]; DataColumnInfo colInfo = Parent.TableInfo[mapTo]; var newColumn = subsetTableInfo.NewColumn(aliases[i].Name, colInfo.DataType); newColumn.DefaultExpression = colInfo.DefaultExpression; newColumn.IsNullable = colInfo.IsNullable; subsetTableInfo.AddColumn(colInfo); reverseColumnMap[mapTo] = i; } subsetTableInfo.Setup(mapping, aliases); subsetTableInfo.IsReadOnly = true; }
/// <summary> /// Copies the object, excluding the columns and the constraints /// contained in it. /// </summary> /// <returns></returns> public DataTableInfo NoColumnClone() { DataTableInfo info = new DataTableInfo(tableName); info.tableTypeName = tableTypeName; return(info); }
public TableQueryInfo(IDatabaseConnection conn, DataTableInfo tableInfo, ObjectName tableName, ObjectName aliasedAs) { this.conn = conn; this.tableInfo = tableInfo; this.aliasedAs = aliasedAs; this.tableName = tableName; }
internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType dataType) { TableInfo = tableInfo; DataType = dataType; Name = name; IsNullable = true; }
internal ReferenceTable(Table table, ObjectName tname) : base(table) { table_name = tname; // Create a modified table info based on the parent info. modifiedTableInfo = table.TableInfo.Clone(tname); modifiedTableInfo.IsReadOnly = true; }
///<summary> ///</summary> ///<param name="crossRefTable"></param> ///<param name="inExpList"></param> ///<param name="columnNames"></param> ///<param name="context"></param> public FunctionTable(Table crossRefTable, Expression[] inExpList, string[] columnNames, IQueryContext context) : base(context.Connection.Database) { // Make sure we are synchronized over the class. lock (typeof(FunctionTable)) { uniqueId = UniqueKeySeq; ++UniqueKeySeq; } uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000; this.context = context; this.crossRefTable = crossRefTable; crResolver = crossRefTable.GetVariableResolver(); crResolver.SetId = 0; // Create a DataTableInfo object for this function table. funTableInfo = new DataTableInfo(FunctionTableName); expList = new Expression[inExpList.Length]; expInfo = new byte[inExpList.Length]; // Create a new DataColumnInfo for each expression, and work out if the // expression is simple or not. for (int i = 0; i < inExpList.Length; ++i) { Expression expr = inExpList[i]; // Examine the expression and determine if it is simple or not if (expr.IsConstant() && !expr.HasAggregateFunction(context)) { // If expression is a constant, solve it DataObject result = expr.Evaluate(null, null, context); expr = Expression.Constant(result); expList[i] = expr; expInfo[i] = 1; } else { // Otherwise must be dynamic expList[i] = expr; expInfo[i] = 0; } // Make the column info funTableInfo.AddColumn(columnNames[i], expr.ReturnType(crResolver, context)); } // Make sure the table info isn't changed from this point on. funTableInfo.IsReadOnly = true; // Function tables are the size of the referring table. row_count = crossRefTable.RowCount; // Set schemes to 'blind search'. BlankSelectableSchemes(1); }
internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType type) { if (name == null) throw new ArgumentNullException("name"); if (type == null) throw new ArgumentNullException("type"); this.tableInfo = tableInfo; this.name = name; this.type = type; }
///<summary> ///</summary> ///<param name="database"></param> ///<param name="name"></param> ///<param name="fields"></param> public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields) : base(database) { tableStorage = new List<DataObject[]>(); tableInfo = new DataTableInfo(new ObjectName(null, name)); foreach (DataColumnInfo field in fields) { tableInfo.AddColumn(field.Clone()); } tableInfo.IsReadOnly = true; }
private static int RequireColumnIndex(DataTableInfo tableInfo, string columnName) { var offset = tableInfo.FindColumnName(columnName); if (offset == -1) { throw new ArgumentException(String.Format("Table {0} has no column named {1}", tableInfo.Name, columnName)); } return(offset); }
///<summary> ///</summary> ///<param name="database"></param> ///<param name="name"></param> ///<param name="fields"></param> public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields) : base(database) { tableStorage = new List <DataObject[]>(); tableInfo = new DataTableInfo(new ObjectName(null, name)); foreach (DataColumnInfo field in fields) { tableInfo.AddColumn(field.Clone()); } tableInfo.IsReadOnly = true; }
internal void CopyColumnsTo(DataTableInfo tableInfo) { foreach (var column in columns) { var newColumn = new DataColumnInfo(tableInfo, column.Name, column.DataType) { DefaultExpression = column.DefaultExpression, IsNullable = column.IsNullable }; tableInfo.AddColumn(newColumn); } }
public DataTableInfo Clone(ObjectName newTableName) { DataTableInfo clone = new DataTableInfo(newTableName); clone.tableTypeName = (string)tableTypeName.Clone(); clone.columns = new List <DataColumnInfo>(); foreach (DataColumnInfo column in columns) { clone.columns.Add(column.Clone()); } return(clone); }
/// <summary> /// This is called when an index to a row needs to be removed from the /// SelectableScheme objects. /// </summary> /// <param name="rowNumber"></param> /// <remarks> /// This occurs when we have a modification log of row removals that haven't /// actually happened to old backed up scheme. /// </remarks> internal void RemoveRowToColumnSchemes(int rowNumber) { int col_count = ColumnCount; DataTableInfo tableInfo = TableInfo; for (int i = 0; i < col_count; ++i) { if (tableInfo[i].IsIndexableType) { SelectableScheme ss = GetRootColumnScheme(i); ss.Remove(rowNumber); } } }
/// <summary> /// This is called when a row is in the table, and the SelectableScheme /// objects for each column need to be notified of the rows existance, /// therefore build up the relational model for the columns. /// </summary> /// <param name="rowNumber"></param> internal void AddRowToColumnSchemes(int rowNumber) { int colCount = TableInfo.ColumnCount; DataTableInfo tableInfo = TableInfo; for (int i = 0; i < colCount; ++i) { if (tableInfo[i].DataType.IsIndexable) { SelectableScheme ss = GetRootColumnScheme(i); ss.Insert(rowNumber); } } }
internal DataColumnInfo(DataTableInfo tableInfo, string name, DataType type) { if (name == null) { throw new ArgumentNullException("name"); } if (type == null) { throw new ArgumentNullException("type"); } this.tableInfo = tableInfo; this.name = name; this.type = type; }
///<summary> ///</summary> ///<param name="database"></param> ///<param name="name"></param> ///<param name="fields"></param> public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields) : base(database) { tableStorage = new List<DataObject[]>(); tableInfo = new DataTableInfo(new ObjectName(name)); foreach (DataColumnInfo field in fields) { var newColumn = tableInfo.NewColumn(field.Name, field.DataType); newColumn.DefaultExpression = field.DefaultExpression; newColumn.IsNullable = field.IsNullable; tableInfo.AddColumn(newColumn); } tableInfo.IsReadOnly = true; }
/// <summary> /// Constructs the source. /// </summary> /// <param name="caseInsensitive"></param> /// <param name="tableQuery"></param> /// <param name="uniqueName"></param> /// <param name="givenName"></param> /// <param name="rootName"></param> public FromTableDirectSource(bool caseInsensitive, ITableQueryInfo tableQuery, string uniqueName, ObjectName givenName, ObjectName rootName) { this.uniqueName = uniqueName; dataTableInfo = tableQuery.TableInfo; RootTableName = rootName; if (givenName != null) { GivenTableName = givenName; } else { GivenTableName = rootName; } // Is the database case insensitive? this.caseInsensitive = caseInsensitive; this.tableQuery = tableQuery; }
///<summary> ///</summary> ///<param name="database"></param> ///<param name="name"></param> ///<param name="fields"></param> public TemporaryTable(IDatabase database, String name, DataColumnInfo[] fields) : base(database) { tableStorage = new List <DataObject[]>(); tableInfo = new DataTableInfo(new ObjectName(name)); foreach (DataColumnInfo field in fields) { var newColumn = tableInfo.NewColumn(field.Name, field.DataType); newColumn.DefaultExpression = field.DefaultExpression; newColumn.IsNullable = field.IsNullable; tableInfo.AddColumn(newColumn); } tableInfo.IsReadOnly = true; }
public ITableQueryInfo GetTableQueryInfo(ObjectName tableName, ObjectName givenName) { DataTableInfo tableInfo = GetTableInfo(tableName); // If the table is aliased, set a new DataTableInfo with the given name if (givenName != null) { var newTableInfo = new DataTableInfo(givenName.Clone()); for (int i = 0; i < tableInfo.ColumnCount; i++) { var columnInfo = tableInfo[i]; newTableInfo.AddColumn(columnInfo.Name, columnInfo.DataType, !columnInfo.IsNotNull); } newTableInfo.IsReadOnly = true; tableInfo = newTableInfo; } return(new TableQueryInfo(this, tableInfo, tableName, givenName)); }
/// <inheritdoc/> public override int FindFieldName(ObjectName v) { // Check this is the correct table first... ObjectName tableName = v.Parent; DataTableInfo tableInfo = TableInfo; if (tableName != null && tableName.Equals(TableName)) { // Look for the column name string colName = v.Name; int size = ColumnCount; for (int i = 0; i < size; ++i) { DataColumnInfo col = tableInfo[i]; if (col.Name.Equals(colName)) { return(i); } } } return(-1); }
/// <summary> /// Helper function for initializing the variables in the joined table. /// </summary> /// <param name="tables"></param> protected virtual void Init(Table[] tables) { int tableCount = tables.Length; referenceList = tables; int colCount = ColumnCount; columnScheme = new SelectableScheme[colCount]; vtTableInfo = new DataTableInfo(new ObjectName(null, "#VIRTUAL TABLE#")); // Generate look up tables for column_table and column_filter information columnTable = new int[colCount]; columnFilter = new int[colCount]; int index = 0; for (int i = 0; i < referenceList.Length; ++i) { Table curTable = referenceList[i]; DataTableInfo curTableInfo = curTable.TableInfo; int refColCount = curTable.ColumnCount; // For each column for (int n = 0; n < refColCount; ++n) { columnFilter[index] = n; columnTable[index] = i; ++index; // Add this column to the data table info of this table. vtTableInfo.AddColumn(curTableInfo[n].Clone()); } } vtTableInfo.IsReadOnly = true; }
protected virtual void Init(DataTableInfo[] tableInfos) { // Generate look up tables for column_table and column_filter information int colCount = 0; for (int i = 0; i < tableInfos.Length; i++) { colCount += tableInfos[i].ColumnCount; } columnTable = new int[colCount]; columnFilter = new int[colCount]; int index = 0; for (int i = 0; i < tableInfos.Length; ++i) { DataTableInfo curTableInfo = tableInfos[i]; int refColCount = curTableInfo.ColumnCount; // For each column for (int n = 0; n < refColCount; ++n) { columnFilter[index] = n; columnTable[index] = i; ++index; // Add this column to the data table info of this table. var sourceColumn = curTableInfo[n]; var newColumn = new DataColumnInfo(this, sourceColumn.Name, sourceColumn.DataType); newColumn.DefaultExpression = sourceColumn.DefaultExpression; newColumn.IsNullable = sourceColumn.IsNullable; AddColumn(newColumn); } } IsReadOnly = true; }
public void SetUp() { database = new TestDatabase(); var tableInfo = new DataTableInfo("APP", "person"); tableInfo.AddColumn("id", PrimitiveTypes.Numeric()); tableInfo.AddColumn("first_name", PrimitiveTypes.String()); tableInfo.AddColumn("last_name", PrimitiveTypes.String()); tableInfo.AddColumn("age", PrimitiveTypes.Numeric()); var table = database.CreateTable(tableInfo); long rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(0)); table.SetValue(1, rowIndex, new DataObject(PrimitiveTypes.String(), new StringObject("Antonello"))); table.SetValue(2, rowIndex, new DataObject(PrimitiveTypes.String(), new StringObject("Provenzano"))); table.SetValue(3, rowIndex, new DataObject(PrimitiveTypes.Numeric(), Number.FromInt32(32))); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(1)); table.SetValue(1, rowIndex, DataObject.String("Mart")); table.SetValue(2, rowIndex, DataObject.String("Roosmaa")); table.SetValue(3, rowIndex, DataObject.Number(28)); tableInfo = new DataTableInfo("APP", "lives"); tableInfo.AddColumn("person_id", PrimitiveTypes.Numeric()); tableInfo.AddColumn("city", PrimitiveTypes.String()); tableInfo.AddColumn("country", PrimitiveTypes.String()); table = database.CreateTable(tableInfo); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(0)); table.SetValue(1, rowIndex, DataObject.String("Oslo")); table.SetValue(2, rowIndex, DataObject.String("Norway")); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(1)); table.SetValue(1, rowIndex, DataObject.String("Tallinn")); table.SetValue(2, rowIndex, DataObject.String("Estonia")); tableInfo = new DataTableInfo("APP", "devices"); tableInfo.AddColumn("id", PrimitiveTypes.Numeric()); tableInfo.AddColumn("person_id", PrimitiveTypes.Numeric()); tableInfo.AddColumn("device_name", PrimitiveTypes.String()); tableInfo.AddColumn("os", PrimitiveTypes.String()); tableInfo.AddColumn("date", PrimitiveTypes.Date()); table = database.CreateTable(tableInfo); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(0)); table.SetValue(1, rowIndex, DataObject.Number(0)); table.SetValue(2, rowIndex, DataObject.String("Work Notebook")); table.SetValue(3, rowIndex, DataObject.String("Windows 8.1")); table.SetValue(4, rowIndex, DataObject.Now()); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(1)); table.SetValue(1, rowIndex, DataObject.Number(0)); table.SetValue(2, rowIndex, DataObject.String("Tablet")); table.SetValue(3, rowIndex, DataObject.String("Android 4.4")); table.SetValue(4, rowIndex, DataObject.Now()); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(2)); table.SetValue(1, rowIndex, DataObject.Number(0)); table.SetValue(2, rowIndex, DataObject.String("Other Notebook")); table.SetValue(3, rowIndex, DataObject.String("Ubuntu Linux")); table.SetValue(4, rowIndex, DataObject.Now()); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(3)); table.SetValue(1, rowIndex, DataObject.Number(1)); table.SetValue(2, rowIndex, DataObject.String("Mac Work Notebook")); table.SetValue(3, rowIndex, DataObject.String("Mac OS X")); table.SetValue(4, rowIndex, DataObject.Now()); rowIndex = table.NewRow(); table.SetValue(0, rowIndex, DataObject.Number(4)); table.SetValue(1, rowIndex, DataObject.Number(1)); table.SetValue(2, rowIndex, DataObject.String("Tablet")); table.SetValue(3, rowIndex, DataObject.String("Android 4.2")); table.SetValue(4, rowIndex, DataObject.Now()); }
public TestTable CreateTable(DataTableInfo tableInfo) { var table = new TestTable(tableInfo); tables[tableInfo.TableName] = table; return table; }
public ChildTableInfo(DataTableInfo parent) : base(parent.Name) { Parent = parent; }
public ITableQueryInfo GetTableQueryInfo(ObjectName tableName, ObjectName givenName) { DataTableInfo tableInfo = GetTableInfo(tableName); // If the table is aliased, set a new DataTableInfo with the given name if (givenName != null) { var newTableInfo = new DataTableInfo(givenName.Clone()); for (int i = 0; i < tableInfo.ColumnCount; i++) { var columnInfo = tableInfo[i]; newTableInfo.AddColumn(columnInfo.Name, columnInfo.DataType, !columnInfo.IsNotNull); } newTableInfo.IsReadOnly = true; tableInfo = newTableInfo; } return new TableQueryInfo(this, tableInfo, tableName, givenName); }
public TestTable(DataTableInfo tableInfo) { this.tableInfo = tableInfo; rows = new List<DataObject[]>(); }
/// <summary> /// Constructs this <see cref="TemporaryTable"/> based on the /// fields from the given <see cref="Table"/> object. /// </summary> /// <param name="name"></param> /// <param name="based_on"></param> public TemporaryTable(String name, Table based_on) : base(based_on.Database) { tableInfo = based_on.TableInfo.Clone(new ObjectName(null, name)); tableInfo.IsReadOnly = true; }
/// <summary> /// Constructs this <see cref="TemporaryTable"/> based on the given /// <see cref="Table"/> object. /// </summary> /// <param name="based_on"></param> public TemporaryTable(Table based_on) : base(based_on.Database) { tableInfo = based_on.TableInfo.Clone(); tableInfo.IsReadOnly = true; }
public DataTableInfo Clone(ObjectName newTableName) { DataTableInfo clone = new DataTableInfo(newTableName); clone.tableTypeName = (string)tableTypeName.Clone(); clone.columns = new List<DataColumnInfo>(); foreach (DataColumnInfo column in columns) { clone.columns.Add(column.Clone()); } return clone; }
///<summary> ///</summary> ///<param name="crossRefTable"></param> ///<param name="inExpList"></param> ///<param name="columnNames"></param> ///<param name="context"></param> public FunctionTable(Table crossRefTable, Expression[] inExpList, string[] columnNames, IQueryContext context) : base(context.Connection.Database) { // Make sure we are synchronized over the class. lock (typeof (FunctionTable)) { uniqueId = UniqueKeySeq; ++UniqueKeySeq; } uniqueId = (uniqueId & 0x0FFFFFFF) | 0x010000000; this.context = context; this.crossRefTable = crossRefTable; crResolver = crossRefTable.GetVariableResolver(); crResolver.SetId = 0; // Create a DataTableInfo object for this function table. funTableInfo = new DataTableInfo(FunctionTableName); expList = new Expression[inExpList.Length]; expInfo = new byte[inExpList.Length]; // Create a new DataColumnInfo for each expression, and work out if the // expression is simple or not. for (int i = 0; i < inExpList.Length; ++i) { Expression expr = inExpList[i]; // Examine the expression and determine if it is simple or not if (expr.IsConstant() && !expr.HasAggregateFunction(context)) { // If expression is a constant, solve it DataObject result = expr.Evaluate(null, null, context); expr = Expression.Constant(result); expList[i] = expr; expInfo[i] = 1; } else { // Otherwise must be dynamic expList[i] = expr; expInfo[i] = 0; } // Make the column info funTableInfo.AddColumn(columnNames[i], expr.ReturnType(crResolver, context)); } // Make sure the table info isn't changed from this point on. funTableInfo.IsReadOnly = true; // Function tables are the size of the referring table. row_count = crossRefTable.RowCount; // Set schemes to 'blind search'. BlankSelectableSchemes(1); }
private void CallInit(DataTableInfo[] tableInfos) { Init(tableInfos); }
public JoinedTableInfo(ObjectName name, DataTableInfo[] tableInfos) : base(name) { sourceInfos = tableInfos; CallInit(tableInfos); }
public TestTable(DataTableInfo tableInfo) { this.tableInfo = tableInfo; rows = new List <DataObject[]>(); }
/// <summary> /// Copies the object, excluding the columns and the constraints /// contained in it. /// </summary> /// <returns></returns> public DataTableInfo NoColumnClone() { DataTableInfo info = new DataTableInfo(tableName); info.tableTypeName = tableTypeName; return info; }