-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TrackRef = Track Location + Track ID #901
Conversation
I think I have understand what you aim, even if the new TrackRef is not used. ... but IMHO for the additional self documentation we introduce a new degree of complexity, another Object type other developers have to learn. Always calculating and storing the canonical path, might be an overhead that we don't need for all use-cases of TrackRef. I would prefer a solution that caches the canonical path only on demand. |
}; | ||
|
||
inline | ||
bool operator==(const TrackRef& lhs, const TrackRef& rhs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a candidate for missus since it might fail even if we reference the same track.
I would prefer to introduce a named function for comparing.
Like isRefferencingTheSameTrack() or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree. This is the canonical implementation of the equality operator
for a simple value object, member by member.
If on the other hand the class name of TrackRef is misleading than we should
instead choose a different one.
On 03/04/2016 04:02 PM, Daniel Schürmann wrote:
In src/track/trackref.h
#901 (comment):
- }
- bool isValid() const {
return hasId() || hasCanonicalLocation();
- }
+private:
- bool verifyConsistency() const;
- QString m_location;
- QString m_canonicalLocation;
- TrackId m_id;
+};
+inline
+bool operator==(const TrackRef& lhs, const TrackRef& rhs) {This is a candidate for missus since it might fail even if we reference
the same track.
I would prefer to introduce a named function for comparing.
Like isRefferencingTheSameTrack() or similar.—
Reply to this email directly or view it on GitHub
https://github.com/mixxxdj/mixxx/pull/901/files#r55039820.
...because construction from QFileInfo is costly and should be used consciously.
TrackRef is a new class, but it encapsulates a separate aspect of tracks I don't think that we should introduce an additional layer of caching.
On 03/04/2016 04:00 PM, Daniel Schürmann wrote:
|
It looks like we have a different view on this PR. Maybe it is because the The object itself, locks nice and you are right in separating different For me, the main issue we have to solve is a concurrent file access by two As I understand the way to solve it, is a track cache that tracks tracks by The canonical path is cached in the Qfileinfo class which is part of Will this approach work, or do I miss something? Which use case do you have in mind? I don't think that we should introduce an additional layer of caching.
On 03/04/2016 04:00 PM, Daniel Schürmann wrote:
— |
We must not instantiate two TrackInfoObjects for the same file! Otherwise The TrackCache will create and hand out managed pointers to tracks, both Maybe we can delay the calculation of the canonical path until it is I thought we could pull this PR out of the TrackCache stuff, because On 03/05/2016 05:58 PM, Daniel Schürmann wrote:
|
Delaying the calculation of the canonical file path was a good idea! That But as I already mentioned, the class TrackRef is unaffected. On 03/05/2016 07:27 PM, Uwe Klotz wrote:
|
I am starting to understand your approach.
This is a true requirement from your point of view. The underlying root requirement is: Even if we have only a single track object there is no guarantee. But the advantage of your approach is that it allows us to set-up locking mechanism quite easy. Currently a TrackInfo if build around the unique database ID. If we now prevent Mixxx from instantiating a TrackInfo object from a different database ID of a file that is only referenced by an other Track, it will change a lot of the meaning of a track info object. For example in SetlogFeature::slotJoinWithPrevious the TrackInfo object is only required to set the played counter, which has nothing to do with the track file on the HDD. This is the source of my Objections: If we do the deduplicate it at the Track level, we will have problems to graceful handle duplicates, which we will have in some legacy databases. Of cause, duplicates are not desired, but they exists and we need keep a way to write the Database entries of a specific Track ID in the database even if we have already an other track object around which referenced the same file but from and on other DB ID. How do you think about this idea:
|
I'll close this PR for now. The commits are still available in my "WriteAudioTags" branch/PR. I have to think about the implications of an alternative solution or how to handle inconsistencies/duplicates in existing libraries. |
A class for referencing tracks with or without an id. It is needed for the introduction of a TrackCache that manages tracks by their TrackRef.
The new class encapsulates both the location and id of a track. Each track has a unique location, but only tracks that are stored in the library have an id. The id is created and assigned when storing the track in the database for the first time.
This class also consistently calculates the track location from QFileInfo.