Skip to content

Commit

Permalink
fix: rename as_bytes to as_byte in ReadableSize (apache#428) (apache#767
Browse files Browse the repository at this point in the history
)

* fix: rename as_bytes to as_byte in ReadableSize (apache#428)

* style: fmt server.rs
  • Loading branch information
zouxiang1993 authored Mar 26, 2023
1 parent c54d931 commit 15b365b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 34 deletions.
8 changes: 4 additions & 4 deletions analytic_engine/src/compaction/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ impl LevelPicker for SizeTieredPicker {
segment.to_vec(),
opts.bucket_high,
opts.bucket_low,
opts.min_sstable_size.as_bytes() as f32,
opts.min_sstable_size.as_byte() as f32,
);

let files = Self::most_interesting_bucket(
buckets,
opts.min_threshold,
opts.max_threshold,
opts.max_input_sstable_size.as_bytes(),
opts.max_input_sstable_size.as_byte(),
);

if files.is_some() {
Expand Down Expand Up @@ -497,13 +497,13 @@ impl TimeWindowPicker {
bucket.to_vec(),
size_tiered_opts.bucket_high,
size_tiered_opts.bucket_low,
size_tiered_opts.min_sstable_size.as_bytes() as f32,
size_tiered_opts.min_sstable_size.as_byte() as f32,
);
let files = SizeTieredPicker::most_interesting_bucket(
buckets,
size_tiered_opts.min_threshold,
size_tiered_opts.max_threshold,
size_tiered_opts.max_input_sstable_size.as_bytes(),
size_tiered_opts.max_input_sstable_size.as_byte(),
);

if files.is_some() {
Expand Down
2 changes: 1 addition & 1 deletion analytic_engine/src/compaction/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl SchedulerImpl {
request_buf: RwLock::new(RequestQueue::default()),
}),
running: running.clone(),
memory_limit: MemoryLimit::new(config.memory_limit.as_bytes() as usize),
memory_limit: MemoryLimit::new(config.memory_limit.as_byte() as usize),
};

let handle = runtime.spawn(async move {
Expand Down
6 changes: 3 additions & 3 deletions analytic_engine/src/instance/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Instance {
space_store.clone(),
bg_runtime.clone(),
scheduler_config,
ctx.config.write_sst_max_buffer_size.as_bytes() as usize,
ctx.config.write_sst_max_buffer_size.as_byte() as usize,
scan_options_for_compaction,
));

Expand Down Expand Up @@ -104,11 +104,11 @@ impl Instance {
db_write_buffer_size: ctx.config.db_write_buffer_size,
space_write_buffer_size: ctx.config.space_write_buffer_size,
replay_batch_size: ctx.config.replay_batch_size,
write_sst_max_buffer_size: ctx.config.write_sst_max_buffer_size.as_bytes() as usize,
write_sst_max_buffer_size: ctx.config.write_sst_max_buffer_size.as_byte() as usize,
max_bytes_per_write_batch: ctx
.config
.max_bytes_per_write_batch
.map(|v| v.as_bytes() as usize),
.map(|v| v.as_byte() as usize),
iter_options,
scan_options,
remote_engine: remote_engine_ref,
Expand Down
10 changes: 5 additions & 5 deletions analytic_engine/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ fn open_storage(
}
};

if opts.disk_cache_capacity.as_bytes() > 0 {
if opts.disk_cache_capacity.as_byte() > 0 {
let path = Path::new(&opts.disk_cache_dir).join(DISK_CACHE_DIR_NAME);
tokio::fs::create_dir_all(&path).await.context(CreateDir {
path: path.to_string_lossy().into_owned(),
Expand All @@ -471,20 +471,20 @@ fn open_storage(
store = Arc::new(
DiskCacheStore::try_new(
path.to_string_lossy().into_owned(),
opts.disk_cache_capacity.as_bytes() as usize,
opts.disk_cache_page_size.as_bytes() as usize,
opts.disk_cache_capacity.as_byte() as usize,
opts.disk_cache_page_size.as_byte() as usize,
store,
)
.await
.context(OpenObjectStore)?,
) as _;
}

if opts.mem_cache_capacity.as_bytes() > 0 {
if opts.mem_cache_capacity.as_byte() > 0 {
let mem_cache = Arc::new(
MemCache::try_new(
opts.mem_cache_partition_bits,
NonZeroUsize::new(opts.mem_cache_capacity.as_bytes() as usize).unwrap(),
NonZeroUsize::new(opts.mem_cache_capacity.as_byte() as usize).unwrap(),
)
.context(OpenMemCache)?,
);
Expand Down
2 changes: 1 addition & 1 deletion common_util/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ReadableSize {
self.0 / MIB
}

pub const fn as_bytes(self) -> u64 {
pub const fn as_byte(self) -> u64 {
self.0
}
}
Expand Down
43 changes: 23 additions & 20 deletions server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,26 +355,29 @@ impl<Q: QueryExecutor + 'static> Builder<Q> {
.context(BuildMysqlService)?;

let router = self.router.context(MissingRouter)?;
let rpc_services = grpc::Builder::new()
.endpoint(
Endpoint::new(self.server_config.bind_addr, self.server_config.grpc_port)
.to_string(),
)
.local_endpoint(Endpoint::new(self.node_addr, self.server_config.grpc_port).to_string())
.resp_compress_min_length(
self.server_config.resp_compress_min_length.as_bytes() as usize
)
.runtimes(engine_runtimes)
.instance(instance.clone())
.router(router)
.cluster(self.cluster.clone())
.opened_wals(opened_wals)
.schema_config_provider(provider)
.forward_config(self.server_config.forward)
.timeout(self.server_config.timeout.map(|v| v.0))
.auto_create_table(self.server_config.auto_create_table)
.build()
.context(BuildGrpcService)?;
let rpc_services =
grpc::Builder::new()
.endpoint(
Endpoint::new(self.server_config.bind_addr, self.server_config.grpc_port)
.to_string(),
)
.local_endpoint(
Endpoint::new(self.node_addr, self.server_config.grpc_port).to_string(),
)
.resp_compress_min_length(
self.server_config.resp_compress_min_length.as_byte() as usize
)
.runtimes(engine_runtimes)
.instance(instance.clone())
.router(router)
.cluster(self.cluster.clone())
.opened_wals(opened_wals)
.schema_config_provider(provider)
.forward_config(self.server_config.forward)
.timeout(self.server_config.timeout.map(|v| v.0))
.auto_create_table(self.server_config.auto_create_table)
.build()
.context(BuildGrpcService)?;

let server = Server {
http_service,
Expand Down

0 comments on commit 15b365b

Please sign in to comment.