-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix: Add object marker to enable return of empty docs #800
Conversation
core/key.go
Outdated
if len(elements) == 6 { | ||
return DataStoreKey{ | ||
CollectionId: elements[3], | ||
InstanceType: InstanceType(elements[4]), | ||
DocKey: elements[5], | ||
} | ||
} | ||
|
||
numberOfElements := len(elements) |
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.
@AndrewSisley you may not like this so let me know if you think I should do something different.
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.
Yeah, I would suggest adding a new Key type for this - it doesn't use all the props and you'll be able to give it a clearer name/docs.
EDIT: Although conceptually this can perhaps be seen as nil field, and breaking it out to a new type would make the fetcher code more complex? Suggest some docs in here if you keep like this
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.
If we were using a new key type, it would end up being a duplicate of the primary key in a sense. This means that we could instead use the primary key to accomplish this but that would make the fetcher more complex.
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.
Not fussed about the duplication (is a coincidence), but whether it is worth the extra fetcher hassle is quite tenuous
db/fetcher/fetcher.go
Outdated
// skip object markers | ||
if bytes.Equal(df.kv.Value, []byte{base.ObjectMarker}) { | ||
continue | ||
} | ||
|
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.
suggestion: You don't need the for loop anymore, as all branches now return according to logic. Is that desired? if so then remove the outer for { }
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.
indeed. I had removed it initially and then reverted while trying to find a problem and never re-removed it.
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.
Really surprised how little code you managed to do this in :) And I was wondering if we'd have to go this route :( Got a todo for you regarding extra scan rows for docs with fields - that one is fairly significant, and a minor skipable comment RE to dockey lines.
core/key.go
Outdated
if len(elements) == 6 { | ||
return DataStoreKey{ | ||
CollectionId: elements[3], | ||
InstanceType: InstanceType(elements[4]), | ||
DocKey: elements[5], | ||
} | ||
} | ||
|
||
numberOfElements := len(elements) |
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.
Yeah, I would suggest adding a new Key type for this - it doesn't use all the props and you'll be able to give it a clearer name/docs.
EDIT: Although conceptually this can perhaps be seen as nil field, and breaking it out to a new type would make the fetcher code more complex? Suggest some docs in here if you keep like this
db/collection.go
Outdated
|
||
// write value object marker | ||
valueKey := c.getDatastoreFromDocKey(dockey) | ||
err = txn.Datastore().Put(ctx, valueKey.ToDS(), []byte{base.ObjectMarker}) |
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.
todo: Would really suggest only adding these if the doc is empty/nil, otherwise you are adding an extra scan row to every doc in the db. We got a notable performance gain breaking out the PKs.
0edc20d
to
93cae66
Compare
Codecov Report
@@ Coverage Diff @@
## develop #800 +/- ##
========================================
Coverage 59.53% 59.54%
========================================
Files 154 154
Lines 17181 17219 +38
========================================
+ Hits 10229 10253 +24
- Misses 6030 6040 +10
- Partials 922 926 +4
|
core/key.go
Outdated
if isDataObjectMarker(elements) { | ||
return DataStoreKey{ | ||
CollectionId: elements[3], | ||
InstanceType: InstanceType(elements[4]), |
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.
suggestion(non-bocking): IMO it would be clearer to just hardcode InstanceType here, as the current suggests that it can be stuff other than Value
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.
Good job :) Hope you had fun figuring this out :D
d5e8514
to
2eede48
Compare
Relevant issue(s)
Resolves #610
Description
This PR add an object marker to stored documents. This helps the iterator return an empty documents.
Tasks
How has this been tested?
integration tests
Specify the platform(s) on which this was tested: