Skip to content
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

[WIP] Store an optional value on doc deletions. #46

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

hackergrrl
Copy link
Contributor

No description provided.

Copy link
Member

@gmaclennan gmaclennan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel pretty good about this approach. Any blockers on moving ahead with this?

index.js Outdated
@@ -40,7 +40,8 @@ function DB (opts) {
map: function (row, next) {
if (!row.value) return null
var v = row.value.v, d = row.value.d
if (v && v.lat !== undefined && v.lon !== undefined) {
var k = row.value.k
if (k && v.lat !== undefined && v.lon !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this change, can you explain the implications / reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that DELETEs can have a v (value) as well as PUTs, checking for k (key) is a more reliable way of differentiating between PUTs and DELETEs. I can wrap this in a helper function to be more explicit -- not a bad idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is is performance-critical code I think better use a comment rather than function, which would have a slight performance overhead.

One thing though, a delete could have lat and lon defined, that wouldn't affect here right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call re comment vs function.

One thing though, a delete could have lat and lon defined, that wouldn't affect here right?

Right. Deletions have a d key, and insertions have a k key. Since this new code checks for the presence of a k, even deletions with values would be ignored.

@hackergrrl
Copy link
Contributor Author

This is ready for another look-over. Here's the gist:

  1. Writing deletions: starting at osm.del(), the deletion values are threaded through into _getDocumentDeletionBatchOp(), which generates a new batch op structure to be passed into osm.batch(), which in turn get fed into kv.batch().
  2. Exposing values on deletions: look in osm.get() and addDocFromNode() in _collectNodeAndReferers().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants