Skip to content
Permalink
01adfa3b25
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
39 lines (28 sloc) 885 Bytes
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