pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/DataDog/lading/pull/1708/files

ef="https://github.githubassets.com/assets/primer-primitives-ef1311e26457f1ec.css" /> feat(capture): flatten labels to top-level l_* columns by scottopell · Pull Request #1708 · DataDog/lading · GitHub
Skip to content
Draft
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
45 changes: 23 additions & 22 deletions lading_capture/src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ mod tests {
use crate::line::{Line, LineValue, MetricKind};
use approx::relative_eq;
use arrow_array::{
Array, BinaryArray, Float64Array, MapArray, StringArray, StructArray,
TimestampMillisecondArray, UInt64Array,
Array, BinaryArray, Float64Array, StringArray, TimestampMillisecondArray, UInt64Array,
};
use bytes::Bytes;
use datadog_protos::metrics::Dogsketch;
Expand Down Expand Up @@ -487,12 +486,23 @@ mod tests {
.downcast_ref::<Float64Array>()
.expect("value_float is Float64Array");

let labels_array = batch
.column_by_name("labels")
.expect("labels column")
.as_any()
.downcast_ref::<MapArray>()
.expect("labels is MapArray");
// Collect l_* columns for label extraction (new schema uses flat columns)
let schema = batch.schema();
let l_columns: Vec<(&str, &StringArray)> = schema
.fields()
.iter()
.filter_map(|field| {
let name = field.name();
if name.starts_with("l_") {
batch
.column_by_name(name)
.and_then(|c| c.as_any().downcast_ref::<StringArray>())
.map(|arr| (name.strip_prefix("l_").unwrap_or(name), arr))
} else {
None
}
})
.collect();

let value_histogram_array = batch
.column_by_name("value_histogram")
Expand Down Expand Up @@ -524,21 +534,12 @@ mod tests {
LineValue::Int(value_int_array.value(row_idx))
};

let labels_slice: StructArray = labels_array.value(row_idx);
let keys = labels_slice
.column(0)
.as_any()
.downcast_ref::<StringArray>()
.expect("label keys are strings");
let values = labels_slice
.column(1)
.as_any()
.downcast_ref::<StringArray>()
.expect("label values are strings");

// Extract labels from l_* columns
let mut labels = FxHashMap::default();
for i in 0..keys.len() {
labels.insert(keys.value(i).to_string(), values.value(i).to_string());
for (key, arr) in &l_columns {
if !arr.is_null(row_idx) {
labels.insert((*key).to_string(), arr.value(row_idx).to_string());
}
}

let value_histogram = if value_histogram_array.is_null(row_idx) {
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy