Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #92 from myui/hotfixes
Browse files Browse the repository at this point in the history
Reduced object allocations
  • Loading branch information
myui committed Jul 31, 2014
2 parents b404bc6 + 753e123 commit 7073c7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/hivemall/common/RandomizedAmplifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void add(T storedObj) throws HiveException {
assert (replaced2 != null);
if(replaced1.timestamp >= replaced2.timestamp) {// bias to hold old entry
dropout(replaced1.object);
slot[rindex1] = new AgedObject<T>(storedObj);
replaced1.set(storedObj);
} else {
dropout(replaced2.object);
slot[rindex2] = new AgedObject<T>(storedObj);
replaced2.set(storedObj);
}
}
}
Expand Down Expand Up @@ -116,13 +116,18 @@ protected void dropout(T droppped) throws HiveException {

private static final class AgedObject<T> {

private final T object;
private final long timestamp;
private T object;
private long timestamp;

AgedObject(T obj) {
this.object = obj;
this.timestamp = System.nanoTime();
}

void set(T object) {
this.object = object;
this.timestamp = System.nanoTime();
}
}

public interface DropoutListener<T> {
Expand Down
Binary file modified target/hivemall.jar
Binary file not shown.

0 comments on commit 7073c7f

Please sign in to comment.