From ca45ad28b913babefe9877245fe497abd3275b1c Mon Sep 17 00:00:00 2001 From: lmatz Date: Mon, 19 Jun 2023 19:59:29 +0800 Subject: [PATCH 1/2] fix(macro): support `derive(EstimateSize)` on tuple struct (#10318) (#10407) Signed-off-by: Richard Chien Co-authored-by: Richard Chien Co-authored-by: Yuhao Su <31772373+yuhao-su@users.noreply.github.com> --- src/common/proc_macro/src/lib.rs | 39 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/common/proc_macro/src/lib.rs b/src/common/proc_macro/src/lib.rs index 02fbe7b62db4b..0437efbc68817 100644 --- a/src/common/proc_macro/src/lib.rs +++ b/src/common/proc_macro/src/lib.rs @@ -194,19 +194,36 @@ pub fn derive_estimate_size(input: TokenStream) -> TokenStream { return gen.into(); } - let mut cmds = Vec::with_capacity(data_struct.fields.len()); + let mut field_cmds = Vec::with_capacity(data_struct.fields.len()); + + match data_struct.fields { + syn::Fields::Unnamed(unnamed_fields) => { + for (i, field) in unnamed_fields.unnamed.iter().enumerate() { + // Check if the value should be ignored. If so skip it. + if has_nested_flag_attribute_list(&field.attrs, "estimate_size", "ignore") { + continue; + } - for field in data_struct.fields.iter() { - // Check if the value should be ignored. If so skip it. - if has_nested_flag_attribute_list(&field.attrs, "estimate_size", "ignore") { - continue; + let idx = syn::Index::from(i); + field_cmds.push(quote! { + total += EstimateSize::estimated_heap_size(&self.#idx); + }) + } } + syn::Fields::Named(named_fields) => { + for field in named_fields.named.iter() { + // Check if the value should be ignored. If so skip it. + if has_nested_flag_attribute_list(&field.attrs, "estimate_size", "ignore") { + continue; + } - let ident = field.ident.as_ref().unwrap(); - - cmds.push(quote! { - total += &self.#ident.estimated_heap_size();; - }) + let field_ident = field.ident.as_ref().unwrap(); + field_cmds.push(quote! { + total += &self.#field_ident.estimated_heap_size(); + }) + } + } + syn::Fields::Unit => {} } // Build the trait implementation @@ -215,7 +232,7 @@ pub fn derive_estimate_size(input: TokenStream) -> TokenStream { fn estimated_heap_size(&self) -> usize { let mut total = 0; - #(#cmds)*; + #(#field_cmds)*; total } From 767cb48d07cdef0318b8b381394e9b1c277ebe7a Mon Sep 17 00:00:00 2001 From: Noel Kwan <47273164+kwannoel@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:28:25 +0800 Subject: [PATCH 2/2] fix(risedevtool): try download kafka from archive.apache if downloads.apache does not work (#10414) Co-authored-by: lmatz --- src/risedevtool/kafka.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/risedevtool/kafka.toml b/src/risedevtool/kafka.toml index d81a0e7eb37b1..88d2afab56311 100644 --- a/src/risedevtool/kafka.toml +++ b/src/risedevtool/kafka.toml @@ -5,7 +5,8 @@ KAFKA_DOWNLOAD_PATH = "${PREFIX_TMP}/kafka.tgz" KAFKA_VERSION = "3.4.1" KAFKA_SCALA_VERSION = "2.13" KAFKA_RELEASE = "kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}" -KAFKA_DOWNLOAD_TGZ = "https://dlcdn.apache.org/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz" +KAFKA_DOWNLOAD_RECENT_TGZ = "https://downloads.apache.org/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz" +KAFKA_DOWNLOAD_ARCHIVE_TGZ = "https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz" [tasks.download-kafka] category = "RiseDev - Components" @@ -19,7 +20,8 @@ if [ -d "${PREFIX_BIN}/kafka" ]; then exit 0 fi echo "Kafka not found, download ${KAFKA_RELEASE}" -curl -fL -o "${KAFKA_DOWNLOAD_PATH}" "${KAFKA_DOWNLOAD_TGZ}" +curl -fL -o "${KAFKA_DOWNLOAD_PATH}" "${KAFKA_DOWNLOAD_RECENT_TGZ}" \ + || curl -fL -o "${KAFKA_DOWNLOAD_PATH}" "${KAFKA_DOWNLOAD_ARCHIVE_TGZ}" tar -xf "${KAFKA_DOWNLOAD_PATH}" -C "${PREFIX_TMP}" mv "${PREFIX_TMP}/${KAFKA_RELEASE}" "${PREFIX_BIN}/kafka" rm ${KAFKA_DOWNLOAD_PATH}