[Mono-devel-list] Re: build breakage and comments

Sureshkumar T tsureshkumar at novell.com
Wed Jun 15 06:35:40 EDT 2005


> 2. The new "internal DataRow Find (object [] keys, DataViewRowState 
> rowStateFilter)" in datarowcollection.cs, uses Table.FindIndex and if 
> not found creates a new index. So if there is no suitable index a new 
> one will be created on each call, what is very inneficient. The better 
> practice would be calling table.GetIndex. In addition, the "public 
> DataRow Find (object[] keys)" may simply forward to the new more generic 
> method.
> 
> What do you think?
> 

I could not use GetIndex simply because It introduces 6 regressions. 

As I already pointed out to you, we are not updating the indexes
whenever there is a change in Original or Current. Somehow, the current
design keeps valid index for Current records :-). But for an index of
original rows, it causes a bug. Simply change FindIndex in Rows.Find
(object [], DataViewRowState) to GetIndex and run test suite. I have
identified what is the problem. If we update the indexes and immediately
we change Current/Original, the problem won't occur and currently there
is no simple solution rather rebuild the whole index. So, I have to do
something like this

[SNIP]
Index: System.Data/DataRow.cs
===================================================================
--- System.Data/DataRow.cs      (revision 46009)
+++ System.Data/DataRow.cs      (working copy)
@@ -1443,6 +1443,13 @@
                                else if (row.Original == row.Current) {
                                        row.Original =
row.Table.RecordCache.NewRecord();
                                        row.Table.RecordCache.CopyRecord
(row.Table, row.Current, row.Original);
+                                       // here the target table's
original index has to be updated
+                                       // because, it is currently
pointing to a location which is no
+                                       // longer valid and used by
OriginalRows.
+                                       foreach (Index i in
row.Table.Indexes) {
+                                               if (i.Key.RowStateFilter
== DataViewRowState.OriginalRows)
+                                                       i.Reset ();
+                                       }
                                }
[/SNIP]

which I don't like. If we write an API like index.Update (old value,
current value) and if we change all the code like Current = x, Original
=x  into like old = Current, Current = x, index.Update (old, x),
Table.GetIndex will be valid all the times.

Thanks
Suresh.



More information about the Mono-devel-list mailing list