forked from tensorchord/VectorChord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: usamoi <usamoi@outlook.com>
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
pub mod executing; | ||
pub mod prewarm; | ||
|
||
pub unsafe fn init() { | ||
unsafe { | ||
executing::init(); | ||
prewarm::init(); | ||
prewarm::prewarm(); | ||
#[cfg(any(feature = "pg12", feature = "pg13", feature = "pg14"))] | ||
pgrx::pg_sys::EmitWarningsOnPlaceholders(c"rabbithole".as_ptr()); | ||
#[cfg(any(feature = "pg15", feature = "pg16", feature = "pg17"))] | ||
pgrx::pg_sys::MarkGUCPrefixReserved(c"rabbithole".as_ptr()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use pgrx::guc::{GucContext, GucFlags, GucRegistry, GucSetting}; | ||
use std::ffi::CStr; | ||
|
||
static PREWARM_DIM: GucSetting<Option<&CStr>> = GucSetting::<Option<&CStr>>::new(None); | ||
|
||
pub unsafe fn init() { | ||
GucRegistry::define_string_guc( | ||
"rabbithole.prewarm_dim", | ||
"prewarm_dim when the extension is loading.", | ||
"prewarm_dim when the extension is loading.", | ||
&PREWARM_DIM, | ||
GucContext::Userset, | ||
GucFlags::default(), | ||
); | ||
} | ||
|
||
pub fn prewarm() { | ||
if let Some(prewarm_dim) = PREWARM_DIM.get() { | ||
if let Ok(prewarm_dim) = prewarm_dim.to_str() { | ||
for dim in prewarm_dim.split(',') { | ||
if let Ok(dim) = dim.trim().parse::<usize>() { | ||
crate::algorithm::rabitq::prewarm(dim as _); | ||
} else { | ||
pgrx::warning!("{dim:?} is not a valid integer"); | ||
} | ||
} | ||
} else { | ||
pgrx::warning!("rabbithole.prewarm_dim is not a valid UTF-8 string"); | ||
} | ||
} | ||
} |