Hi,
Have you tried chunking/paging the rowset? The javadoc says that
size() also returns the number of rows in the current page but maybe
this is not what you are looking for.
Kuassi http://db360.blogspot.com/2006/09/manipulating-tabular-data-using-jdbc_03.html
> Hello,
>
[quoted text clipped - 15 lines]
>
> Thanks
Carl Leiby - 05 Mar 2007 13:59 GMT
I haven't done any paging yet. It's a Swing app so I essentially want
the whole filtered subset. The problem is that the JTable uses the
getRowCount function in my model to decide how many rows to draw and
in turn how to render the scrollbar nect to the table. I'd like those
two to to accurately reflect how many rows are really available for
the propper user experience. Short of doing an absolute(1) and next()
to count the rows there doesn't seem to be a way to tell how many rows
are in the filtered subset. I've written this code to loop through
the records. Since they are all already in memory it runs fairly
quickly. I just don't like how much code that ends up executing.
Each call to next() results in a call to to my filter Predicate for
each row until the next suitable row is found. It seems like an
immense overhead.
On Mar 4, 2:23 pm, "kuassi.men...@gmail.com" <kuassi.men...@gmail.com>
wrote:
> Hi,
>
[quoted text clipped - 23 lines]
>
> > Thanks
This has also been frustrating me. What I have discovered is that the
way the FilteredRowSet works is that once you have declared it and
applied your filter the actual filtered data has still not been
derived since working out the filtered set actually involves cycling
through all the data and applying your evaluate function defined by
your predicate. So for example lets say you ran a query and populated
your FRS and the applied a filter. I have written a basic predicate
that looks for exact matching values on columns called search
Search pred = new Search("gender",gender);
frs.populate(rs);
frs_ret.setFilter(pred);
At this point the Filter has not actually been applied so it does not
actually know how big it is. It is only applied when you call the
frs.next() function. And at this point it is only applied with one
evaluate function at a time i.e. not over the whole set
In this case it calls the evaluate function that checks to see if your
criteria applies and I assume it skips to the next one if it doesnt
apply. This is how it appears to work. So unfortunately it does look
like in order to work out the size of the filtered rowset you would
need to loop until the resultset is deemed to be finished. This
shoulnt post too much of a problem on a small resultset.
public int Size()
{
cnt = 0;
frs.beforeFirst();
while (frs.next())
{
cnt ++;
}
return cnt;
frs.beforeFirst();
}
This does seem rather inefficient but at some point the filter needs
to actually determine which rows apply and need to apply the tests
from your predicate. Perhaps there is a more elegant method. These are
my finding from running some tests on the FiltereRowSet and playing
with different predicates