All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
/tmp/faiss/IndexBinaryHNSW.h
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD+Patents license found in the
* LICENSE file in the root directory of this source tree.
*/
// -*- c++ -*-
#pragma once
#include "HNSW.h"
#include "IndexBinaryFlat.h"
#include "utils.h"
namespace faiss {
/** The HNSW index is a normal random-access index with a HNSW
* link structure built on top */
struct IndexBinaryHNSW : IndexBinary {
typedef HNSW::storage_idx_t storage_idx_t;
// the link strcuture
HNSW hnsw;
// the sequential storage
bool own_fields;
IndexBinary *storage;
explicit IndexBinaryHNSW();
explicit IndexBinaryHNSW(int d, int M = 32);
explicit IndexBinaryHNSW(IndexBinary *storage, int M = 32);
~IndexBinaryHNSW() override;
HNSW::DistanceComputer *get_distance_computer() const;
void add(idx_t n, const uint8_t *x) override;
/// Trains the storage if needed
void train(idx_t n, const uint8_t* x) override;
/// entry point for search
void search(idx_t n, const uint8_t *x, idx_t k,
int32_t *distances, idx_t *labels) const override;
void reconstruct(idx_t key, uint8_t* recons) const override;
void reset() override;
};
} // namespace faiss
faiss::IndexBinaryHNSW::add
void add(idx_t n, const uint8_t *x) override
Definition: IndexBinaryHNSW.cpp:227
faiss::IndexBinary::d
int d
vector dimension
Definition: IndexBinary.h:40
faiss::IndexBinaryHNSW::reconstruct
void reconstruct(idx_t key, uint8_t *recons) const override
Definition: IndexBinaryHNSW.cpp:245
faiss::IndexBinaryHNSW
Definition: IndexBinaryHNSW.h:24
faiss::HNSW
Definition: HNSW.h:47
faiss::IndexBinaryHNSW::train
void train(idx_t n, const uint8_t *x) override
Trains the storage if needed.
Definition: IndexBinaryHNSW.cpp:192
faiss::IndexBinary
Definition: IndexBinary.h:37
faiss::IndexBinary::idx_t
long idx_t
all indices are this type
Definition: IndexBinary.h:38
faiss::IndexBinaryHNSW::search
void search(idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels) const override
entry point for search
Definition: IndexBinaryHNSW.cpp:199
faiss::HNSW::storage_idx_t
int storage_idx_t
internal storage of vectors (32 bits: this is expensive)
Definition: HNSW.h:49
faiss::HNSW::DistanceComputer
Definition: HNSW.h:60
faiss::IndexBinaryHNSW::reset
void reset() override
Removes all elements from the database.
Definition: IndexBinaryHNSW.cpp:238