#NEWLINE# def lsh_instance( bits , dimensions , hashtables , storage_type ) : #NEWLINE# #INDENT# " Build an lsh instance using specified settings & storage method.\n\n    Params:\n        bits: n bitlength of hash key\n        dimentions: n features in each input point\n        hashtables: number of parallel hashtables to construct\n        storage_type: type of storage backend. one of:\n            'berkeleydb', 'leveldb', 'redis', 'dict'\n    " #NEWLINE# if ( storage_type == 'berkeleydb' ) : #NEWLINE# #INDENT# conf = { #NEWLINE# #INDENT# 'berkeleydb' : { #NEWLINE# #INDENT# 'filename' : './db' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( storage_type == 'leveldb' ) : #NEWLINE# #INDENT# conf = { #NEWLINE# #INDENT# 'leveldb' : { #NEWLINE# #INDENT# 'db' : 'ldb' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( bits == 'redis' ) : #NEWLINE# #INDENT# conf = { #NEWLINE# #INDENT# 'redis' : { #NEWLINE# #INDENT# 'host' : '127.0.0.1' , #NEWLINE# 'port' : 6379 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# conf = { #NEWLINE# #INDENT# 'dict' : None , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# lsh = LSH ( bits , dimensions , num_hashtables = hashtables , storage_config = conf ) #NEWLINE# return lsh