forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
c2c: refactor eventStream to track batch in seperate streamEventBatcher
This is a small refactor cleans up the streamLoop() in the eventStream and makes it easier to emit spanConfig protos for zone config replication. Epic: none Release note: None
- Loading branch information
Showing
9 changed files
with
173 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
pkg/ccl/streamingccl/streamproducer/stream_event_batcher.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package streamproducer | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvpb" | ||
"github.com/cockroachdb/cockroach/pkg/repstream/streampb" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
) | ||
|
||
type streamEventBatcher struct { | ||
batch streampb.StreamEvent_Batch | ||
size int | ||
} | ||
|
||
func makeStreamEventBatcher() *streamEventBatcher { | ||
return &streamEventBatcher{ | ||
batch: streampb.StreamEvent_Batch{}, | ||
} | ||
} | ||
|
||
func (seb *streamEventBatcher) reset() { | ||
seb.size = 0 | ||
seb.batch.KeyValues = seb.batch.KeyValues[:0] | ||
seb.batch.Ssts = seb.batch.Ssts[:0] | ||
seb.batch.DelRanges = seb.batch.DelRanges[:0] | ||
} | ||
|
||
func (seb *streamEventBatcher) addSST(sst *kvpb.RangeFeedSSTable) { | ||
seb.batch.Ssts = append(seb.batch.Ssts, *sst) | ||
seb.size += sst.Size() | ||
} | ||
|
||
func (seb *streamEventBatcher) addKV(kv *roachpb.KeyValue) { | ||
seb.batch.KeyValues = append(seb.batch.KeyValues, *kv) | ||
seb.size += kv.Size() | ||
} | ||
|
||
func (seb *streamEventBatcher) addDelRange(d *kvpb.RangeFeedDeleteRange) { | ||
// DelRange's span is already trimmed to enclosed within | ||
// the subscribed span, just emit it. | ||
seb.batch.DelRanges = append(seb.batch.DelRanges, *d) | ||
seb.size += d.Size() | ||
} | ||
|
||
func (seb *streamEventBatcher) getSize() int { | ||
return seb.size | ||
} |
Oops, something went wrong.