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

storage: expose separate WriteBatch interface #98712

Merged
merged 1 commit into from Mar 21, 2023

Conversation

jbowens
Copy link
Collaborator

@jbowens jbowens commented Mar 15, 2023

Adapt NewUnindexedBatch to no longer take a writeOnly parameter. Instead, a new NewWriteBatch method is exposed that returns a WriteBatch type that does not provide Reader facilities. Future work may remove UnindexedBatch altogether, updating callers to explicitly maintain separate Readers and WriteBatches.

Epic: None
Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jbowens jbowens force-pushed the writebatch branch 2 times, most recently from d820c87 to ad639da Compare March 15, 2023 22:18
@jbowens jbowens marked this pull request as ready for review March 15, 2023 22:29
@jbowens jbowens requested review from a team as code owners March 15, 2023 22:29
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 15 of 15 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @itsbilal and @jbowens)


pkg/storage/engine.go line 977 at r1 (raw file):

	// iterator has to be repositioned using a seek operation, after the
	// mutations were done.
	ReadWriter

can this be changed to Reader?


pkg/storage/batch_test.go line 694 at r1 (raw file):

	defer e.Close()

	batch := e.NewUnindexedBatch(true /* writeOnly */)

Since someone can successfully turn a WriteBatch into a Reader since both are backed by the pebbleBatch implementation, should we keep this.

Adapt NewUnindexedBatch to no longer take a writeOnly parameter. Instead, a new
NewWriteBatch method is exposed that returns a WriteBatch type that does not
provide Reader facilities. Future work may remove UnindexedBatch altogether,
updating callers to explicitly maintain separate Readers and WriteBatches.

Epic: None
Release note: None
Copy link
Collaborator Author

@jbowens jbowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @itsbilal and @sumeerbhola)


pkg/storage/engine.go line 977 at r1 (raw file):

Previously, sumeerbhola wrote…

can this be changed to Reader?

Done.


pkg/storage/batch_test.go line 694 at r1 (raw file):

Previously, sumeerbhola wrote…

Since someone can successfully turn a WriteBatch into a Reader since both are backed by the pebbleBatch implementation, should we keep this.

Done.

@jbowens
Copy link
Collaborator Author

jbowens commented Mar 21, 2023

TFTR!

bors r=sumeerbhola

@craig
Copy link
Contributor

craig bot commented Mar 21, 2023

Build succeeded:

@craig craig bot merged commit 18e6641 into cockroachdb:master Mar 21, 2023
7 checks passed
@jbowens jbowens deleted the writebatch branch March 21, 2023 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants