Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why not just use a sorted collection as your table model instead of a list. TreeMap seems logical since your entries are all ordered. If you also need fast access by row or any other column, you can simply add a secondary map. Basically you are doing what database indexes do.</p> <p>I thought for some reason that you could use the map.headSet(key) and find the kth entry -- this won't work. You need to be able to get from table row -> EventID (or close to it).</p> <p>if you use a model like this</p> <pre><code>Map&lt;EventID, Event&gt; model = new TreeSet&lt;EventID, Event&gt;(); </code></pre> <p>Conceptually your getValueAt() looks like this:</p> <pre><code>getValueAt(int row, column) { eventID = getSortPosition(row); Event e = model.headSet(eventID).next(); return getColumn(e, column); } </code></pre> <p>The key is being able to efficiently maintain a map from sort index -> key (an inverse map). This is non-trival since inserting a new event at the very top affects the absolute order of all those below it. It seems like there should be a CS answer here, but it escapes me.</p> <p>Here is the most basic implementation: - on every insert, you update your map, then materialize your sorted map.</p> <pre><code>ArrayList&lt;Event&gt; orderedEvents = new ArrayList&lt;Event&gt;(); public void insert(Event event) { model.put(event.getID(), event); // update the model.headSet().addAll(orderedEvents); } </code></pre> <p>Your getValueAt() would be pretty simple.</p> <pre><code>getValueAt(int row, column) {w); Event e = orderedEvents.get(row); return getColumn(e, column); } </code></pre> <ul> <li>this makes insertions O(n) instead of O(n log n) (still not great)</li> </ul> <p><strong>I think you should reconsider your UI design</strong> If you are having users browse a 100K row table, adding a search filter will solve your performance problem:</p> <ul> <li>No user will EVER read 100k rows</li> <li>If it is meaningfull for your users to search by eventID then this works great, when the users selects the eventID, you do: sortedMap.headSet( searchFilterID ) // take first 200 put them into your table</li> <li>If it is meaningfull for users to search by time, then make a map from and do the same. </li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload