From d67a8743ba962dc1ae4456fa68ceebc16e202ee5 Mon Sep 17 00:00:00 2001 From: LuQQiu Date: Fri, 2 Jan 2026 15:35:33 -0800 Subject: [PATCH] feat: support remote ivf rq (#2863) --- python/python/lancedb/remote/table.py | 21 +++++++++++++++++++-- rust/lancedb/src/remote/table.rs | 11 +++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/python/python/lancedb/remote/table.py b/python/python/lancedb/remote/table.py index c97199e4..7961995c 100644 --- a/python/python/lancedb/remote/table.py +++ b/python/python/lancedb/remote/table.py @@ -18,7 +18,17 @@ from lancedb._lancedb import ( UpdateResult, ) from lancedb.embeddings.base import EmbeddingFunctionConfig -from lancedb.index import FTS, BTree, Bitmap, HnswSq, IvfFlat, IvfPq, IvfSq, LabelList +from lancedb.index import ( + FTS, + BTree, + Bitmap, + HnswSq, + IvfFlat, + IvfPq, + IvfRq, + IvfSq, + LabelList, +) from lancedb.remote.db import LOOP import pyarrow as pa @@ -265,6 +275,12 @@ class RemoteTable(Table): num_sub_vectors=num_sub_vectors, num_bits=num_bits, ) + elif index_type == "IVF_RQ": + config = IvfRq( + distance_type=metric, + num_partitions=num_partitions, + num_bits=num_bits, + ) elif index_type == "IVF_SQ": config = IvfSq(distance_type=metric, num_partitions=num_partitions) elif index_type == "IVF_HNSW_PQ": @@ -279,7 +295,8 @@ class RemoteTable(Table): else: raise ValueError( f"Unknown vector index type: {index_type}. Valid options are" - " 'IVF_FLAT', 'IVF_SQ', 'IVF_PQ', 'IVF_HNSW_PQ', 'IVF_HNSW_SQ'" + " 'IVF_FLAT', 'IVF_PQ', 'IVF_RQ', 'IVF_SQ'," + " 'IVF_HNSW_PQ', 'IVF_HNSW_SQ'" ) LOOP.run( diff --git a/rust/lancedb/src/remote/table.rs b/rust/lancedb/src/remote/table.rs index 5f62c69b..2a941144 100644 --- a/rust/lancedb/src/remote/table.rs +++ b/rust/lancedb/src/remote/table.rs @@ -1088,6 +1088,17 @@ impl BaseTable for RemoteTable { body["num_partitions"] = serde_json::Value::Number(num_partitions.into()); } } + Index::IvfRq(index) => { + body[INDEX_TYPE_KEY] = serde_json::Value::String("IVF_RQ".to_string()); + body[METRIC_TYPE_KEY] = + serde_json::Value::String(index.distance_type.to_string().to_lowercase()); + if let Some(num_partitions) = index.num_partitions { + body["num_partitions"] = serde_json::Value::Number(num_partitions.into()); + } + if let Some(num_bits) = index.num_bits { + body["num_bits"] = serde_json::Value::Number(num_bits.into()); + } + } Index::BTree(_) => { body[INDEX_TYPE_KEY] = serde_json::Value::String("BTREE".to_string()); }