pub struct CapacitySplitTableBuilder<F>where
F: TableBuilderFactory,{Show 13 fields
builder_factory: F,
sst_outputs: Vec<LocalSstableInfo>,
current_builder: Option<SstableBuilder<F::Writer, F::Filter>>,
pub compactor_metrics: Arc<CompactorMetrics>,
task_progress: Option<Arc<TaskProgress>>,
last_table_id: u32,
vnode_count: usize,
table_vnode_partition: BTreeMap<u32, u32>,
split_weight_by_vnode: u32,
largest_vnode_in_current_partition: usize,
concurrent_upload_join_handle: FuturesUnordered<UploadJoinHandle>,
concurrent_uploading_sst_count: Option<usize>,
compaction_catalog_agent_ref: CompactionCatalogAgentRef,
}
Expand description
A wrapper for SstableBuilder
which automatically split key-value pairs into multiple tables,
based on their target capacity set in options.
When building is finished, one may call finish
to get the results of zero, one or more tables.
Fields§
§builder_factory: F
When creating a new SstableBuilder
, caller use this factory to generate it.
sst_outputs: Vec<LocalSstableInfo>
§current_builder: Option<SstableBuilder<F::Writer, F::Filter>>
§compactor_metrics: Arc<CompactorMetrics>
Statistics.
task_progress: Option<Arc<TaskProgress>>
Update the number of sealed Sstables.
last_table_id: u32
§vnode_count: usize
§table_vnode_partition: BTreeMap<u32, u32>
§split_weight_by_vnode: u32
§largest_vnode_in_current_partition: usize
When vnode of the coming key is greater than largest_vnode_in_current_partition
, we will
switch SST.
concurrent_upload_join_handle: FuturesUnordered<UploadJoinHandle>
§concurrent_uploading_sst_count: Option<usize>
§compaction_catalog_agent_ref: CompactionCatalogAgentRef
Implementations§
source§impl<F> CapacitySplitTableBuilder<F>where
F: TableBuilderFactory,
impl<F> CapacitySplitTableBuilder<F>where
F: TableBuilderFactory,
sourcepub fn new(
builder_factory: F,
compactor_metrics: Arc<CompactorMetrics>,
task_progress: Option<Arc<TaskProgress>>,
table_vnode_partition: BTreeMap<u32, u32>,
concurrent_uploading_sst_count: Option<usize>,
compaction_catalog_agent_ref: CompactionCatalogAgentRef,
) -> Self
pub fn new( builder_factory: F, compactor_metrics: Arc<CompactorMetrics>, task_progress: Option<Arc<TaskProgress>>, table_vnode_partition: BTreeMap<u32, u32>, concurrent_uploading_sst_count: Option<usize>, compaction_catalog_agent_ref: CompactionCatalogAgentRef, ) -> Self
Creates a new CapacitySplitTableBuilder
using given configuration generator.
pub fn for_test( builder_factory: F, compaction_catalog_agent_ref: CompactionCatalogAgentRef, ) -> Self
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of SstableBuilder
s.
pub async fn add_full_key_for_test( &mut self, full_key: FullKey<&[u8]>, value: HummockValue<&[u8]>, is_new_user_key: bool, ) -> HummockResult<()>
pub async fn add_raw_block( &mut self, buf: Bytes, filter_data: Vec<u8>, smallest_key: FullKey<Vec<u8>>, largest_key: Vec<u8>, block_meta: BlockMeta, ) -> HummockResult<bool>
sourcepub async fn add_full_key(
&mut self,
full_key: FullKey<&[u8]>,
value: HummockValue<&[u8]>,
is_new_user_key: bool,
) -> HummockResult<()>
pub async fn add_full_key( &mut self, full_key: FullKey<&[u8]>, value: HummockValue<&[u8]>, is_new_user_key: bool, ) -> HummockResult<()>
Adds a key-value pair to the underlying builders.
If allow_split
and the current builder reaches its capacity, this function will create a
new one with the configuration generated by the closure provided earlier.
Note that in some cases like compaction of the same user key, automatic splitting is not
allowed, where allow_split
should be false
.
pub fn check_switch_builder(&mut self, user_key: &UserKey<&[u8]>) -> bool
pub fn need_flush(&self) -> bool
sourcepub async fn seal_current(&mut self) -> HummockResult<()>
pub async fn seal_current(&mut self) -> HummockResult<()>
Marks the current builder as sealed. Next call of add
will always create a new table.
If there’s no builder created, or current one is already sealed before, then this function will be no-op.
sourcepub async fn finish(self) -> HummockResult<Vec<LocalSstableInfo>>
pub async fn finish(self) -> HummockResult<Vec<LocalSstableInfo>>
Finalizes all the tables to be ids, blocks and metadata.
Auto Trait Implementations§
impl<F> !Freeze for CapacitySplitTableBuilder<F>
impl<F> !RefUnwindSafe for CapacitySplitTableBuilder<F>
impl<F> Send for CapacitySplitTableBuilder<F>where
F: Send,
impl<F> Sync for CapacitySplitTableBuilder<F>
impl<F> Unpin for CapacitySplitTableBuilder<F>where
F: Unpin,
<F as TableBuilderFactory>::Writer: Unpin,
<F as TableBuilderFactory>::Filter: Unpin,
impl<F> !UnwindSafe for CapacitySplitTableBuilder<F>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.