| 38 | |
| 39 | template <typename dist_t> |
| 40 | class AlgorithmInterface { |
| 41 | public: |
| 42 | virtual bool |
| 43 | addPoint(const void* datapoint, LabelType label) = 0; |
| 44 | |
| 45 | virtual std::priority_queue<std::pair<dist_t, LabelType>> |
| 46 | searchKnn(const void* query_data, |
| 47 | size_t k, |
| 48 | size_t ef, |
| 49 | const vsag::FilterPtr is_id_allowed = nullptr, |
| 50 | float skip_ratio = 0.9f, |
| 51 | vsag::FilterSearchSkipStrategyType skip_strategy_type = |
| 52 | vsag::FilterSearchSkipStrategyType::DETERMINISTIC_ACCUMULATIVE, |
| 53 | vsag::Allocator* allocator = nullptr, |
| 54 | vsag::IteratorFilterContext* iter_ctx = nullptr, |
| 55 | bool is_last_filter = false) const = 0; |
| 56 | |
| 57 | virtual std::priority_queue<std::pair<dist_t, LabelType>> |
| 58 | searchRange(const void* query_data, |
| 59 | float radius, |
| 60 | size_t ef, |
| 61 | const vsag::FilterPtr is_id_allowed = nullptr) const = 0; |
| 62 | |
| 63 | // Return k nearest neighbor in the order of closer fist |
| 64 | virtual std::vector<std::pair<dist_t, LabelType>> |
| 65 | searchKnnCloserFirst(const void* query_data, |
| 66 | size_t k, |
| 67 | size_t ef, |
| 68 | const vsag::FilterPtr& is_id_allowed = nullptr) const; |
| 69 | |
| 70 | virtual void |
| 71 | saveIndex(StreamWriter& writer) = 0; |
| 72 | |
| 73 | virtual size_t |
| 74 | getMaxElements() = 0; |
| 75 | |
| 76 | virtual float |
| 77 | getDistanceByLabel(LabelType label, const void* data_point) = 0; |
| 78 | |
| 79 | virtual float |
| 80 | getDistanceByInternalId(uint32_t internal_id, const void* data_point) { |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | virtual float |
| 85 | getSelfDistanceByInternalId(uint32_t internal_id) { |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | virtual tl::expected<vsag::DatasetPtr, vsag::Error> |
| 90 | getBatchDistanceByLabel(const int64_t* ids, const void* data_point, int64_t count) = 0; |
| 91 | |
| 92 | virtual std::pair<int64_t, int64_t> |
| 93 | getMinAndMaxId() = 0; |
| 94 | |
| 95 | virtual const float* |
| 96 | getDataByLabel(LabelType label) const = 0; |
| 97 |
nothing calls this directly
no outgoing calls
no test coverage detected