-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Cursor & SelectMapper Refactor (WIP) #4180
Cursor & SelectMapper Refactor (WIP) #4180
Conversation
Can you explain why this will help with the upcoming engine changes? We started months ago with a single Mapper type, the first round of DQ changes split it into Raw and Aggregate, and @dgnorton merged it back to a single type. Now this change splits it again. I'd like to make sure I have the full context. |
I didn't merge raw and agg mappers. At least not that I remember. :) |
func (tx *Tx) Cursor(key string, direction tsdb.Direction) tsdb.Cursor { | ||
// Retrieve key bucket. | ||
b := tx.Bucket([]byte(key)) | ||
// Cursor returns an iterator for a key over a single field. |
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.
I may be reading this wrong, but we say single field
here, do we mean single point
? Later, in the cursor.read
method we check to see if we have a single field or multiple fields, which implies we can cursor over multiple fields right?
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.
The Cursor()
was to do a single field originally. It was too hard to split that out right now so we'll have to wrap the pd
storage with a wrapping cursor to join individual field cursors.
@dgnorton -- yeah, I stated that incorrectly. What you did do is embed the Raw Mapper inside a LocalMapper i.e. set a Local into Raw mode. In other words, we're churning the implementation of this, and I wanted to understand why we're reverting to an earlier form. Perhaps it's for the same reasons I first separated the two Mappers. |
@otoolep I resolved some more test failures but it's really slow going. I'm getting a type assertion error now. It's difficult to keep track of which fields are getting processed where. I pushed my latest code (98328ab). |
OK @benbjohnson - I will take a look. I was mistaken about work @dgnorton had done, I forgot that I merged the mappers. |
@@ -7,7 +7,7 @@ if [ $fmtcount -gt 0 ]; then | |||
fi | |||
|
|||
# Due to the way composites work, vet will fail for some of our tests so we ignore it | |||
vetcount=`go tool vet --composites=false ./ 2>&1 | wc -l` | |||
vetcount=`go tool vet --composites=false --methods=false ./ 2>&1 | wc -l` |
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.
😢
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.
Let me know if you have a better method name than Seek().
It probably makes sense to move to iterators (with just a Next() method) instead of cursors but that's a refactor for another time.
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.
I hit this before and just used the name SeekTo
.
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.
Ah, I see you also used SeekTo
, according to a comment below. So can this go vet
change be pulled?
// Read items until we have a key that doesn't match the previously read one. | ||
// This is to perform deduplication when there's multiple items with the same key. | ||
// The highest priority cursor will be read first and then remaining keys will be dropped. | ||
for { | ||
// Return nil if there are no more items left. | ||
// Return EOF marker if there are no more items left. |
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.
Why this change?
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.
nil
isn't allowed now that we're using int64
so I wanted to declare the marker more explicitly than simply doing -1
.
I took a look at this, and it generally looks fine. Can you give us a couple of lines on your thinking, about why you wanted this change? |
b99da42
to
56cb2fa
Compare
639db30
to
96715d7
Compare
…apper Conflicts: tsdb/store.go
Cursor & SelectMapper Refactor (WIP)
@otoolep Sure, the main goal for this change was to make it so that There were a few issues with passing fields into the cursor:
|
Thanks @benbjohnson -- both of those points are good ones, with which I agree. |
Overview
This pull request refactors the
SelectMapper
into separate raw and aggregate mappers and it refactors theCursor
implementation to returnint64
keys andinterface{}
values.This pull request is largely complete but still has test failures