pub struct BatchSizeConfig {
pub size: usize,
pub strategy: BatchStrategy,
}Expand description
批量大小配置
对应 Hibernate @BatchSize(size = 100) 注解。
Fields§
§size: usize每批数量
strategy: BatchStrategy抓取策略
Implementations§
Source§impl BatchSizeConfig
impl BatchSizeConfig
Sourcepub fn new(size: usize, strategy: BatchStrategy) -> BatchSizeConfig
pub fn new(size: usize, strategy: BatchStrategy) -> BatchSizeConfig
创建配置
Sourcepub fn with_size(size: usize) -> BatchSizeConfig
pub fn with_size(size: usize) -> BatchSizeConfig
创建默认策略的配置(IN)
Sourcepub fn batch_count(&self, total: usize) -> usize
pub fn batch_count(&self, total: usize) -> usize
计算给定总数需要分多少批
§示例
use sz_orm_query::entity_graph::BatchSizeConfig;
let config = BatchSizeConfig::with_size(100);
assert_eq!(config.batch_count(0), 0);
assert_eq!(config.batch_count(1), 1);
assert_eq!(config.batch_count(100), 1);
assert_eq!(config.batch_count(101), 2);
assert_eq!(config.batch_count(250), 3);Sourcepub fn batch_range(&self, batch_index: usize, total: usize) -> Range<usize>
pub fn batch_range(&self, batch_index: usize, total: usize) -> Range<usize>
返回第 batch_index 批的范围(start..end,end 不超过 total)
§示例
use sz_orm_query::entity_graph::BatchSizeConfig;
let config = BatchSizeConfig::with_size(100);
assert_eq!(config.batch_range(0, 250), 0..100);
assert_eq!(config.batch_range(1, 250), 100..200);
assert_eq!(config.batch_range(2, 250), 200..250);Trait Implementations§
Source§impl Clone for BatchSizeConfig
impl Clone for BatchSizeConfig
Source§fn clone(&self) -> BatchSizeConfig
fn clone(&self) -> BatchSizeConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for BatchSizeConfig
Source§impl Debug for BatchSizeConfig
impl Debug for BatchSizeConfig
Source§impl Default for BatchSizeConfig
impl Default for BatchSizeConfig
Source§fn default() -> BatchSizeConfig
fn default() -> BatchSizeConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BatchSizeConfig
impl RefUnwindSafe for BatchSizeConfig
impl Send for BatchSizeConfig
impl Sync for BatchSizeConfig
impl Unpin for BatchSizeConfig
impl UnsafeUnpin for BatchSizeConfig
impl UnwindSafe for BatchSizeConfig
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more