Skip to content

Commit

Permalink
Performance improvements (#43)
Browse files Browse the repository at this point in the history
* 100% threshold optimisation

* test slice off

* .

* Revert "100% threshold optimisation"

This reverts commit 6297a8e.
  • Loading branch information
Phelimb authored Feb 2, 2019
1 parent 7e372c6 commit 26d0bfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bigsi/graph/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __kmers_to_hashes(self, kmers):
return d

def __batch_get_rows(self, row_indexes):
return dict(zip(row_indexes, self.bitmatrix.get_rows(row_indexes)))
return dict(zip(row_indexes, self.bitmatrix.get_rows(row_indexes, slice=False)))

def __bitwise_and_kmers(self, kmer_to_hashes, rows):
d = {}
Expand Down
9 changes: 7 additions & 2 deletions bigsi/matrix/bitmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ def create(cls, storage, rows, num_rows, num_cols):
def get_row(self, row_index):
return self.storage.get_bitarray(row_index)[: self.num_cols]

def get_rows(self, row_indexes):
def get_rows(self, row_indexes, slice=True):
## Only need to slice for merging (it's a lot slower)
# Takes advantage of batching in storage engine if available
return (ba[: self.num_cols] for ba in self.storage.get_bitarrays(row_indexes))
bitarrays=self.storage.get_bitarrays(row_indexes)
if slice:
return (ba[: self.num_cols] for ba in bitarrays)
else:
return bitarrays

def set_row(self, row_index, bitarray):
return self.storage.set_bitarray(row_index, bitarray)
Expand Down

0 comments on commit 26d0bfe

Please sign in to comment.