2

I wanted to ask for a clarification about the use of RowFilter and its effects on performances. I implemented a filter through the method include(Entry) that for every row simply checks if its correspondent value in the model has a boolean flag set: if so, returns true, else false.

Now, the JTable I have can be pretty big (1000000+ rows), and I wasn't sure if this simple filtering, applied to such a big input set, could be costly.

How does the mapping between filtered rows and underlying data work exactly? I mean, does it store any extra data or it just draws the rows that match the filter "on the fly"??

Thank you very much for the clarifications.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
mdm
  • 3,928
  • 3
  • 27
  • 43
  • 1
    a) have a look at the source of DefaultRowSorter if you are interested in the details of its implementation b) write a short test or use a profiler to measure its performance impact – kleopatra Jan 30 '12 at 17:30
  • 1
    *"I wasn't sure if this simple filtering, .. could be costly."* What happened when you tried it? It should only take 30-40 lines of code to test. I can tell you there is no noticeable lag when filtering the text of title/artist for over 11,000 tracks in a play list. – Andrew Thompson Jan 30 '12 at 17:30
  • from a usability aspect, such a big table is horrible, why/who/how would anybody browse those many rows? – kleopatra Jan 30 '12 at 17:32
  • @kleopatra I know that such a huge table is a mess from the point of view of usability, but in my case I have an external component that really the user uses for the navigation. JTable is only a "dive into" the data that most often than not is not even open. That's why no "more sophisticated" approaches were developed. – mdm Jan 31 '12 at 08:56

2 Answers2

3

no component in any of programing languages aren't designated to displaying too largiest matrix of data on the screen, then you have two choises

  1. faster way is let's this job for SQL engine, that designated for searching and filtering rows in hugest Database table

  2. slower way is hold these data in HashMap and there apply Comparator, and JTable would be display only result from this Comparator

mKorbel
  • 109,525
  • 20
  • 134
  • 319
3

Expanding on @mKorbel's second point, a TableModel for a very large data set may contain a List<Record>, as suggested here. The list may be sorted using a suitable Comparator and dynamically partitioned using the subList() method. At any one time, the corresponding JTable can only see one such partition, and separate controls will be required to change partitions.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045