Effacer les filtres
Effacer les filtres

table row key implementation

3 vues (au cours des 30 derniers jours)
Andrew J
Andrew J le 3 Déc 2019
Commenté : Andrew J le 8 Jan 2020
Does anyone know how the MatLab table 'RowKey' mechanism is implemented ?
I would expect something like this to be done using a tree structure internally - which then indirects into the backing data structure - so that sorting would be maintaned efficiently as the table grows - but I am seeing some strange behaviour which makes me question this.
If I create a tables - approx 250,000 rows - and use tbl.Properties.RowKeys to set unique keys - and then do a filter/sort operation on that table, like this:
tFinal1 = tInitial(MyRowKeys,:)
this takes a very long time, but if instead I do:
[~, idx] = ismember(MyRowKeys, tInitial.Properties.RowNames);
tFinal2 = tInitial(idx,:)
this is several orders of magnitude faster - so much so that the first version is unworkable.
It looks to me like one is o(n.log(n)) and the other is o(n squared) - or there is a very different element cmp operation.
Is there any documentation on how this works internally ?
A

Réponse acceptée

Eric Sofen
Eric Sofen le 13 Déc 2019
Hi Andrew,
I assume you mean t.Properties.RowNames throughout rather than "RowKeys." Yes, that's a large difference in performance to use ismember rather than named row subscripting when MyRowKeys is large. We are aware of some of the performance issues in named subscripting in tables and have been exploring ways to improve this performance. Thank you for illustrating this particular case. For now, you're best off using ismember() or maybe using containers.Map to create your own map between keys and indices.
  1 commentaire
Andrew J
Andrew J le 8 Jan 2020
thank you - that is the conclusion that I have come to also !
Regards,
A

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by