Skip to content

Commit

Permalink
Fixed synchr. problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfeiferd committed Dec 20, 2024
1 parent 1baa13c commit 69cc745
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ protected void doMakeThis() {
}
}
store.fix();
set(new Database((KMerSortedArray<String>) store, wrapper.getTaxTree()));
set(new Database(store, wrapper.getTaxTree()));
if (getLogger().isTraceEnabled()) {
getLogger().trace("KMers moved: " + store.getKMersMoved());
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class KMerSortedArray<V extends Serializable> implements KMerStore<V> {
private boolean useFilter;
private Object2LongMap<V> kmerPersTaxid;

private transient long kmersMoved;

public KMerSortedArray(int k, double fpp, List<V> initialValues, boolean enforceLarge) {
this(k, fpp, initialValues, enforceLarge, new MurmurCGATBloomFilter(k, fpp));
}
Expand All @@ -100,6 +102,11 @@ protected KMerSortedArray(int k, double fpp, List<V> initialValues, boolean enfo
this.filter = filter;
this.useFilter = filter != null;
this.kmerPersTaxid = null;
this.kmersMoved = 0;
}

public long getKMersMoved() {
return kmersMoved;
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -368,6 +375,7 @@ public boolean update(long kmer, UpdateValueProvider<V> provider) {
// This is important in the multi-threading context:
synchronized (valueMap) {
index = getAddValueIndex(newValue);
kmersMoved++;
}
if (largeKmers != null) {
BigArrays.set(largeValueIndexes, pos, index);
Expand Down

0 comments on commit 69cc745

Please sign in to comment.