mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-22 07:42:16 +00:00
Move `validate_enumerated_option`, `validate_positive_option`, and `validate_factor_option` into shared index option utilities under the `secondary_index::util` namespace. These functions were previously defined as file-local statics in `vector_index.cc` with hardcoded index names in error messages. The shared versions take `index_type_name` as a parameter, allowing each `custom_index` subclass to pass its own name via the virtual `index_type_name()` method at the call site. The options maps use `std::bind_front` to bind config params (supported values, limits), leaving `index_name` as the first unbound argument passed by `check_index_options()`. Add `index_type_name()` as a pure virtual method on `custom_index`. Move the shared utility implementations into `index_option_utils.cc` and update `vector_index.cc` to use them.
57 lines
2.4 KiB
C++
57 lines
2.4 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/secondary_index_manager.hh"
|
|
|
|
#include <vector>
|
|
|
|
namespace secondary_index {
|
|
|
|
class vector_index: public custom_index {
|
|
public:
|
|
std::string_view index_type_name() const override { return "vector"; }
|
|
|
|
// The minimal TTL for the CDC used by Vector Search.
|
|
// Required to ensure that the data is not deleted until the vector index is fully built.
|
|
static constexpr int VS_TTL_SECONDS = 86400; // 24 hours
|
|
|
|
vector_index() = default;
|
|
~vector_index() override = default;
|
|
std::optional<cql3::description> describe(const index_metadata& im, const schema& base_schema) const override;
|
|
bool view_should_exist() 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;
|
|
utils::UUID index_version(const schema& schema) override;
|
|
static bool has_vector_index(const schema& s);
|
|
static bool has_vector_index_on_column(const schema& s, const sstring& target_name);
|
|
static bool is_vector_index_on_column(const index_metadata& im, const sstring& target_name);
|
|
static void check_cdc_options(const schema& schema);
|
|
|
|
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_uses_tablets(const schema& schema, const data_dictionary::database& db) const;
|
|
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_index_options(const cql3::statements::index_specific_prop_defs& properties) const;
|
|
};
|
|
|
|
std::unique_ptr<secondary_index::custom_index> vector_index_factory();
|
|
}
|