Skip to content

Commit

Permalink
use ArcStr in Kafka offsets (#7747)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 54ca3575900bc5ee346d791ba3d49ad6a28daf79
  • Loading branch information
zxqfd555-pw authored and Manul from Pathway committed Nov 27, 2024
1 parent a59f42c commit 9cedbaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/connectors/data_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::sync::Arc;
use std::thread::sleep;
use std::time::{Duration, Instant, SystemTime};

use arcstr::ArcStr;
use chrono::DateTime;
use futures::StreamExt;
use itertools::Itertools;
Expand Down Expand Up @@ -767,7 +768,7 @@ impl Writer for FileWriter {
pub struct KafkaReader {
consumer: BaseConsumer<DefaultConsumerContext>,
persistent_id: Option<PersistentId>,
topic: Arc<String>,
topic: ArcStr,
positions_for_seek: HashMap<i32, KafkaOffset>,
}

Expand Down Expand Up @@ -830,7 +831,7 @@ impl Reader for KafkaReader {
if self.topic != *topic {
warn!(
"Unexpected topic name. Expected: {}, Got: {topic}",
*self.topic
self.topic
);
continue;
}
Expand Down Expand Up @@ -880,7 +881,7 @@ impl KafkaReader {
KafkaReader {
consumer,
persistent_id,
topic: Arc::new(topic),
topic: topic.into(),
positions_for_seek,
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::os::unix::ffi::OsStrExt;
use std::path::PathBuf;
use std::sync::Arc;

use arcstr::ArcStr;
use serde::{Deserialize, Serialize};
use xxhash_rust::xxh3::Xxh3 as Hasher;

Expand All @@ -12,7 +13,7 @@ use crate::engine::value::HashInto;
#[allow(clippy::module_name_repetitions)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Ord, PartialOrd)]
pub enum OffsetKey {
Kafka(Arc<String>, i32),
Kafka(ArcStr, i32),
Nats(usize),
Empty,
}
Expand Down

0 comments on commit 9cedbaa

Please sign in to comment.