Skip to content
Closed
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions src/meta/api/src/kv_pb_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,15 @@ pub trait KVPbApi: KVApi {
Self::Error: From<PbApiReadError<Self::Error>>,
{
let it = keys.into_iter();
let key_chunks = it
let key_chunks: Vec<Vec<K>> = it
.chunks(Self::CHUNK_SIZE)
.into_iter()
.map(|x| x.collect::<Vec<_>>())
.collect::<Vec<_>>();
let total_keys: usize = key_chunks.iter().map(|c| c.len()).sum();

async move {
let mut res = vec![];
let mut res = Vec::with_capacity(total_keys);
for chunk in key_chunks {
let strm = self.get_pb_values(chunk).await?;

Expand Down Expand Up @@ -278,14 +279,15 @@ pub trait KVPbApi: KVApi {
Self::Error: From<PbApiReadError<Self::Error>>,
{
let it = keys.into_iter();
let key_chunks = it
let key_chunks: Vec<Vec<K>> = it
.chunks(Self::CHUNK_SIZE)
.into_iter()
.map(|x| x.collect::<Vec<_>>())
.collect::<Vec<_>>();
let total_keys: usize = key_chunks.iter().map(|c| c.len()).sum();

async move {
let mut res = vec![];
let mut res = Vec::with_capacity(total_keys);
for chunk in key_chunks {
let strm = self.get_pb_stream(chunk).await?;

Expand Down
13 changes: 11 additions & 2 deletions src/meta/kvapi/src/kvapi/key_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

//! A helper for building a string key from a structured key

use std::io::Write;

use crate::kvapi::helper::escape;
use crate::kvapi::helper::escape_specified;

Expand Down Expand Up @@ -46,8 +48,15 @@ impl KeyBuilder {
self.push_raw(&escape(s))
}

pub fn push_u64(self, n: u64) -> Self {
self.push_raw(&format!("{}", n))
pub fn push_u64(mut self, n: u64) -> Self {
if !self.buf.is_empty() {
// `/`
self.buf.push(0x2f);
}

// Write directly to buffer instead of allocating a string
write!(self.buf, "{}", n).unwrap();
self
}

pub fn done(self) -> String {
Expand Down
12 changes: 6 additions & 6 deletions src/query/ast/src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub fn display_parser_error(error: Error, source: &str) -> String {
format!("unexpected `{span_text}`")
};
if let Some(suggestion) = has_suggestion {
msg += &format!(". {}", suggestion);
write!(msg, ". {}", suggestion).unwrap();
labels = vec![(inner.span, msg)];

// Return early to skip context labels when we have intelligent suggestions
Expand All @@ -270,15 +270,15 @@ pub fn display_parser_error(error: Error, source: &str) -> String {
write!(msg, ", or {} more ...", more).unwrap();
break;
} else if i == 0 {
msg += ", expecting ";
msg.push_str(", expecting ");
} else if iter.peek().is_none() && i == 1 {
msg += " or ";
msg.push_str(" or ");
} else if iter.peek().is_none() {
msg += ", or ";
msg.push_str(", or ");
} else {
msg += ", ";
msg.push_str(", ");
}
msg += error;
msg.push_str(error);
}

labels = vec![(inner.span, msg)];
Expand Down
49 changes: 31 additions & 18 deletions src/query/sql/src/executor/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

use std::collections::HashMap;
use std::fmt::Write;

use databend_common_ast::ast::FormatTreeNode;
use databend_common_base::base::format_byte_size;
Expand Down Expand Up @@ -1788,59 +1789,69 @@ fn part_stats_info_to_format_tree(info: &PartStatistics) -> Vec<FormatTreeNode<S

// range pruning status.
if info.pruning_stats.blocks_range_pruning_before > 0 {
blocks_pruning_description += &format!(
write!(
blocks_pruning_description,
"range pruning: {} to {}",
info.pruning_stats.blocks_range_pruning_before,
info.pruning_stats.blocks_range_pruning_after
);
)
.unwrap();
}

// bloom pruning status.
if info.pruning_stats.blocks_bloom_pruning_before > 0 {
if !blocks_pruning_description.is_empty() {
blocks_pruning_description += ", ";
blocks_pruning_description.push_str(", ");
}
blocks_pruning_description += &format!(
write!(
blocks_pruning_description,
"bloom pruning: {} to {}",
info.pruning_stats.blocks_bloom_pruning_before,
info.pruning_stats.blocks_bloom_pruning_after
);
)
.unwrap();
}

// inverted index pruning status.
if info.pruning_stats.blocks_inverted_index_pruning_before > 0 {
if !blocks_pruning_description.is_empty() {
blocks_pruning_description += ", ";
blocks_pruning_description.push_str(", ");
}
blocks_pruning_description += &format!(
write!(
blocks_pruning_description,
"inverted pruning: {} to {}",
info.pruning_stats.blocks_inverted_index_pruning_before,
info.pruning_stats.blocks_inverted_index_pruning_after
);
)
.unwrap();
}

// topn pruning status.
if info.pruning_stats.blocks_topn_pruning_before > 0 {
if !blocks_pruning_description.is_empty() {
blocks_pruning_description += ", ";
blocks_pruning_description.push_str(", ");
}
blocks_pruning_description += &format!(
write!(
blocks_pruning_description,
"topn pruning: {} to {}",
info.pruning_stats.blocks_topn_pruning_before,
info.pruning_stats.blocks_topn_pruning_after
);
)
.unwrap();
}

// vector index pruning status.
if info.pruning_stats.blocks_vector_index_pruning_before > 0 {
if !blocks_pruning_description.is_empty() {
blocks_pruning_description += ", ";
blocks_pruning_description.push_str(", ");
}
blocks_pruning_description += &format!(
write!(
blocks_pruning_description,
"vector pruning: {} to {}",
info.pruning_stats.blocks_vector_index_pruning_before,
info.pruning_stats.blocks_vector_index_pruning_after
);
)
.unwrap();
}

// Combine segment pruning and blocks pruning descriptions if any
Expand All @@ -1850,18 +1861,20 @@ fn part_stats_info_to_format_tree(info: &PartStatistics) -> Vec<FormatTreeNode<S
let mut pruning_description = String::new();

if info.pruning_stats.segments_range_pruning_before > 0 {
pruning_description += &format!(
write!(
pruning_description,
"segments: <range pruning: {} to {}>",
info.pruning_stats.segments_range_pruning_before,
info.pruning_stats.segments_range_pruning_after
);
)
.unwrap();
}

if !blocks_pruning_description.is_empty() {
if !pruning_description.is_empty() {
pruning_description += ", ";
pruning_description.push_str(", ");
}
pruning_description += &format!("blocks: <{}>", blocks_pruning_description);
write!(pruning_description, "blocks: <{}>", blocks_pruning_description).unwrap();
}

items.push(FormatTreeNode::new(format!(
Expand Down
Loading