8000 feat: max_scan_tuples by usamoi · Pull Request #94 · tensorchord/VectorChord · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: max_scan_tuples #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2024
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
20 changes: 20 additions & 0 deletions src/gucs/executing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::ffi::CStr;

static PROBES: GucSetting<Option<&'static CStr>> = GucSetting::<Option<&CStr>>::new(Some(c"10"));
static EPSILON: GucSetting<f64> = GucSetting::<f64>::new(1.9);
static MAX_SCAN_TUPLES: GucSetting<i32> = GucSetting::<i32>::new(-1);

pub unsafe fn init() {
GucRegistry::define_string_guc(
Expand All @@ -23,6 +24,16 @@ pub unsafe fn init() {
GucContext::Userset,
GucFlags::default(),
);
GucRegistry::define_int_guc(
"vchordrq.max_scan_tuples",
"`max_scan_tuples` argument of vchordrq.",
"`max_scan_tuples` argument of vchordrq.",
&MAX_SCAN_TUPLES,
-1,
u16::MAX as _,
GucContext::Userset,
GucFlags::default(),
);
}

pub fn probes() -> Vec<u32> {
Expand Down Expand Up @@ -54,3 +65,12 @@ pub fn probes() -> Vec<u32> {
pub fn epsilon() -> f32 {
EPSILON.get() as f32
}

pub fn max_scan_tuples() -> Option<u32> {
let x = MAX_SCAN_TUPLES.get();
if x < 0 {
None
} else {
Some(x as u32)
}
}
7 changes: 6 additions & 1 deletion src/index/am_scan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::am_options::Opfamily;
use crate::algorithm::scan::scan;
use crate::gucs::executing::epsilon;
use crate::gucs::executing::max_scan_tuples;
use crate::gucs::executing::probes;
use crate::postgres::Relation;
use base::distance::Distance;
Expand Down Expand Up @@ -86,7 +87,11 @@ pub fn scan_next(scanner: &mut Scanner, relation: Relation) -> Option<(Pointer,
epsilon(),
);
*scanner = Scanner::Vbase {
vbase: Box::new(vbase),
vbase: if let Some(max_scan_tuples) = max_scan_tuples() {
Box::new(vbase.take(max_scan_tuples as usize))
} else {
Box::new(vbase)
},
threshold: *threshold,
recheck: *recheck,
opfamily: *opfamily,
Expand Down
Loading
0