public FunctionTable AsGroup() { // TODO: create a new table ... wholeTableAsGroup = true; wholeTableGroupSize = ReferenceTable.RowCount; // Set up 'whole_table_group' to the list of all rows in the reference // table. var en = ReferenceTable.GetEnumerator(); wholeTableIsSimpleEnum = en is SimpleRowEnumerator; if (!wholeTableIsSimpleEnum) { wholeTableGroup = new List <int>(ReferenceTable.RowCount); while (en.MoveNext()) { wholeTableGroup.Add(en.Current.RowId.RowNumber); } } // Set up a group resolver for this method. groupResolver = new TableGroupResolver(this); return(this); }
// ------ Public methods ------ ///<summary> /// Sets the whole reference table as a single group. ///</summary> public void SetWholeTableAsGroup() { wholeTableAsGroup = true; wholeTableGroupSize = ReferenceTable.RowCount; // Set up 'whole_table_group' to the list of all rows in the reference // table. IEnumerator <long> en = ReferenceTable.GetRowEnumerator(); wholeTableIsSimpleEnum = en is SimpleRowEnumerator; if (!wholeTableIsSimpleEnum) { wholeTableGroup = new List <long>((int)ReferenceTable.RowCount); while (en.MoveNext()) { wholeTableGroup.Add(en.Current); } } // Set up a group resolver for this method. groupResolver = new TableGroupResolver(this); }
/// <summary> /// Creates a grouping matrix for the given columns. /// </summary> /// <param name="columns"></param> /// <remarks> /// The grouping matrix is arranged so that each row of the refering /// table that is in the group is given a number that refers to the top /// group entry in the group list. The group list is a linked integer /// list that chains through each row item in the list. /// </remarks> public void CreateGroupMatrix(ObjectName[] columns) { // If we have zero rows, then don't bother creating the matrix. if (RowCount <= 0 || columns.Length <= 0) { return; } Table rootTable = ReferenceTable; long rowCount = rootTable.RowCount; int[] colLookup = new int[columns.Length]; for (int i = columns.Length - 1; i >= 0; --i) { colLookup[i] = rootTable.FindFieldName(columns[i]); } IList <long> rowList = rootTable.OrdereddRows(colLookup); // 'row_list' now contains rows in this table sorted by the columns to // group by. // This algorithm will generate two lists. The group_lookup list maps // from rows in this table to the group number the row belongs in. The // group number can be used as an index to the 'group_links' list that // contains consequtive links to each row in the group until -1 is reached // indicating the end of the group; groupLookup = new List <long>((int)rowCount); groupLinks = new List <long>((int)rowCount); int current_group = 0; long previous_row = -1; for (int i = 0; i < rowCount; ++i) { long rowIndex = rowList[i]; if (previous_row != -1) { bool equal = true; // Compare cell in column in this row with previous row. for (int n = 0; n < colLookup.Length && equal; ++n) { DataObject c1 = rootTable.GetValue(colLookup[n], rowIndex); DataObject c2 = rootTable.GetValue(colLookup[n], previous_row); equal = (c1.CompareTo(c2) == 0); } if (!equal) { // If end of group, set bit 15 groupLinks.Add(previous_row | 0x040000000); current_group = groupLinks.Count; } else { groupLinks.Add(previous_row); } } // groupLookup.Insert(row_index, current_group); PlaceAt(groupLookup, rowIndex, current_group); previous_row = rowIndex; } // Add the final row. groupLinks.Add(previous_row | 0x040000000); // Set up a group resolver for this method. groupResolver = new TableGroupResolver(this); }
public GroupVariableResolver(TableGroupResolver groupResolver, int rowIndex) { this.groupResolver = groupResolver; this.rowIndex = rowIndex; }
public GroupVariableResolver(TableGroupResolver groupResolver) : this(groupResolver, -1) { }
public FunctionTable CreateGroupMatrix(ObjectName[] columns) { // If we have zero rows, then don't bother creating the matrix. if (RowCount <= 0 || columns.Length <= 0) return this; var rootTable = ReferenceTable; int rowCount = rootTable.RowCount; int[] colLookup = new int[columns.Length]; for (int i = columns.Length - 1; i >= 0; --i) { colLookup[i] = rootTable.IndexOfColumn(columns[i]); } var rowList = rootTable.OrderRowsByColumns(colLookup).ToList(); // 'row_list' now contains rows in this table sorted by the columns to // group by. // This algorithm will generate two lists. The group_lookup list maps // from rows in this table to the group number the row belongs in. The // group number can be used as an index to the 'group_links' list that // contains consequtive links to each row in the group until -1 is reached // indicating the end of the group; groupLookup = new List<int>(rowCount); groupLinks = new List<int>(rowCount); int currentGroup = 0; int previousRow = -1; for (int i = 0; i < rowCount; i++) { var rowIndex = rowList[i]; if (previousRow != -1) { bool equal = true; // Compare cell in column in this row with previous row. for (int n = 0; n < colLookup.Length && equal; ++n) { var c1 = rootTable.GetValue(rowIndex, colLookup[n]); var c2 = rootTable.GetValue(previousRow, colLookup[n]); equal = (c1.CompareTo(c2) == 0); } if (!equal) { // If end of group, set bit 15 groupLinks.Add(previousRow | 0x040000000); currentGroup = groupLinks.Count; } else { groupLinks.Add(previousRow); } } // groupLookup.Insert(row_index, current_group); PlaceAt(groupLookup, rowIndex, currentGroup); previousRow = rowIndex; } // Add the final row. groupLinks.Add(previousRow | 0x040000000); // Set up a group resolver for this method. groupResolver = new TableGroupResolver(this); return this; }
public FunctionTable AsGroup() { // TODO: create a new table ... wholeTableAsGroup = true; wholeTableGroupSize = ReferenceTable.RowCount; // Set up 'whole_table_group' to the list of all rows in the reference // table. var en = ReferenceTable.GetEnumerator(); wholeTableIsSimpleEnum = en is SimpleRowEnumerator; if (!wholeTableIsSimpleEnum) { wholeTableGroup = new List<int>(ReferenceTable.RowCount); while (en.MoveNext()) { wholeTableGroup.Add(en.Current.RowId.RowNumber); } } // Set up a group resolver for this method. groupResolver = new TableGroupResolver(this); return this; }
// ------ Public methods ------ ///<summary> /// Sets the whole reference table as a single group. ///</summary> public void SetWholeTableAsGroup() { wholeTableAsGroup = true; wholeTableGroupSize = ReferenceTable.RowCount; // Set up 'whole_table_group' to the list of all rows in the reference // table. IEnumerator<long> en = ReferenceTable.GetRowEnumerator(); wholeTableIsSimpleEnum = en is SimpleRowEnumerator; if (!wholeTableIsSimpleEnum) { wholeTableGroup = new List<long>((int)ReferenceTable.RowCount); while (en.MoveNext()) { wholeTableGroup.Add(en.Current); } } // Set up a group resolver for this method. groupResolver = new TableGroupResolver(this); }