Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
MssBenchmark/ann_benchmarks/algorithms/base.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (28 sloc)
885 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
import psutil | |
class BaseANN(object): | |
def done(self): | |
pass | |
def get_index_size(self, process): | |
"""Returns the size of the index in kB or -1 if not implemented.""" | |
return psutil.Process().memory_info().rss / 1024 # return in kB for backwards compatibility | |
def pre_fit(self, X): | |
pass | |
def fit(self, X): | |
pass | |
def pre_query(self, q, n): | |
pass | |
def query(self, q, n): | |
return [] # array of candidate indices | |
def post_query(self, rq=False): | |
pass | |
def pre_batch_query(self, X, n): | |
pass | |
def batch_query(self, X, n): | |
self.res = [] | |
for q in X: | |
self.res.append(self.query(q, n)) | |
def get_batch_results(self): | |
return self.res | |
def __str__(self): | |
return self.name |