Skip to content

Commit

Permalink
Store frame values as string
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikWin committed Jan 7, 2025
1 parent 714c072 commit 1aa3d3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions vidformer-igni/init/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CREATE TABLE spec_t (
pos INT NOT NULL,
t_numer BIGINT NOT NULL,
t_denom BIGINT NOT NULL,
frame JSONB,
frame TEXT,
PRIMARY KEY (spec_id, pos)
);

Expand Down Expand Up @@ -100,7 +100,7 @@ CREATE TABLE spec_part_staged_t (
in_part_pos INT NOT NULL,
t_numer BIGINT,
t_denom BIGINT,
frame JSONB,
frame TEXT,
PRIMARY KEY (spec_id, pos, in_part_pos),
FOREIGN KEY (spec_id, pos) REFERENCES spec_part_staged(spec_id, pos)
);
6 changes: 3 additions & 3 deletions vidformer-igni/src/server/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ pub(crate) async fn push_part(
let mut in_part_poss = Vec::with_capacity(req.frames.len());
let mut t_numers = Vec::with_capacity(req.frames.len());
let mut t_denoms = Vec::with_capacity(req.frames.len());
let mut frames: Vec<Option<serde_json::Value>> = Vec::with_capacity(req.frames.len());
let mut frames: Vec<Option<String>> = Vec::with_capacity(req.frames.len());
for (idx, ((numer, denom), frame)) in req.frames.iter().enumerate() {
in_part_poss.push(idx as i32);
t_numers.push(numer);
t_denoms.push(denom);
if let Some(expr) = frame {
frames.push(Some(serde_json::to_value(expr).unwrap()));
frames.push(Some(serde_json::to_string(expr).unwrap()));
} else {
frames.push(None);
}
Expand Down Expand Up @@ -446,7 +446,7 @@ pub(crate) async fn push_part(
.execute(&mut *transaction)
.await?;

sqlx::query("INSERT INTO spec_part_staged_t (spec_id, pos, in_part_pos, t_numer, t_denom, frame) VALUES (unnest($1::uuid[]), unnest($2::int[]), unnest($3::int[]), unnest($4::bigint[]), unnest($5::bigint[]), unnest($6::jsonb[]))")
sqlx::query("INSERT INTO spec_part_staged_t (spec_id, pos, in_part_pos, t_numer, t_denom, frame) VALUES (unnest($1::uuid[]), unnest($2::int[]), unnest($3::int[]), unnest($4::bigint[]), unnest($5::bigint[]), unnest($6::text[]))")
.bind(&spec_ids)
.bind(&pos)
.bind(&in_part_poss)
Expand Down
4 changes: 2 additions & 2 deletions vidformer-igni/src/server/vod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub(crate) async fn get_segment(
};

// Get the frames from spec_t that are in the segment (pos between first_t and last_t)
let rows: Vec<(i64, i64, serde_json::Value)> = sqlx::query_as(
let rows: Vec<(i64, i64, String)> = sqlx::query_as(
"SELECT t_numer, t_denom, frame FROM spec_t WHERE spec_id = $1 AND pos BETWEEN $2 AND $3",
)
.bind(spec_id)
Expand All @@ -251,7 +251,7 @@ pub(crate) async fn get_segment(
// Map json values to FrameExpr
let frames: Vec<vidformer::sir::FrameExpr> = rows
.iter()
.map(|(_, _, frame)| serde_json::from_value(frame.clone()).unwrap())
.map(|(_, _, frame)| serde_json::from_str(frame).unwrap())
.collect();

struct IgniSpec {
Expand Down

0 comments on commit 1aa3d3a

Please sign in to comment.