File pgvectorscale.spec of Package pgvectorscale

#
# spec file
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define         pg_name  @BUILD_FLAVOR@%{nil}
%define         ext_name   pgvectorscale
%{pg_version_from_name}

Version:        0.9.0
Release:        0
%if "%{pg_name}" == ""
ExclusiveArch:  do_not_build
Name:           %{ext_name}
%else
Name:           %{pg_name}-%{ext_name}
BuildRequires:  %{pg_name}-pgrx
%pg_server_requires
%endif

Summary:        A complement to pgvector for high performance, cost efficient vector search on large workloads
License:        PostgreSQL
Group:          Productivity/Databases/Tools
URL:            https://github.com/timescale/pgvectorscale
Source:         https://github.com/timescale/%{ext_name}/archive/refs/tags/v%{version}.tar.gz#/%{ext_name}-%{version}.tar.gz
Source1:        vendor.tar.zst
Source99:       _service
BuildRequires:  zstd
ExcludeArch:    %ix86 %arm
# BuildSystem:    pgrx
# BuildOption(install): --features=pg%{pg_version}
# BuildOption(prep): -a1
# BuildOption(prep): -n %{ext_name}-%{version}

%description
pgvectorscale complements pgvector, the open-source vector data extension for
PostgreSQL, and introduces the following key innovations for pgvector data:

- A new index type called StreamingDiskANN, inspired by the DiskANN algorithm,
  based on research from Microsoft.
- Statistical Binary Quantization: developed by Timescale researchers, This
  compression method improves on standard Binary Quantization.

On a benchmark dataset of 50 million Cohere embeddings with 768 dimensions
each, PostgreSQL with pgvector and pgvectorscale achieves 28x lower p95 latency
and 16x higher query throughput compared to Pinecone's storage optimized (s1)
index for approximate nearest neighbor queries at 99% recall, all at 75% less
cost when self-hosted on AWS EC2.

%prep
%autosetup -p1 -a1 -n %{ext_name}-%{version}

%build
%ifarch x86_64
export RUSTFLAGS="%build_rustflags -C target-feature=+avx2,+fma"
%endif

cd pgvectorscale

%pgrx_init

%install
%ifarch x86_64
export RUSTFLAGS="%build_rustflags -C target-feature=+avx2,+fma"
%endif

cd pgvectorscale
%pgrx_package --features=pg%{pg_version}

%files
%license LICENSE
%doc *.md
%{pg_config_pkglibdir}/vectorscale-%{version}.so
%{pg_config_sharedir}/extension/vectorscale*

%changelog
openSUSE Build Service is sponsored by