/// <summary> /// Returns an object that contains fully resolved, one level only information /// about the <see cref="DataTable"/> and the row indices of the data in this table. /// </summary> /// <param name="info"></param> /// <param name="rowSet"></param> /// <remarks> /// This information can be used to construct a new <see cref="VirtualTable"/>. We /// need to supply an empty <see cref="RawTableInformation"/> object. /// </remarks> /// <returns></returns> private RawTableInformation ResolveToRawTable(RawTableInformation info, IList <long> rowSet) { if (this is IRootTable) { info.Add((IRootTable)this, CalculateRowReferenceList()); } else { for (int i = 0; i < referenceList.Length; ++i) { List <long> newRowSet = new List <long>(rowSet); // Resolve the rows into the parents indices. ResolveAllRowsForTableAt(newRowSet, i); Table table = referenceList[i]; if (table is IRootTable) { info.Add((IRootTable)table, newRowSet); } else { ((JoinedTable)table).ResolveToRawTable(info, newRowSet); } } } return(info); }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { List <long> allList = new List <long>(); long size = RowCount; for (int i = 0; i < size; ++i) { allList.Add(i); } return(ResolveToRawTable(info, allList)); }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { List <long> rowSet = new List <long>(); IEnumerator <long> e = GetRowEnumerator(); while (e.MoveNext()) { rowSet.Add(e.Current); } info.Add(this, rowSet); return(info); }
public OuterTable(Table inputTable) { RawTableInformation baseTable = inputTable.ResolveToRawTable(new RawTableInformation()); Table[] tables = baseTable.GetTables(); IList <long>[] rows = baseTable.GetRows(); outerRows = new IList <long> [rows.Length]; // Set up the VirtualTable with this base table information, Init(tables); Set(tables, rows); }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { Console.Error.WriteLine("Efficiency Warning in DataTable.ResolveToRawTable."); List <long> rowSet = new List <long>(); IEnumerator <long> e = GetRowEnumerator(); while (e.MoveNext()) { rowSet.Add(e.Current); } info.Add(this, rowSet); return(info); }
/// <summary> /// Merges the given table in with this table. /// </summary> /// <param name="outsideTable"></param> public void MergeIn(Table outsideTable) { RawTableInformation rawTableInfo = outsideTable.ResolveToRawTable(new RawTableInformation()); // Get the base information, Table[] baseTables = ReferenceTables; IList <long>[] baseRows = ReferenceRows; // The tables and rows being merged in. Table[] tables = rawTableInfo.GetTables(); IList <long>[] rows = rawTableInfo.GetRows(); // The number of rows being merged in. outerRowCount = rows[0].Count; for (int i = 0; i < baseTables.Length; ++i) { Table btable = baseTables[i]; int index = -1; for (int n = 0; n < tables.Length && index == -1; ++n) { if (btable == tables[n]) { index = n; } } // If the table wasn't found, then set 'NULL' to this base_table if (index == -1) { outerRows[i] = null; } else { List <long> list = new List <long>(outerRowCount); outerRows[i] = list; // Merge in the rows from the input table, IList <long> toMerge = rows[index]; if (toMerge.Count != outerRowCount) { throw new ApplicationException("Wrong size for rows being merged in."); } list.AddRange(toMerge); } } }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { throw new ApplicationException("Tricky to implement this method!"); // ( for a SubsetColumnTable that is ) }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { throw new ApplicationException("Tricky to implement this method!"); // ( for a SubsetColumnTable that is ) }
internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { return(Parent.ResolveToRawTable(info)); }
internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { List<long> allList = new List<long>(); long size = RowCount; for (int i = 0; i < size; ++i) { allList.Add(i); } return ResolveToRawTable(info, allList); }
private RawTableInformation ResolveToRawTable(RawTableInformation info, IList<long> rowSet) { if (this is IRootTable) { info.Add((IRootTable)this, CalculateRowReferenceList()); } else { for (int i = 0; i < referenceList.Length; ++i) { List<long> newRowSet = new List<long>(rowSet); // Resolve the rows into the parents indices. ResolveAllRowsForTableAt(newRowSet, i); Table table = referenceList[i]; if (table is IRootTable) { info.Add((IRootTable)table, newRowSet); } else { ((JoinedTable)table).ResolveToRawTable(info, newRowSet); } } } return info; }
internal abstract RawTableInformation ResolveToRawTable(RawTableInformation info);
public void Union(RawTableInformation info) { // Number of Table 'columns' int colCount = rawInfo.Count; // Get the sorted RawTableElement[] from each raw table information object. RawTableElement[] merge1 = GetSortedElements(); RawTableElement[] merge2 = info.GetSortedElements(); // Validates that both tables being merges are of identical type. int size1 = -1; int size2 = -1; // First check number of tables in each merge is correct. if (merge1.Length != merge2.Length) throw new ApplicationException("Incorrect format in table union"); // Check each table in the merge1 set has identical length row_sets for (int i = 0; i < merge1.Length; ++i) { if (size1 == -1) { size1 = merge1[i].RowSet.Count; } else { if (size1 != merge1[i].RowSet.Count) { throw new ApplicationException("Incorrect format in table union"); } } } // Check each table in the merge2 set has identical length row_sets for (int i = 0; i < merge2.Length; ++i) { // Check the tables in merge2 are identical to the tables in merge1 // (Checks the names match, and the validColumns filters are identical // see DataTableBase.TypeEquals method). if (!merge2[i].Table.Equals(merge1[i].Table)) { throw new ApplicationException("Incorrect format in table union"); } if (size2 == -1) { size2 = merge2[i].RowSet.Count; } else { if (size2 != merge2[i].RowSet.Count) { throw new ApplicationException("Incorrect format in table union"); } } } // If size1 or size2 are -1 then we have a corrupt table. (It will be // 0 for an empty table). if (size1 == -1 || size2 == -1) throw new ApplicationException("Incorrect format in table union"); // We don't need information in 'raw_info' vector anymore so clear it. // This may help garbage collection. rawInfo.Clear(); // Merge the two together into a new list of RawRowElement[] int mergeSize = size1 + size2; var elems = new RawRowElement[mergeSize]; int elemsIndex = 0; for (int i = 0; i < size1; ++i) { var e = new RawRowElement(); e.RowVals = new long[colCount]; for (int n = 0; n < colCount; ++n) { e.RowVals[n] = merge1[n].RowSet[i]; } elems[elemsIndex] = e; ++elemsIndex; } for (int i = 0; i < size2; ++i) { var e = new RawRowElement(); e.RowVals = new long[colCount]; for (int n = 0; n < colCount; ++n) { e.RowVals[n] = merge2[n].RowSet[i]; } elems[elemsIndex] = e; ++elemsIndex; } // Now sort the row elements into order. //TODO: SortUtil.QuickSort(elems); Array.Sort(elems); // Set up the 'raw_info' vector with the new RawTableElement[] removing // any duplicate rows. for (int i = 0; i < colCount; ++i) { RawTableElement e = merge1[i]; e.RowSet.Clear(); } RawRowElement previous = null; RawRowElement current = null; for (int n = 0; n < mergeSize; ++n) { current = elems[n]; // Check that the current element in the set is not a duplicate of the // previous. if (previous == null || previous.CompareTo(current) != 0) { for (int i = 0; i < colCount; ++i) { merge1[i].RowSet.Add(current.RowVals[i]); } previous = current; } } for (int i = 0; i < colCount; ++i) { rawInfo.Add(merge1[i]); } }
public void Union(RawTableInformation info) { // Number of Table 'columns' int colCount = rawInfo.Count; // Get the sorted RawTableElement[] from each raw table information object. RawTableElement[] merge1 = GetSortedElements(); RawTableElement[] merge2 = info.GetSortedElements(); // Validates that both tables being merges are of identical type. int size1 = -1; int size2 = -1; // First check number of tables in each merge is correct. if (merge1.Length != merge2.Length) { throw new ApplicationException("Incorrect format in table union"); } // Check each table in the merge1 set has identical length row_sets for (int i = 0; i < merge1.Length; ++i) { if (size1 == -1) { size1 = merge1[i].RowSet.Count; } else { if (size1 != merge1[i].RowSet.Count) { throw new ApplicationException("Incorrect format in table union"); } } } // Check each table in the merge2 set has identical length row_sets for (int i = 0; i < merge2.Length; ++i) { // Check the tables in merge2 are identical to the tables in merge1 // (Checks the names match, and the validColumns filters are identical // see DataTableBase.TypeEquals method). if (!merge2[i].Table.Equals(merge1[i].Table)) { throw new ApplicationException("Incorrect format in table union"); } if (size2 == -1) { size2 = merge2[i].RowSet.Count; } else { if (size2 != merge2[i].RowSet.Count) { throw new ApplicationException("Incorrect format in table union"); } } } // If size1 or size2 are -1 then we have a corrupt table. (It will be // 0 for an empty table). if (size1 == -1 || size2 == -1) { throw new ApplicationException("Incorrect format in table union"); } // We don't need information in 'raw_info' vector anymore so clear it. // This may help garbage collection. rawInfo.Clear(); // Merge the two together into a new list of RawRowElement[] int mergeSize = size1 + size2; var elems = new RawRowElement[mergeSize]; int elemsIndex = 0; for (int i = 0; i < size1; ++i) { var e = new RawRowElement(); e.RowVals = new long[colCount]; for (int n = 0; n < colCount; ++n) { e.RowVals[n] = merge1[n].RowSet[i]; } elems[elemsIndex] = e; ++elemsIndex; } for (int i = 0; i < size2; ++i) { var e = new RawRowElement(); e.RowVals = new long[colCount]; for (int n = 0; n < colCount; ++n) { e.RowVals[n] = merge2[n].RowSet[i]; } elems[elemsIndex] = e; ++elemsIndex; } // Now sort the row elements into order. //TODO: SortUtil.QuickSort(elems); Array.Sort(elems); // Set up the 'raw_info' vector with the new RawTableElement[] removing // any duplicate rows. for (int i = 0; i < colCount; ++i) { RawTableElement e = merge1[i]; e.RowSet.Clear(); } RawRowElement previous = null; RawRowElement current = null; for (int n = 0; n < mergeSize; ++n) { current = elems[n]; // Check that the current element in the set is not a duplicate of the // previous. if (previous == null || previous.CompareTo(current) != 0) { for (int i = 0; i < colCount; ++i) { merge1[i].RowSet.Add(current.RowVals[i]); } previous = current; } } for (int i = 0; i < colCount; ++i) { rawInfo.Add(merge1[i]); } }
internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { return Parent.ResolveToRawTable(info); }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { List<long> rowSet = new List<long>(); IEnumerator<long> e = GetRowEnumerator(); while (e.MoveNext()) { rowSet.Add(e.Current); } info.Add(this, rowSet); return info; }
/// <inheritdoc/> internal override RawTableInformation ResolveToRawTable(RawTableInformation info) { Console.Error.WriteLine("Efficiency Warning in DataTable.ResolveToRawTable."); List<long> rowSet = new List<long>(); IEnumerator<long> e = GetRowEnumerator(); while (e.MoveNext()) { rowSet.Add(e.Current); } info.Add(this, rowSet); return info; }
internal abstract RawTableInformation ResolveToRawTable(RawTableInformation info);