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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
*.iml
**/*.rs.bk
Cargo.lock
.env
pg_cron
test.sql

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "tembo"
name = "vectorize"
version = "0.0.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Dev pgrx settings
Required postgresql.conf settings

```
cron.database_name = 'tembo'
cron.database_name = 'vectorize'
```


Expand Down
2 changes: 1 addition & 1 deletion sql/meta.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE tembo_meta (
CREATE TABLE vectorize_meta (
job_id bigserial,
name TEXT NOT NULL UNIQUE,
job_type TEXT NOT NULL,
Expand Down
18 changes: 9 additions & 9 deletions src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use sqlx::types::chrono::Utc;
use sqlx::{FromRow, PgPool, Pool, Postgres, Row};

// schema for every job
// also schema for the tembo.tembo_meta table
// also schema for the vectorize.vectorize_meta table
#[derive(Clone, Debug, Deserialize, FromRow, Serialize)]
pub struct TemboMeta {
pub struct VectorizeMeta {
pub job_id: i64,
pub name: String,
pub job_type: types::JobType,
Expand All @@ -42,7 +42,7 @@ pub struct ColumnJobParams {
#[derive(Clone, Deserialize, Debug, Serialize)]
pub struct JobMessage {
pub job_name: String,
pub job_meta: TemboMeta,
pub job_meta: VectorizeMeta,
pub inputs: Vec<Inputs>,
}

Expand All @@ -66,7 +66,7 @@ fn job_execute(job_name: String) -> pgrx::JsonB {
let queue = pgmq::PGMQueueExt::new(db_url, 2)
.await
.expect("failed to init db connection");
let meta = get_tembo_meta(&job_name, conn)
let meta = get_vectorize_meta(&job_name, conn)
.await
.expect("failed to get job meta");
let job_params = serde_json::from_value::<ColumnJobParams>(meta.params.clone())
Expand Down Expand Up @@ -101,15 +101,15 @@ fn job_execute(job_name: String) -> pgrx::JsonB {
}

// get job meta
pub async fn get_tembo_meta(
pub async fn get_vectorize_meta(
job_name: &str,
conn: Pool<Postgres>,
) -> Result<TemboMeta, DatabaseError> {
) -> Result<VectorizeMeta, DatabaseError> {
let row = sqlx::query_as!(
TemboMeta,
VectorizeMeta,
"
SELECT *
FROM tembo.tembo_meta
FROM vectorize.vectorize_meta
WHERE name = $1
",
job_name.to_string(),
Expand Down Expand Up @@ -188,7 +188,7 @@ fn get_inputs_query(
WHERE {last_updated_col} >
(
SELECT last_completion
FROM tembo_meta
FROM vectorize_meta
WHERE name = '{job_name}'
)::timestamp
"
Expand Down
8 changes: 4 additions & 4 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
types::{self, Transformer},
};

pub const PGMQ_QUEUE_NAME: &str = "tembo_vectorize_queue";
pub const PGMQ_QUEUE_NAME: &str = "vectorize_queue";

#[pg_extern]
fn init_table(
Expand Down Expand Up @@ -92,10 +92,10 @@ fn init_pgmq() -> Result<(), spi::Error> {
fn init_job_query() -> String {
format!(
"
INSERT INTO {schema}.tembo_meta (name, job_type, transformer, search_alg, params)
INSERT INTO {schema}.vectorize_meta (name, job_type, transformer, search_alg, params)
VALUES ($1, $2, $3, $4, $5);
",
schema = types::TEMBO_SCHEMA
schema = types::VECTORIZE_SCHEMA
)
}

Expand All @@ -109,6 +109,6 @@ fn init_embedding_table(job_name: &str) -> String {
updated_at TIMESTAMP WITH TIME ZONE DEFAULT (now() at time zone 'utc') not null
);
",
schema = types::TEMBO_SCHEMA
schema = types::VECTORIZE_SCHEMA
)
}
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
use std::str::FromStr;

pub const TEMBO_SCHEMA: &str = "tembo";
pub const VECTORIZE_SCHEMA: &str = "vectorize";

#[allow(non_camel_case_types)]
#[derive(Clone, Debug, Serialize, Deserialize, PostgresEnum)]
Expand Down
4 changes: 2 additions & 2 deletions src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ use crate::executor::JobMessage;

#[pg_guard]
pub extern "C" fn _PG_init() {
BackgroundWorkerBuilder::new("PG Tembo Background Worker")
BackgroundWorkerBuilder::new("PG Vectorize Background Worker")
.set_function("background_worker_main")
.set_library("tembo")
.set_library("vectorize")
.enable_spi_access()
.load();
}
Expand Down
7 changes: 0 additions & 7 deletions tembo.control

This file was deleted.

7 changes: 7 additions & 0 deletions vectorize.control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
comment = 'Vector search in two functions'
default_version = '@CARGO_VERSION@'
module_pathname = '$libdir/vectorize'
relocatable = false
superuser = true
schema = 'vectorize'
requires = 'pg_cron,pgmq'