Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/actions/setup-build-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ runs:
test -e ~/.cargo/bin/rnr || cargo install rnr
test -e ~/.cargo/bin/cargo-nextest || cargo install cargo-nextest
test -e ~/.cargo/bin/cargo-binstall || cargo install cargo-binstall
test -e ~/.cargo/bin/dx || cargo binstall dioxus-cli -y
test -e ~/.cargo/bin/dx || cargo binstall dioxus-cli@0.7.0 -y
test -e ~/.cargo/bin/trunk || cargo install trunk --locked

- name: Install Python Build Dependencies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ pkg/
.VSCodeCounter/
*.pyc
venv/
python/probing/probing
19 changes: 10 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion probing/extensions/cc/src/extensions/taskstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod datasrc;
#[derive(Debug, Default, EngineExtension)]
pub struct TaskStatsExtension {
/// Task statistics collection interval in milliseconds (0 to disable)
#[option(aliases=["taskstats_interval"])]
#[option(aliases=["taskstats_interval", "task.stats.interval"])]
task_stats_interval: Maybe<i64>,
}

Expand Down
2 changes: 1 addition & 1 deletion probing/extensions/cc/src/extensions/taskstats/datasrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl CustomNamespace for TaskStatsSchema {
Field::new("cpu_utime", DataType::Int64, false),
Field::new("cpu_stime", DataType::Int64, false),
]))),
data: Default::default(),
data: Self::data(expr),
}),
_ => Arc::new(probing_core::core::LazyTableSource {
name: expr.to_string(),
Expand Down
120 changes: 120 additions & 0 deletions probing/proto/src/dto/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
use std::fmt::{Display, Formatter};
use std::time::{Duration, SystemTime};

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

/// Element type enumeration for DTO
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
pub enum EleType {
Nil,
BOOL,
I32,
I64,
F32,
F64,
Text,
Url,
DataTime,
}

/// Element value enumeration for DTO
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
pub enum Ele {
Nil,
BOOL(bool),
I32(i32),
I64(i64),
F32(f32),
F64(f64),
Text(String),
Url(String),
DataTime(u64),
}

impl Display for Ele {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Ele::Nil => f.write_str("nil"),
Ele::BOOL(x) => f.write_fmt(format_args!("{x}")),
Ele::I32(x) => f.write_fmt(format_args!("{x}")),
Ele::I64(x) => f.write_fmt(format_args!("{x}")),
Ele::F32(x) => f.write_fmt(format_args!("{x}")),
Ele::F64(x) => f.write_fmt(format_args!("{x}")),
Ele::Text(x) => f.write_fmt(format_args!("{x}")),
Ele::Url(x) => f.write_fmt(format_args!("{x}")),
Ele::DataTime(x) => {
let datetime: DateTime<Utc> =
(SystemTime::UNIX_EPOCH + Duration::from_micros(*x)).into();
f.write_fmt(format_args!("{}", datetime.to_rfc3339()))
}
}
}
}

/// Sequence of elements for DTO
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
#[serde(tag = "type", content = "value")]
pub enum Seq {
Nil,
SeqBOOL(Vec<bool>),
SeqI32(Vec<i32>),
SeqI64(Vec<i64>),
SeqF32(Vec<f32>),
SeqF64(Vec<f64>),
SeqText(Vec<String>),
SeqDateTime(Vec<u64>),
}

impl Seq {
pub fn len(&self) -> usize {
match self {
Seq::SeqBOOL(vec) => vec.len(),
Seq::SeqI32(vec) => vec.len(),
Seq::SeqI64(vec) => vec.len(),
Seq::SeqF32(vec) => vec.len(),
Seq::SeqF64(vec) => vec.len(),
Seq::SeqText(vec) => vec.len(),
Seq::SeqDateTime(vec) => vec.len(),
Seq::Nil => 0,
}
}

pub fn is_empty(&self) -> bool {
match self {
Seq::Nil => true,
other => other.len() == 0,
}
}

pub fn get(&self, idx: usize) -> Ele {
match self {
Seq::SeqBOOL(vec) => vec.get(idx).map(|x| Ele::BOOL(*x)),
Seq::SeqI32(vec) => vec.get(idx).map(|x| Ele::I32(*x)),
Seq::SeqI64(vec) => vec.get(idx).map(|x| Ele::I64(*x)),
Seq::SeqF32(vec) => vec.get(idx).map(|x| Ele::F32(*x)),
Seq::SeqF64(vec) => vec.get(idx).map(|x| Ele::F64(*x)),
Seq::SeqText(vec) => vec.get(idx).map(|x| Ele::Text(x.clone())),
Seq::SeqDateTime(vec) => vec.get(idx).map(|x| Ele::DataTime(*x)),
Seq::Nil => None,
}
.unwrap_or(Ele::Nil)
}
}

/// Value representation for DTO
#[derive(Debug, Default, Deserialize, Serialize, PartialEq, Eq, Clone)]
pub struct Value {
pub id: u64,
pub class: String,
pub shape: Option<String>,
pub dtype: Option<String>,
pub device: Option<String>,
pub value: Option<String>,
}

impl Display for Value {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "value: {:?}", self.value)
}
}
62 changes: 62 additions & 0 deletions probing/proto/src/dto/dataframe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use serde::{Deserialize, Serialize};

use super::basic::Seq;

/// Data frame structure for DTO
#[derive(Debug, Default, Deserialize, Serialize, PartialEq, Clone)]
pub struct DataFrame {
pub names: Vec<String>,
pub cols: Vec<Seq>,
pub size: u64,
}

impl DataFrame {
pub fn new(names: Vec<String>, columns: Vec<Seq>) -> Self {
DataFrame {
names,
cols: columns,
size: 0,
}
}

pub fn len(&self) -> usize {
if self.cols.is_empty() {
return 0;
}
self.cols[0].len()
}

#[must_use]
pub fn is_empty(&self) -> bool {
self.len() == 0
}

pub fn iter(&'_ self) -> DataFrameIterator<'_> {
DataFrameIterator {
df: self,
current: 0,
}
}
}

pub struct DataFrameIterator<'a> {
df: &'a DataFrame,
current: usize,
}

impl Iterator for DataFrameIterator<'_> {
type Item = Vec<super::basic::Ele>;

fn next(&mut self) -> Option<Self::Item> {
if self.current >= self.df.len() {
None
} else {
let mut row = vec![];
for i in 0..self.df.cols.len() {
row.push(self.df.cols[i].get(self.current));
}
self.current += 1;
Some(row)
}
}
}
5 changes: 5 additions & 0 deletions probing/proto/src/dto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! DTO (Data Transfer Object) modules
pub mod basic;
pub mod dataframe;
pub mod query;
pub mod time_series;
Loading
Loading