mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-13 22:36:57 +00:00
Merge branch 'feat/narthex-series-foundation' into feat/narthex-series-samples
Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,6 @@ pub mod samples;
|
||||
pub mod time;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "series/tests.rs"]
|
||||
mod tests;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -345,14 +345,15 @@ impl Default for HistogramBatchBuilder {
|
||||
impl HistogramBatchBuilder {
|
||||
/// Creates an empty builder.
|
||||
pub fn new() -> Self {
|
||||
// Avoid reserving Arrow's large default capacity for small histogram batches.
|
||||
Self {
|
||||
schema: Int32Builder::new(),
|
||||
threshold: Float64Builder::new(),
|
||||
sum: Float64Builder::new(),
|
||||
count: Float64Builder::new(),
|
||||
zero: Float64Builder::new(),
|
||||
hint: Int32Builder::new(),
|
||||
start: Int64Builder::new(),
|
||||
schema: Int32Builder::with_capacity(0),
|
||||
threshold: Float64Builder::with_capacity(0),
|
||||
sum: Float64Builder::with_capacity(0),
|
||||
count: Float64Builder::with_capacity(0),
|
||||
zero: Float64Builder::with_capacity(0),
|
||||
hint: Int32Builder::with_capacity(0),
|
||||
start: Int64Builder::with_capacity(0),
|
||||
custom: lb64(),
|
||||
po: lb32(),
|
||||
pl: lb32(),
|
||||
@@ -462,14 +463,14 @@ fn preflight(r: HistogramView<'_>, rows: usize, existing: [usize; 7]) -> Result<
|
||||
)
|
||||
}
|
||||
fn lb64() -> ListBuilder<Float64Builder> {
|
||||
ListBuilder::new(Float64Builder::new()).with_field(Arc::new(Field::new(
|
||||
ListBuilder::new(Float64Builder::with_capacity(0)).with_field(Arc::new(Field::new(
|
||||
"item",
|
||||
DataType::Float64,
|
||||
false,
|
||||
)))
|
||||
}
|
||||
fn lb32() -> ListBuilder<Int32Builder> {
|
||||
ListBuilder::new(Int32Builder::new()).with_field(Arc::new(Field::new(
|
||||
ListBuilder::new(Int32Builder::with_capacity(0)).with_field(Arc::new(Field::new(
|
||||
"item",
|
||||
DataType::Int32,
|
||||
false,
|
||||
@@ -489,5 +490,4 @@ fn append32(b: &mut ListBuilder<Int32Builder>, v: &[i32]) {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "histogram/tests.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -44,6 +44,16 @@ fn batch() -> Arc<HistogramBatch> {
|
||||
b.finish().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tiny_histogram_batch_does_not_retain_large_default_buffers() {
|
||||
let mut builder = HistogramBatchBuilder::new();
|
||||
builder.push(row(None, CounterResetHint::Unknown)).unwrap();
|
||||
let batch = builder.finish().unwrap();
|
||||
let retained = batch.as_arrow().get_buffer_memory_size();
|
||||
|
||||
assert!(retained < 4096, "retained {retained} bytes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builder_views_and_arrow_buffer_borrowing() {
|
||||
let empty = HistogramBatchBuilder::new();
|
||||
|
||||
@@ -54,7 +54,6 @@ fn metric_identity_uses_contents_and_distinguishes_absent_from_empty() {
|
||||
assert_eq!(one.get("empty"), Some(""));
|
||||
assert_eq!(one.get("missing"), None);
|
||||
assert_eq!(one.get("__name__"), Some("cpu"));
|
||||
assert_eq!(one.get("__name_missing"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -20,7 +20,6 @@ use snafu::OptionExt;
|
||||
use crate::error::{InvalidSeriesSnafu, Result};
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "time/tests.rs"]
|
||||
mod tests;
|
||||
|
||||
/// Value description of a non-empty, fixed-step evaluation grid.
|
||||
|
||||
Reference in New Issue
Block a user