mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-30 03:30:49 +00:00
After schema reload, `target_parser::is_local()` did not recognize the
vector-index local target format `{"pk": [...], "tc": "..."}`, causing
local vector indexes to be treated as global. This broke duplicate
detection when both a global and a local vector index existed on the same
column. Fix by introducing `vector_index::is_local()` and dispatching
to it from `create_index_from_index_row()` based on the index class.
Also adds tests for local/global vector index coexistence.
Fixes: SCYLLADB-987
backport reasoning: we added local vector index support in 2026.1
Closes scylladb/scylladb#29492
* github.com:scylladb/scylladb:
test/cqlpy: add tests for global and local vector index coexistence
index: fix local vector index locality detection after schema reload
55 lines
2.2 KiB
C++
55 lines
2.2 KiB
C++
/*
|
|
* Copyright 2025-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.1
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "schema/schema.hh"
|
|
|
|
#include "data_dictionary/data_dictionary.hh"
|
|
#include "cql3/statements/index_target.hh"
|
|
#include "index/external_index.hh"
|
|
|
|
#include <vector>
|
|
|
|
namespace secondary_index {
|
|
|
|
class vector_index: public external_index {
|
|
public:
|
|
static constexpr std::string_view INDEX_TYPE_NAME = "vector";
|
|
static constexpr std::string_view SEARCH_TYPE_NAME = "Vector Search";
|
|
std::string_view index_type_name() const override { return INDEX_TYPE_NAME; }
|
|
|
|
vector_index() = default;
|
|
~vector_index() override = default;
|
|
std::optional<cql3::description> describe(const index_metadata& im, const schema& base_schema) const override;
|
|
void validate(const schema &schema, const cql3::statements::index_specific_prop_defs &properties,
|
|
const std::vector<::shared_ptr<cql3::statements::index_target>> &targets, const gms::feature_service& fs,
|
|
const data_dictionary::database& db) const override;
|
|
static bool has_index(const schema& s) { return has_index_impl<vector_index>(s); }
|
|
static bool is_local(const sstring& target_string);
|
|
static bool is_vector_index_on_column(const index_metadata& im, const sstring& target_name);
|
|
static void check_cdc_options(const schema& s) {
|
|
check_cdc_options_impl<vector_index>(s);
|
|
}
|
|
|
|
static sstring serialize_targets(const std::vector<::shared_ptr<cql3::statements::index_target>>& targets);
|
|
static sstring get_target_column(const sstring& targets);
|
|
|
|
static bool is_rescoring_enabled(const index_options_map& properties);
|
|
static float get_oversampling(const index_options_map& properties);
|
|
static sstring get_cql_similarity_function_name(const index_options_map& properties);
|
|
private:
|
|
void check_cdc_not_explicitly_disabled(const schema& schema) const;
|
|
void check_target(const schema& schema, const std::vector<::shared_ptr<cql3::statements::index_target>>& targets) const;
|
|
void check_key_column_count(const schema& schema) const;
|
|
void check_index_options(const cql3::statements::index_specific_prop_defs& properties) const;
|
|
};
|
|
|
|
std::unique_ptr<secondary_index::custom_index> vector_index_factory();
|
|
}
|