fresh-borzoni commented on code in PR #214: URL: https://github.com/apache/fluss-rust/pull/214#discussion_r2729695689
########## crates/fluss/src/util/partition.rs: ########## @@ -0,0 +1,532 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +/// Utils for partition. +use crate::error::Error::IllegalArgument; +use crate::error::Result; +use crate::metadata::DataType; +use crate::row::{Date, Datum, Time, TimestampLtz, TimestampNtz}; +use jiff::ToSpan; + +fn hex_string(bytes: &[u8]) -> String { Review Comment: nit: technically we can format into buffer directly: ```rust use std::fmt::Write; fn hex_string(bytes: &[u8]) -> String { let mut hex = String::with_capacity(bytes.len() * 2); for &b in bytes { write!(&mut hex, "{:02x}", b).unwrap(); } hex } ``` it would avoid allocation this way ########## crates/fluss/src/client/table/partition_getter.rs: ########## @@ -17,40 +17,186 @@ use crate::error::Error::IllegalArgument; use crate::error::Result; -use crate::metadata::{DataType, RowType}; +use crate::metadata::{DataType, ResolvedPartitionSpec, RowType}; +use crate::row::InternalRow; use crate::row::field_getter::FieldGetter; +use crate::util::partition; +/// A getter to get partition name from a row. #[allow(dead_code)] -pub struct PartitionGetter<'a> { - partitions: Vec<(&'a String, &'a DataType, FieldGetter)>, +pub struct PartitionGetter { + partition_keys: Vec<String>, Review Comment: I wonder if Arc[String] is better, this code is hot, here is makes sense. WDYT? Though it would require changes in other places. Perhaps it's better to handle in separate PR if we consider this worth it cc @luoyuxia as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
