Skip to content

Commit

Permalink
remove add_target function
Browse files Browse the repository at this point in the history
  • Loading branch information
Waylon Flinn committed Nov 17, 2015
1 parent 35d01a3 commit d42fbe4
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions bneighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,52 +103,3 @@ def location(self, source_id):
source_index = self.id_index_map[source_id]

return self.vectors[source_index]


def add_target(self, source_id):
'''
Add a new entry to the target table.
Args:
source_id: the external identifier for the entry (domain, primary key, etc)
Returns:
the index of the new entry in the table
this method needs to work like a transaction. nothing should be appended to the
target ctable while this thing runs.
'''

# TODO: fix this. broken my removal of target table

if not source_id in self.id_index_map:
# not in source
return -1

# this solution won't scale
if source_id in self.index_id_map.values():
# already a target
return -1

source_index = self.id_index_map[source_id]


# lock start
target_index = len(self.target_table)

# the slice hack is a workaround for a bug in append
self.target_table.append(self.source_table[source_index:source_index+1])

self.index_id_map[target_index] = source_id

# lock end

self.target_table.flush()

# repoen target vectors
self.target_vectors = bvec.carray(rootdir=self.target_path + "/vector")

# this breaks encapsulation, and should recreate the similarity object instead
self.similarity.target_carray = self.target_vectors

return target_index

0 comments on commit d42fbe4

Please sign in to comment.