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

Spatial and date indexes on Changesets #32

Open
gmaclennan opened this issue Feb 4, 2017 · 9 comments
Open

Spatial and date indexes on Changesets #32

gmaclennan opened this issue Feb 4, 2017 · 9 comments

Comments

@gmaclennan
Copy link
Member

We need to implement GET /api/0.6/changesets in order to create an interface for reviewing recent changes.

This would require both a spatial index on changesets and a date index. Is there a way to cheaply get an ordered list of changesets? e.g. if we can't rely on clocks being set correctly can we just pull the most recent changesets off the db?

@hackergrrl
Copy link
Contributor

hackergrrl commented Feb 4, 2017 via email

@hackergrrl
Copy link
Contributor

Sorry, forgot github refuses to treat emails as markdown. :(

@gmaclennan
Copy link
Member Author

How does the ordering work on log.createReadStream() after syncing? e.g.

  1. Machine 1 creates changesets A, B.
  2. Machine 1 syncs with machine 2
  3. Machine 1 creates changeset C, D
  4. Machine 2 creates changeset E, F
  5. Machine 1 and 2 sync.
  6. What would log.createReadStream() on Machine 1 now return? would we always get A, B before C, D E and F? Would the order C, D and E, F always be guaranteed? I am guessing the ordering of the two pairs [C, D] with [E, F] is not guaranteed?

@hackergrrl
Copy link
Contributor

hackergrrl commented Feb 4, 2017 via email

@gmaclennan
Copy link
Member Author

Yes to which part? You can't guarantee that E, F would come after A, B in the above case?

@hackergrrl
Copy link
Contributor

Re ordering, you can only assume that parents appear earlier than children. So the CHANGES log on each machine should be:

Machine 1: A B C D E F
Machine 2: A B E F C D

(This is the in-order sequence. If opts.reverse is provided, you'll be reading these in right-to-left instead.)

@gmaclennan
Copy link
Member Author

Ok, good, that would be good enough for our needs. Now would the changeset ordering match up with the node/way/relation ordering? i.e. can we assume that for the elements referenced in a changeset, parents appear earlier than children?

@hackergrrl
Copy link
Contributor

hackergrrl commented Feb 7, 2017

It's not required, no. As a consumer of osm-p2p-db, I could write

var nodeA = { type: 'node', id: 'A', lon: 0, lat: 0 }
var nodeB = { type: 'node', id: 'B', lon: 1, lat: 1 }
var way = { type: 'way', id: 'C', refs: [ 'A', 'B'] }
var ops = {
  { type: 'put', doc: way },
  { type: 'put', doc: nodeA },
  { type: 'put', doc: nodeB }
}
osm.batch(ops)

And then, if you read back osm.log.getReadStream() you would see them in the same order they were written. osm-p2p-db is intentionally (I believe) very ignorant about semantics. This could be another good candidate for the osm-p2p-api module we've been talking about.

If we wanted to try and ensure this, osm-p2p-server/api/put_changes.js might be a good place to do the sorting.

@gmaclennan
Copy link
Member Author

Ok, thanks, I think returning the order changesets were written is fine for now.

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

No branches or pull requests

2 participants