-
Notifications
You must be signed in to change notification settings - Fork 25
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
Comments
If you just want the last N changesets (where N isn't *too* big), you
can probably get away with just doing something like this:
```js
var through = require('through2')
var collect = require('collect-stream')
osm.log.createReadStream({ reverse: true, limit: 100 })
.pipe(through(write))
.pipe(collect(function (err, data) {
doWithChangesets(data)
})
function write (node, enc, next) {
if (node.value.type === 'changeset') {
this.push(node)
}
next()
}
function doWithChangesets (cs) {
// ...
}
```
This will give you the last 0-N changesets from the underlying hyperlog.
If you want more, you could remove the `limit` kv and just end the
stream once you have as many as you'd like.
|
Sorry, forgot github refuses to treat emails as markdown. :( |
How does the ordering work on
|
Yes: the ordering is not stable across machines. A hyperlog's CHANGEs
ordering is not globally ordered. However, after you grab the last N
changesets, you could sort them prior to presentation according to some
sort of deterministic predicate.
|
Yes to which part? You can't guarantee that E, F would come after A, B in the above case? |
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 (This is the in-order sequence. If |
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? |
It's not required, no. As a consumer of 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 If we wanted to try and ensure this, |
Ok, thanks, I think returning the order changesets were written is fine for now. |
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?
The text was updated successfully, but these errors were encountered: