You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReQL proposal: allow changefeeds on specific documents #2542
Also, I think it would be useful to have an optarg that makes r.table('foo').get(id).changes() return as its first change object the actual value of r.table('foo').get(id). I think the most common use case for this is "get me this row and tell me when it changes", which is hard to do by composing a get and a changes call because you might miss a change in-between.
Is this any different from applying a .filter(r.row('id').eq(id))?
Scalability. If you filter, the changefeed has to look at every row, so you can't create millions of them. With a changefeed on get, you might be able to (at least theoretically).
You do the changes call first and then do a get.
You might lose documents in between. The flag would guarantee atomicity.
Is this any different from applying a .filter(r.row('id').eq(id))?
Like Slava said, scalability. We could theoretically do this by just having a better query optimizer, but that's a whole thing.
You do the changes call first and then do a get.
Yes, but that's a pain, and still doesn't quite do what you want. What you really want is to know the most recent version of the document at any point in time. OK, so you've called changes and gotten back a stream, and done a get. Is the value of the get the most recent version of the document? Well, you'd have to look at what's in the stream, but that can block. So you have to set the value to the object you got back from get, then consume the stream and only start replacing the value with the objects in the stream when you see old_val:VALUE_RETURNED_FROM_GET. People can definitely do that, but it sucks.
You can't set the value to get and then replace from the stream without checking old_val unless you're OK with the value maybe changing from a newer value to and older value and back (which might be confusing depending on the use case).
@neumino -- yes. But @srh was talking about opening a changefeed and then doing the get, which prevents you from missing changes at the cost of needing extra logic in your app to maintain ordering.
In particular, the most important performance improvement to look for right now is that of: not having to send every write to every single changefeed-listening parser in the cluster. Making btree nodes also not have to iterate through a list of changefeed listeners (by registering point-listeners with a map by key, on the store end?) is a relatively miniscule benefit.
I don't see why you would expect it to be anything other than a changefeed that covers the exact set of documents provided by the initial filter at the changefeed's creation.
(Note that it covering the exact set of documents wouldn't be a great idea because (I think) it would require an up-front traversal of the entire table. Actually, maybe not, if we send exact per-row timestamps to the parser and use that detect which documents were part of the set, the first time they come through?) I still don't like that behavior either, because it doesn't seem like what people would want -- the set of documents as defined by a filter sounds like the sort of thing you'd want to include any new documents inserted into the database too, in most applications.
I think maybe seq.filter(x).changes() might also want to be equivalent to seq.changes().filter(lambda row: x(row['new_val']).or(x(row['old_val']))) ???
Or maybe, when x runs on new_val and old_val, and fails on one of them, that entry is null. If it fails on both of them, the document's not part of the changefeed at all. That way, the changefeed can see what enters and removes the given selection. I think this might be what you really want and it seems to generally make sense.
But with that, things would get dicey with a .filter(...).map(...).changes(). We've got a general sort of query transformation in play.
(On that note, it might not be so bad internally -- I think datum_stream_t should have its role replaced in much of query evaluation with selection_t or something that merely describes a table and the operations that have been attached to in in order to form a selection, without that dreadful state related to streaming actual data.)
Or maybe, when x runs on new_val and old_val, and fails on one of them, that entry is null.
Also, combining that with return_all=True, you get the exact set and sequence of data you'd need to construct and maintain a per-parser view of some query on the table. Some kind of future .create_view(...) operation would be able to match the semantics of changes() quite nicely.
Or maybe, when x runs on new_val and old_val, and fails on one of them, that entry is null. If it fails on both of them, the document's not part of the changefeed at all. That way, the changefeed can see what enters and removes the given selection. I think this might be what you really want and it seems to generally make sense.
That's what I would expect.
On that note, it might not be so bad internally -- I think datum_stream_t should have its role replaced in much of query evaluation with selection_t or something that merely describes a table and the operations that have been attached to in in order to form a selection, without that dreadful state related to streaming actual data.
This is basically how we do it now. A lazy_datum_stream_t (which is the only kind we'd need to support this on I think) has a reader_t which contains an std::vector<transform_variant_t>.
Activity
mlucy commentedon Jun 12, 2014
+1
I think this is really important, and arguably more useful than the existing changefeeds.
mlucy commentedon Jun 12, 2014
Also, I think it would be useful to have an optarg that makes
r.table('foo').get(id).changes()return as its first change object the actual value ofr.table('foo').get(id). I think the most common use case for this is "get me this row and tell me when it changes", which is hard to do by composing agetand achangescall because you might miss a change in-between.mlucy commentedon Jun 12, 2014
But we can talk more about this when it's scheduled.
srh commentedon Jun 13, 2014
Is this any different from applying a
.filter(r.row('id').eq(id))? Aside from getting the row.You do the changes call first and then do a get.
coffeemug commentedon Jun 13, 2014
Scalability. If you filter, the changefeed has to look at every row, so you can't create millions of them. With a changefeed on
get, you might be able to (at least theoretically).You might lose documents in between. The flag would guarantee atomicity.
mlucy commentedon Jun 13, 2014
Like Slava said, scalability. We could theoretically do this by just having a better query optimizer, but that's a whole thing.
Yes, but that's a pain, and still doesn't quite do what you want. What you really want is to know the most recent version of the document at any point in time. OK, so you've called changes and gotten back a stream, and done a
get. Is the value of thegetthe most recent version of the document? Well, you'd have to look at what's in the stream, but that can block. So you have to set the value to the object you got back fromget, then consume the stream and only start replacing the value with the objects in the stream when you seeold_val:VALUE_RETURNED_FROM_GET. People can definitely do that, but it sucks.You can't set the value to
getand then replace from the stream without checkingold_valunless you're OK with the value maybe changing from a newer value to and older value and back (which might be confusing depending on the use case).neumino commentedon Jun 13, 2014
Can I miss some changes between the
get()and thechanges()?mlucy commentedon Jun 13, 2014
@neumino -- yes. But @srh was talking about opening a changefeed and then doing the get, which prevents you from missing changes at the cost of needing extra logic in your app to maintain ordering.
srh commentedon Jun 16, 2014
What are you talking about? You don't get any scalability benefits by doing changefeeds on a specific document.
If we implemented things such that you would, we could also implement things such that you also get the scalability benefits when applying a filter.
srh commentedon Jun 16, 2014
In particular, the most important performance improvement to look for right now is that of: not having to send every write to every single changefeed-listening parser in the cluster. Making btree nodes also not have to iterate through a list of changefeed listeners (by registering point-listeners with a map by key, on the store end?) is a relatively miniscule benefit.
9 remaining items
srh commentedon Jun 18, 2014
I don't see why you would expect it to be anything other than a changefeed that covers the exact set of documents provided by the initial filter at the changefeed's creation.
coffeemug commentedon Jun 18, 2014
Ah, you're right. I don't think I should comment more on this until I get eight hours worth of sleep.
srh commentedon Jun 18, 2014
(Note that it covering the exact set of documents wouldn't be a great idea because (I think) it would require an up-front traversal of the entire table. Actually, maybe not, if we send exact per-row timestamps to the parser and use that detect which documents were part of the set, the first time they come through?) I still don't like that behavior either, because it doesn't seem like what people would want -- the set of documents as defined by a filter sounds like the sort of thing you'd want to include any new documents inserted into the database too, in most applications.
I think maybe
seq.filter(x).changes()might also want to be equivalent toseq.changes().filter(lambda row: x(row['new_val']).or(x(row['old_val'])))???Or maybe, when
xruns on new_val and old_val, and fails on one of them, that entry is null. If it fails on both of them, the document's not part of the changefeed at all. That way, the changefeed can see what enters and removes the given selection. I think this might be what you really want and it seems to generally make sense.But with that, things would get dicey with a
.filter(...).map(...).changes(). We've got a general sort of query transformation in play.(On that note, it might not be so bad internally -- I think
datum_stream_tshould have its role replaced in much of query evaluation withselection_tor something that merely describes a table and the operations that have been attached to in in order to form a selection, without that dreadful state related to streaming actual data.)srh commentedon Jun 18, 2014
Also, combining that with
return_all=True, you get the exact set and sequence of data you'd need to construct and maintain a per-parser view of some query on the table. Some kind of future.create_view(...)operation would be able to match the semantics ofchanges()quite nicely.mlucy commentedon Jun 18, 2014
That's what I would expect.
This is basically how we do it now. A
lazy_datum_stream_t(which is the only kind we'd need to support this on I think) has areader_twhich contains anstd::vector<transform_variant_t>.srh commentedon Jun 18, 2014
In other words, it's not how we do it now.
datum_stream_tis a stateful object that streams.coffeemug commentedon Jun 19, 2014
Moving to 1.14 since it's relevant to #1118.
coffeemug commentedon Jun 24, 2014
Talked to @mlucy in person. He's going to write up a proposal.
mlucy commentedon Jun 25, 2014
I'd like to fold this into #1118 if there are no objections.
coffeemug commentedon Jun 25, 2014
Sounds good.