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

fix: Align with the internal blockId config #33

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/id_layout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::grpc::protobuf::uniffle::BlockIdLayout;
use log::warn;
use once_cell::sync::Lazy;
use std::ops::Deref;

Expand All @@ -10,9 +11,10 @@ pub const DEFAULT_BLOCK_ID_LAYOUT: Lazy<IdLayout> = Lazy::new(|| {
)
});

const DEFAULT_SEQUENCE_NO_BIT: i32 = 18;
// todo: the default layout should be configured by options
const DEFAULT_SEQUENCE_NO_BIT: i32 = 16;
const DEFAULT_PARTITION_ID_BIT: i32 = 24;
const DEFAULT_TASK_ID_BIT: i32 = 21;
const DEFAULT_TASK_ID_BIT: i32 = 23;

#[derive(Debug, Clone)]
pub struct IdLayout {
Expand Down Expand Up @@ -61,12 +63,20 @@ impl From<&BlockIdLayout> for IdLayout {

pub fn to_layout(layout: Option<BlockIdLayout>) -> IdLayout {
if let Some(block_id_layout) = layout {
if block_id_layout.sequence_no_bits != DEFAULT_SEQUENCE_NO_BIT
|| block_id_layout.partition_id_bits != DEFAULT_PARTITION_ID_BIT
|| block_id_layout.task_attempt_id_bits != DEFAULT_TASK_ID_BIT
{
warn!("This should not happen that client blockId layout is not expected. sequence: {}, partition: {}. task: {}",
block_id_layout.sequence_no_bits, block_id_layout.partition_id_bits, block_id_layout.task_attempt_id_bits);
}
IdLayout::new(
block_id_layout.sequence_no_bits,
block_id_layout.partition_id_bits,
block_id_layout.task_attempt_id_bits,
)
} else {
warn!("This should not happen that client blockId layout is missing and using the default block id layout!");
IdLayout::new(
DEFAULT_SEQUENCE_NO_BIT,
DEFAULT_PARTITION_ID_BIT,
Expand Down
Loading