Skip to content

Commit

Permalink
Import Serial type, add fallback_row_id, and modify map functio…
Browse files Browse the repository at this point in the history
…n for `None` serial value.
  • Loading branch information
shanicky committed Oct 16, 2023
1 parent 1417842 commit 44e3ba4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common/src/hash/consistent_hash/vnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use parse_display::Display;
use crate::array::{Array, ArrayImpl, DataChunk};
use crate::hash::Crc32HashCode;
use crate::row::{Row, RowExt};
use crate::types::{DataType, ScalarRefImpl};
use crate::types::{DataType, ScalarRefImpl, Serial};
use crate::util::hash_util::Crc32FastBuilder;
use crate::util::row_id::extract_vnode_id_from_row_id;

Expand Down Expand Up @@ -119,9 +119,10 @@ impl VirtualNode {
if let Ok(idx) = keys.iter().exactly_one()
&& let ArrayImpl::Serial(serial_array) = &**data_chunk.column_at(*idx)
{
let fallback_row_id = Serial::from(rand::random::<i64>());
return serial_array
.iter()
.map(|serial| extract_vnode_id_from_row_id(serial.unwrap_or_default().as_row_id()))
.map(|serial| extract_vnode_id_from_row_id(serial.unwrap_or(fallback_row_id).as_row_id()))
.collect();
}

Expand Down

0 comments on commit 44e3ba4

Please sign in to comment.