Skip to content

Commit

Permalink
refactor and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Jan 14, 2024
1 parent b866834 commit de83bdc
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 168 deletions.
4 changes: 2 additions & 2 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ function App() {
y: bytes,
}));

const journalCount = () => (sysRows().find(x => x.row_key === "wal#len")?.columns.value[""] ?? []).map(({ timestamp, value: { Byte: y } }) => ({
const journalCount = () => (sysRows().find(x => x.row_key === "wal#len")?.columns.value[""] ?? []).map(({ timestamp, value: { F64, Byte } }) => ({
x: new Date(timestamp / 1000 / 1000),
y,
y: Byte ?? F64, // NOTE: Byte has changed to F64
}));

const writeLatency = () => extractTimeseries(tableStatsMap(), "lat#write#batch");
Expand Down
21 changes: 4 additions & 17 deletions server/src/api/delete_row.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::app_state::AppState;
use crate::data_point;
use crate::error::CustomRouteResult;
use crate::identifier::is_valid_table_identifier;
use crate::response::build_response;
Expand All @@ -10,7 +11,7 @@ use actix_web::{
};
use serde::Deserialize;
use serde_json::json;
use smoltable::{CellValue, ColumnKey, ColumnWriteItem, RowWriteItem, TableWriter};
use smoltable::TableWriter;

#[derive(Debug, Deserialize)]
pub struct Input {
Expand Down Expand Up @@ -65,22 +66,8 @@ pub async fn handler(
TableWriter::write_batch(
table.metrics.clone(),
&[
RowWriteItem {
row_key: "lat#del#row".to_string(),
cells: vec![ColumnWriteItem {
column_key: ColumnKey::try_from("value").expect("should be column key"),
timestamp: None,
value: CellValue::F64(micros_total as f64),
}],
},
RowWriteItem {
row_key: "lat#del#cell".to_string(),
cells: vec![ColumnWriteItem {
column_key: ColumnKey::try_from("value").expect("should be column key"),
timestamp: None,
value: CellValue::F64(micros_per_item as f64),
}],
},
smoltable::row!("lat#del#row", vec![data_point!(micros_total as f64)]),
smoltable::row!("lat#del#cell", vec![data_point!(micros_per_item as f64)]),
],
)
.ok();
Expand Down
15 changes: 6 additions & 9 deletions server/src/api/get_rows.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::app_state::AppState;
use crate::data_point;
use crate::error::CustomRouteResult;
use crate::identifier::is_valid_table_identifier;
use crate::response::build_response;
Expand All @@ -10,7 +11,7 @@ use actix_web::{
};
use serde::{Deserialize, Serialize};
use serde_json::json;
use smoltable::{CellValue, ColumnKey, ColumnWriteItem, QueryRowInput, RowWriteItem, TableWriter};
use smoltable::{QueryRowInput, TableWriter};

#[derive(Debug, Deserialize, Serialize)]
struct Input {
Expand Down Expand Up @@ -62,14 +63,10 @@ pub async fn handler(

TableWriter::write_batch(
table.metrics.clone(),
&[RowWriteItem {
row_key: "lat#read#row".to_string(),
cells: vec![ColumnWriteItem {
column_key: ColumnKey::try_from("value").expect("should be column key"),
timestamp: None,
value: CellValue::F64(micros_per_row.unwrap_or_default() as f64),
}],
}],
&[smoltable::row!(
"lat#read#row",
vec![data_point!(micros_per_row.unwrap_or_default() as f64)]
)],
)
.ok();

Expand Down
17 changes: 6 additions & 11 deletions server/src/api/prefix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::app_state::AppState;
use crate::data_point;
use crate::error::CustomRouteResult;
use crate::identifier::is_valid_table_identifier;
use crate::response::build_response;
Expand All @@ -9,9 +10,7 @@ use actix_web::{
HttpResponse,
};
use serde_json::json;
use smoltable::{
CellValue, ColumnKey, ColumnWriteItem, QueryPrefixInput, RowWriteItem, TableWriter,
};
use smoltable::{QueryPrefixInput, TableWriter};

#[post("/v1/table/{name}/prefix")]
pub async fn handler(
Expand Down Expand Up @@ -58,14 +57,10 @@ pub async fn handler(

TableWriter::write_batch(
table.metrics.clone(),
&[RowWriteItem {
row_key: "lat#read#pfx".to_string(),
cells: vec![ColumnWriteItem {
column_key: ColumnKey::try_from("value").expect("should be column key"),
timestamp: None,
value: CellValue::F64(micros_total as f64),
}],
}],
&[smoltable::row!(
"lat#read#pfx",
vec![data_point!(micros_total as f64)]
)],
)
.ok();

Expand Down
21 changes: 4 additions & 17 deletions server/src/api/write.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::bad_request;
use crate::app_state::AppState;
use crate::data_point;
use crate::error::CustomRouteResult;
use crate::identifier::is_valid_table_identifier;
use crate::response::build_response;
Expand All @@ -11,7 +12,7 @@ use actix_web::{
};
use serde::Deserialize;
use serde_json::json;
use smoltable::{CellValue, ColumnKey, ColumnWriteItem, RowWriteItem, TableWriter};
use smoltable::{RowWriteItem, TableWriter};
use std::ops::Deref;

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -100,22 +101,8 @@ pub async fn handler(
TableWriter::write_batch(
table.metrics.clone(),
&[
RowWriteItem {
row_key: "lat#write#cell".to_string(),
cells: vec![ColumnWriteItem {
column_key: ColumnKey::try_from("value").expect("should be column key"),
timestamp: None,
value: CellValue::F64(micros_per_cell as f64),
}],
},
RowWriteItem {
row_key: "lat#write#batch".to_string(),
cells: vec![ColumnWriteItem {
column_key: ColumnKey::try_from("value").expect("should be column key"),
timestamp: None,
value: CellValue::F64(micros_total as f64),
}],
},
smoltable::row!("lat#write#cell", vec![data_point!(micros_per_cell as f64)]),
smoltable::row!("lat#write#batch", vec![data_point!(micros_total as f64)]),
],
)
.ok();
Expand Down
Loading

0 comments on commit de83bdc

Please sign in to comment.