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

exec: add interface skeletons #31185

Merged
merged 1 commit into from Oct 15, 2018

Conversation

Projects
None yet
3 participants
@jordanlewis
Member

jordanlewis commented Oct 10, 2018

Add the interface skeletons for column vector operators.

Release note: None

@jordanlewis jordanlewis requested a review from cockroachdb/sql-rest-prs as a code owner Oct 10, 2018

@cockroach-teamcity

This comment has been minimized.

Show comment
Hide comment
@cockroach-teamcity

cockroach-teamcity Oct 10, 2018

Member

This change is Reviewable

Member

cockroach-teamcity commented Oct 10, 2018

This change is Reviewable

@asubiotto

Nice. Are these interfaces so we can start working independently or are you planning on keeping them as interfaces?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/exec/colbatch.go, line 39 at r1 (raw file):

	// slice of columns in this batch.
	b      []ColVec
	useSel bool

What about getting rid of this boolean and checking if sel != nil for the cases you would want to use the selection vector.


pkg/sql/exec/colbatch.go, line 41 at r1 (raw file):

	useSel bool
	// if useSel is true, a selection vector from upstream. a selection vector is
	// a list of selected column indexes in this dataFlow's columns.

I think the term dataFlow is undefined here?


pkg/sql/exec/colvec.go, line 19 at r1 (raw file):

// ColVec is an interface that represents a column vector that's accessible by
// Go native types.
type ColVec interface {

Do we also want to have a Type() byte method?


pkg/sql/exec/colvec.go, line 22 at r1 (raw file):

	Nulls

	// TODO(jordan): is a bitmap or slice of bools better?

I'm wondering about this too. Why is it an interface?


pkg/sql/exec/colvec.go, line 130 at r1 (raw file):

type memBytes struct {
	col [][]byte

We might want to actually make this a single slice of []byte with associated offsets. I guess this is fine for now and you're doing this for simplicity.

@jordanlewis

These will stay interfaces. It's okay to have interfaces at this level of the code - as long as they spit out the actual data vectors for the operators to operate on. It's also useful to have multiple implementations of at least ColBatch - one is this simple, in-memory slices one, which is convenient for testing, and one is the ptable block format which is more memory efficient but harder to use.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/exec/colbatch.go, line 39 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

What about getting rid of this boolean and checking if sel != nil for the cases you would want to use the selection vector.

That won't work - you need to pass along the selection vector memory so downstream operators can set and edit it. So you do need the boolean.


pkg/sql/exec/colbatch.go, line 41 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

I think the term dataFlow is undefined here?

Oops, done.


pkg/sql/exec/colvec.go, line 19 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

Do we also want to have a Type() byte method?

Good question. I don't think it's necessary to keep a type in this interface, because every operator will statically know the type of all of its columns. Maybe it'll be convenient to have it later, but for now it's not necessary.


pkg/sql/exec/colvec.go, line 22 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

I'm wondering about this too. Why is it an interface?

I'm copying this from Peter's code in pebble. It's possible that this should just be a slice of bools, but then that doesn't let us use a bitmap if that's faster. I'm not sure - but this will give us a place to start. It'll be easy enough to change later.


pkg/sql/exec/colvec.go, line 130 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

We might want to actually make this a single slice of []byte with associated offsets. I guess this is fine for now and you're doing this for simplicity.

Yeah, the memFoo structures are not intended to be the efficient ones. I'm going to add that in soon - it'll be accessors to the ptable block format in pebble.

It remains to be seen via benchmarking and experimentation whether we want to abandon any function calls for accessing the varlen datatypes. exectoy didn't have any of that stuff, so we'll have to start somewhere. This interface is copied from pebble - it's a place to start.

@asubiotto

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/exec/colbatch.go, line 39 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

That won't work - you need to pass along the selection vector memory so downstream operators can set and edit it. So you do need the boolean.

As discussed in slack, this might not be necessary but you think it's clearer. I personally think that removing this boolean is clearer than not doing so and avoids the possibility of weird states (i.e. what does it mean when useSel is false but sel is a slice). Do whatever you think is right, don't want this to block the PR.

exec: add interface skeletons
Add the interface skeletons for column vector operators.

Release note: None
@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Oct 15, 2018

Member

(i.e. what does it mean when useSel is false but sel is a slice)

You're right, but it's hard to figure out what to do one way or the other until we actually have operators to look at. Going to merge as-is just as a straw man.

bors r+

Member

jordanlewis commented Oct 15, 2018

(i.e. what does it mean when useSel is false but sel is a slice)

You're right, but it's hard to figure out what to do one way or the other until we actually have operators to look at. Going to merge as-is just as a straw man.

bors r+

craig bot pushed a commit that referenced this pull request Oct 15, 2018

Merge #31185
31185: exec: add interface skeletons r=jordanlewis a=jordanlewis

Add the interface skeletons for column vector operators.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig

This comment has been minimized.

Show comment
Hide comment
@craig

craig bot commented Oct 15, 2018

Build succeeded

@craig craig bot merged commit 7aa4427 into cockroachdb:master Oct 15, 2018

3 checks passed

GitHub CI (Cockroach) TeamCity build finished
Details
bors Build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@jordanlewis jordanlewis deleted the jordanlewis:vec branch Oct 16, 2018

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