Skip to content

Commit 4360cac

Browse files
authored
chore: remove prefilter, stand-alone-test and default feature (#505)
* chore: remove prefilter, stand-alone-test and default feature Signed-off-by: usamoi <usamoi@outlook.com> * fix: simplify hnsw entry Signed-off-by: usamoi <usamoi@outlook.com> --------- Signed-off-by: usamoi <usamoi@outlook.com>
1 parent 1a9e0b6 commit 4360cac

File tree

29 files changed

+127
-1208
lines changed

29 files changed

+127
-1208
lines changed

.github/workflows/psql.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ jobs:
9595
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV"
9696
- name: Build Release
9797
run: |
98-
cargo build --lib --no-default-features --features "pg$VERSION" --release
99-
./tools/schema.sh --no-default-features --features "pg$VERSION" --release | expand -t 4 > ./target/vectors--$SEMVER.sql
98+
cargo build --lib --features "pg$VERSION" --release
99+
./tools/schema.sh --features "pg$VERSION" --release | expand -t 4 > ./target/vectors--$SEMVER.sql
100100
- name: Set up PostgreSQL
101101
run: |
102102
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ jobs:
9292
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV"
9393
- name: Build
9494
run: |
95-
cargo build --lib --no-default-features --features pg$VERSION --release --target $ARCH-unknown-linux-gnu
96-
./tools/schema.sh --no-default-features --features pg$VERSION --release --target $ARCH-unknown-linux-gnu | expand -t 4 > ./target/vectors--$SEMVER.sql
95+
cargo build --lib --features pg$VERSION --release --target $ARCH-unknown-linux-gnu
96+
./tools/schema.sh --features pg$VERSION --release --target $ARCH-unknown-linux-gnu | expand -t 4 > ./target/vectors--$SEMVER.sql
9797
- name: Package
9898
run: |
9999
export PLATFORM=$(echo $ARCH | sed 's/aarch64/arm64/; s/x86_64/amd64/')

.github/workflows/rust.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ jobs:
9898
cp ./vendor/pgrx_binding/pg${VERSION}_$(uname --machine)-unknown-linux-gnu.rs ~/.pgrx_binding/pg${VERSION}_raw_bindings.rs
9999
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV"
100100
- name: Clippy
101-
run: cargo clippy --no-default-features --features "pg$VERSION" --target $ARCH-unknown-linux-gnu
101+
run: cargo clippy --features "pg$VERSION" --target $ARCH-unknown-linux-gnu
102102
- name: Build
103-
run: cargo build --lib --no-default-features --features "pg$VERSION" --target $ARCH-unknown-linux-gnu
103+
run: cargo build --lib --features "pg$VERSION" --target $ARCH-unknown-linux-gnu
104104
- name: Post Set up Cache
105105
uses: actions/cache/save@v4
106106
if: ${{ !steps.cache.outputs.cache-hit }}
@@ -163,14 +163,14 @@ jobs:
163163
cp ./vendor/pgrx_binding/pg${VERSION}_$(uname --machine)-unknown-linux-gnu.rs ~/.pgrx_binding/pg${VERSION}_raw_bindings.rs
164164
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV"
165165
- name: Test
166-
run: cargo test --all --no-fail-fast --no-default-features --features "pg$VERSION" --target $ARCH-unknown-linux-gnu -- --nocapture
166+
run: cargo test --all --no-fail-fast --features "pg$VERSION" --target $ARCH-unknown-linux-gnu -- --nocapture
167167
- name: Test (x86_64)
168168
if: matrix.arch == 'x86_64'
169169
run: |
170170
ASSETS=$(mktemp -d)
171171
wget https://downloadmirror.intel.com/813591/sde-external-9.33.0-2024-01-07-lin.tar.xz -O $ASSETS/sde-external.tar.xz
172172
tar -xf $ASSETS/sde-external.tar.xz -C $ASSETS
173-
cargo --config "target.x86_64-unknown-linux-gnu.runner = [\"$ASSETS/sde-external-9.33.0-2024-01-07-lin/sde64\", \"-spr\", \"--\"]" test "_v4" --all --no-fail-fast --no-default-features --features "pg$VERSION" --target $ARCH-unknown-linux-gnu -- --nocapture
173+
cargo --config "target.x86_64-unknown-linux-gnu.runner = [\"$ASSETS/sde-external-9.33.0-2024-01-07-lin/sde64\", \"-spr\", \"--\"]" test "_v4" --all --no-fail-fast --features "pg$VERSION" --target $ARCH-unknown-linux-gnu -- --nocapture
174174
- name: Post Set up Cache
175175
uses: actions/cache/save@v4
176176
if: ${{ !steps.cache.outputs.cache-hit }}

Cargo.lock

-61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ name = "pgrx_embed_vectors"
1111
path = "./src/bin/pgrx_embed.rs"
1212

1313
[features]
14-
default = ["pg15"]
14+
default = []
1515
pg14 = ["pgrx/pg14"]
1616
pg15 = ["pgrx/pg15"]
1717
pg16 = ["pgrx/pg16"]

crates/base/src/index.rs

-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ impl Default for ProductQuantizationOptionsRatio {
495495

496496
#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
497497
pub struct SearchOptions {
498-
pub prefilter_enable: bool,
499498
#[validate(range(min = 1, max = 65535))]
500499
pub hnsw_ef_search: u32,
501500
#[validate(range(min = 1, max = 1_000_000))]

crates/base/src/search.rs

-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ pub struct Element {
7474
pub payload: Payload,
7575
}
7676

77-
pub trait Filter: Clone {
78-
fn check(&mut self, payload: Payload) -> bool;
79-
}
80-
8177
pub trait Collection<O: Operator> {
8278
fn dims(&self) -> u32;
8379
fn len(&self) -> u32;

crates/base/src/worker.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,18 @@ pub trait WorkerOperations {
2828
}
2929

3030
pub trait ViewBasicOperations {
31-
fn basic<'a, F: Fn(Pointer) -> bool + Clone + 'a>(
31+
fn basic<'a>(
3232
&'a self,
3333
vector: &'a OwnedVector,
3434
opts: &'a SearchOptions,
35-
filter: F,
3635
) -> Result<Box<dyn Iterator<Item = Pointer> + 'a>, BasicError>;
3736
}
3837

3938
pub trait ViewVbaseOperations {
40-
fn vbase<'a, F: FnMut(Pointer) -> bool + Clone + 'a>(
39+
fn vbase<'a>(
4140
&'a self,
4241
vector: &'a OwnedVector,
4342
opts: &'a SearchOptions,
44-
filter: F,
4543
) -> Result<Box<dyn Iterator<Item = Pointer> + 'a>, VbaseError>;
4644
}
4745

crates/flat/src/lib.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,16 @@ impl<O: OperatorFlat> Flat<O> {
3939
&self,
4040
vector: Borrowed<'_, O>,
4141
_opts: &SearchOptions,
42-
filter: impl Filter,
4342
) -> BinaryHeap<Reverse<Element>> {
44-
basic(&self.mmap, vector, filter)
43+
basic(&self.mmap, vector)
4544
}
4645

4746
pub fn vbase<'a>(
4847
&'a self,
4948
vector: Borrowed<'a, O>,
5049
_opts: &'a SearchOptions,
51-
filter: impl Filter + 'a,
5250
) -> (Vec<Element>, Box<(dyn Iterator<Item = Element> + 'a)>) {
53-
vbase(&self.mmap, vector, filter)
51+
vbase(&self.mmap, vector)
5452
}
5553

5654
pub fn len(&self) -> u32 {
@@ -129,31 +127,25 @@ pub fn open<O: OperatorFlat>(path: &Path, options: IndexOptions) -> FlatMmap<O>
129127
pub fn basic<O: OperatorFlat>(
130128
mmap: &FlatMmap<O>,
131129
vector: Borrowed<'_, O>,
132-
mut filter: impl Filter,
133130
) -> BinaryHeap<Reverse<Element>> {
134131
let mut result = BinaryHeap::new();
135132
for i in 0..mmap.storage.len() {
136133
let distance = mmap.quantization.distance(vector, i);
137134
let payload = mmap.storage.payload(i);
138-
if filter.check(payload) {
139-
result.push(Reverse(Element { distance, payload }));
140-
}
135+
result.push(Reverse(Element { distance, payload }));
141136
}
142137
result
143138
}
144139

145140
pub fn vbase<'a, O: OperatorFlat>(
146141
mmap: &'a FlatMmap<O>,
147142
vector: Borrowed<'a, O>,
148-
mut filter: impl Filter + 'a,
149143
) -> (Vec<Element>, Box<dyn Iterator<Item = Element> + 'a>) {
150144
let mut result = Vec::new();
151145
for i in 0..mmap.storage.len() {
152146
let distance = mmap.quantization.distance(vector, i);
153147
let payload = mmap.storage.payload(i);
154-
if filter.check(payload) {
155-
result.push(Element { distance, payload });
156-
}
148+
result.push(Element { distance, payload });
157149
}
158150
(result, Box::new(std::iter::empty()))
159151
}

crates/hnsw/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name = "hnsw"
33
version.workspace = true
44
edition.workspace = true
55

6-
[features]
7-
stand-alone-test = []
8-
96
[dependencies]
107
bytemuck.workspace = true
118
parking_lot.workspace = true

0 commit comments

Comments
 (0)