lib/ngt/optimizer.rb in ngt-0.2.3 vs lib/ngt/optimizer.rb in ngt-0.2.4
- old
+ new
@@ -13,21 +13,27 @@
ObjectSpace.define_finalizer(self, self.class.finalize(@optimizer, @error))
end
def execute(in_index_path, out_index_path)
- ffi(:ngt_optimizer_execute, @optimizer, in_index_path, out_index_path)
+ ffi(:ngt_optimizer_execute, @optimizer, path(in_index_path), out_index_path)
end
def adjust_search_coefficients(index_path)
- ffi(:ngt_optimizer_adjust_search_coefficients, @optimizer, index_path)
+ ffi(:ngt_optimizer_adjust_search_coefficients, @optimizer, path(index_path))
end
def self.finalize(optimizer, error)
# must use proc instead of stabby lambda
proc do
FFI.ngt_destroy_optimizer(optimizer)
FFI.ngt_destroy_error_object(error)
end
+ end
+
+ private
+
+ def path(obj)
+ obj.is_a?(Ngt::Index) ? obj.path : obj
end
end
end