[WIP] Introduce DocumentId class
Needs ReviewPublic

Authored by michaelh on Feb 25 2018, 11:11 AM.

Details

Reviewers
adridg
Group Reviewers
Baloo
Frameworks
Summary

This class shall successively replace the current DocId(quint64) to gain more flexibility.

  • Account for 64bit inodes
  • Port away from stBuf.st_dev which is not always constant
  • Use document ids of variable size

T8054

Test Plan

make test

Diff Detail

Repository
R293 Baloo
Branch
flex-class (branched from flexible-docid)
Lint
No Linters Available
Unit
No Unit Test Coverage
michaelh requested review of this revision.Feb 25 2018, 11:11 AM
michaelh created this revision.

A quick review of some quirks and weirdnesses in c++

src/engine/documentid.cpp
67 ↗(On Diff #28005)

if you make operator DeviceIdAndInode explicit, you probably end up with a bit better behavior.

Else the compiler happily converts a documentid to a deviceidandinode in order to make various comparisons at compile time.

e.g. DocumentId id(5,5);
bool b = true;
if (id == b) { ... } should compile, but probably isn't intended behavior..

src/engine/documentid.h
34 ↗(On Diff #28005)

Does it need to be exported? Is things outside of the baloo engine need to access this? (or is it just avaliable for tests)

If it is public-public, you need to be careful about the class size and ensure you have enough bits to work with in the members.

41 ↗(On Diff #28005)

is this needed? or is the default generated good enough?

45 ↗(On Diff #28005)

shouldn't this return a DocumentId& rather than a copy?

46 ↗(On Diff #28005)
=default
or if you remove the custom dtor, this will be autogenerated.

@svuorela: Thank you very much. I will try you suggestion as soon as I'm able to get the tests compiled.

src/engine/documentid.h
34 ↗(On Diff #28005)

I got linker errors without this, so ... err yes.

michaelh updated this revision to Diff 28090.Feb 26 2018, 8:14 AM
  • Revert merge with aliases-test

I have made two errors:

  1. Forgot to submit the adapted tests
  2. An error in reasoning: I have based this and D10829 on a branch with the adapted tests . As long as the changes are expected to be transparent it is much better to use the original tests. (This will also postpone the linker problems a little)
anthonyfieroni added inline comments.
src/engine/documentid.h
51–52

Make a d poniter in exported class.

svuorela added inline comments.Feb 26 2018, 6:58 PM
src/engine/documentid.h
51–52

it depends on why it is exported. If it is exported just for unit test (and the header file not installed), then we don't need to have the mental and code wise overhead of a d-pointer.

If we know that it will never ever need to grow, we also don't need the overhead of a d-pointer.
So it is a big "it depends", which I was also kind of trying to ask into earlier.

michaelh added inline comments.Feb 27 2018, 5:58 PM
src/engine/documentid.cpp
67 ↗(On Diff #28005)

This is intended. At the moment the class should behave like quint64(=DeviceIdAndInode)

src/engine/documentid.h
51–52

I have to admit, I have not understood the meaning of BALOO_ENGINE_EXPORT yet. The file which defines it looks like it's automatically created. I inserted it after trial and error. Except for testing I see no reason why it should be exported. I consider it as strictly internal.

In its present state this class shall serve as a replacement for the quint64 that baloo is currently using for an id.
Finally this class will have a payload of 24 bytes max. (64bit inode and 128bit uuid) and one method: isValid(). That at least is the plan.

This class is used a lot. What I have read about d-pointers so far indicates a huge performance hit when using indirection. Maybe I'm wrong.

@svuorela: I'm sorry if my answer appeared uncouth. That was not intended. Currently a lot of my programming is the result of trial and error rather than knowledge. In time the ratio, hopefully, will change in favor of the latter :)

michaelh retitled this revision from Introduce DocumentId class to [WIP] Introduce DocumentId class.Feb 28 2018, 9:57 AM

This looks abandoned with 2 years of no movement. @michaelh do you still feel this is a WIP?

Restricted Application added a subscriber: kde-frameworks-devel. · View Herald TranscriptMay 30 2020, 3:53 PM