class AnndbApi::Dataset
Public Instance Methods
delete(id)
click to toggle source
# File lib/anndb_api/dataset.rb, line 9 def delete(id) format_dataset_op_result_single @stub.delete(AnndbApiPb::DeleteRequest.new(ids: [ AnndbApiPb::UUID.new(data: AnndbApi::Util.uuid_string_to_bytes(id)) ]), { metadata: @rpc_metadata }) end
delete_batch(ids)
click to toggle source
# File lib/anndb_api/dataset.rb, line 15 def delete_batch(ids) format_dataset_op_result @stub.delete(AnndbApiPb::DeleteRequest.new(ids: ids.map { |id| AnndbApiPb::UUID.new(data: AnndbApi::Util.uuid_string_to_bytes(id)) }), { metadata: @rpc_metadata }) end
Protected Instance Methods
format_dataset_op_result(result)
click to toggle source
# File lib/anndb_api/dataset.rb, line 32 def format_dataset_op_result(result) (0..result.ids.length-1).map { |i| { id: AnndbApi::Util.ascii8bit_to_uuid(result.ids[i].data), error: result.errors[i].message } } end
format_dataset_op_result_single(result)
click to toggle source
# File lib/anndb_api/dataset.rb, line 41 def format_dataset_op_result_single(result) error = result.errors.first.message if error.length > 0 raise AnndbApi::DatasetOpError.new(error) end AnndbApi::Util.ascii8bit_to_uuid(result.ids.first.data) end
format_req_metadata(metadata)
click to toggle source
# File lib/anndb_api/dataset.rb, line 50 def format_req_metadata(metadata) metadata.collect{ |k, v| [k.to_s, v] }.to_h end
format_search_result(result)
click to toggle source
# File lib/anndb_api/dataset.rb, line 23 def format_search_result(result) result.items.map { |item| { id: AnndbApi::Util.ascii8bit_to_uuid(item.id), metadata: item.metadata } } end