D11452: sanitizer: Improve device listing

Michael Heidelbach noreply at phabricator.kde.org
Mon Apr 9 16:53:59 UTC 2018


michaelh marked 4 inline comments as done.
michaelh added inline comments.

INLINE COMMENTS

> bruns wrote in databasesanitizer.cpp:159
> I can not come up with a reason to use a MultiHash here in the first place - all that is needed is the deviceId and the file count per device.
> 
> You can use a QMap<DeviceId, Count> here, and use
> 
>   usedDevices[info.deviceId] += 1;
> 
> (operator[] default-constructs the ValueType, which for e.g. `int` is guranteed by Qt to be 0).
> 
> This reduces the effort for counting the items per device from //(D + 3) * F// to //F//.
> (D: number of devices, F: number of files).
> Currently you walk the infos list once to create the MultiHash, and then walk the Multihash once for `uniqueKeys()`, and once for each device when calling `usedDevices.value()`. Cumulated effort for `.count()` is //F//.
> 
> In your case, this would reduce the time for counting by a factor of 14. You also save the memory for creating a temporary MultiHash with ~20000 items.

Thanks!

> bruns wrote in fsutils.cpp:111
> The question is if this really belongs in the library then.
> 
> IMHO the whole `printDevices()` function should be moved into baloodb.cpp, The DatabaseSanitizer should export either `createList` or a function returning `QVector<DeviceId, Count>`. Going from the DeviceId to the DeviceInfo should happen in baloodb.

I agree completely and followed your suggestion. Currently I'm stuck, though. 
Using Solid to obtain the  accessibilty info of volumes and network shares, it seems only `Solid::Block` provides the `major` and `minor` properties needed to map to `deviceId`. But network shares don't implement Block.  :-/ 
Any ideas? Maybe that is the reason why BalooEngine isn't using Solid?

REPOSITORY
  R293 Baloo

REVISION DETAIL
  https://phabricator.kde.org/D11452

To: michaelh, #baloo, #frameworks
Cc: bruns, smithjd, ashaposhnikov, michaelh, astippich, spoorun, ngraham, alexeymin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180409/e65e37c5/attachment.html>


More information about the Kde-frameworks-devel mailing list