Skip to content

Commit

Permalink
Fixing Issue #271
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwangunasekara authored and hmgomes committed Jul 17, 2024
1 parent 5d37a09 commit 2a3b750
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions moa/src/main/java/moa/AbstractMOAObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public MOAObject copy() {
}

@Override
public int measureByteSize() {
public long measureByteSize() {
return measureByteSize(this);
}

Expand Down Expand Up @@ -73,7 +73,7 @@ public static MOAObject copy(MOAObject obj) {
* @param obj object to measure the memory size
* @return the memory size of this object
*/
public static int measureByteSize(MOAObject obj) {
return (int) SizeOf.fullSizeOf(obj);
public static long measureByteSize(MOAObject obj) {
return SizeOf.fullSizeOf(obj);
}
}
2 changes: 1 addition & 1 deletion moa/src/main/java/moa/MOAObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface MOAObject extends Serializable {
*
* @return the memory size of this object
*/
public int measureByteSize();
public long measureByteSize();

/**
* This method produces a copy of this object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ protected Classifier addToStored(Classifier newClassifier, double newClassifiers
*
* @return the size of the removed classifier.
*/
protected int removePoorestModelBytes() {
protected long removePoorestModelBytes() {
int poorestIndex = Utils.minIndex(this.ensembleWeights);
int byteSize = this.ensemble[poorestIndex].measureByteSize();
long byteSize = this.ensemble[poorestIndex].measureByteSize();
discardModel(poorestIndex);
return byteSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ public void discardModel(int index) {
this.ensembleWeights = newEnsembleWeights;
}

protected int removePoorestModelBytes() {
protected long removePoorestModelBytes() {
int poorestIndex = Utils.minIndex(this.ensembleWeights);
int byteSize = this.ensemble[poorestIndex].measureByteSize();
long byteSize = this.ensemble[poorestIndex].measureByteSize();
discardModel(poorestIndex);
return byteSize;
}
Expand Down
26 changes: 13 additions & 13 deletions moa/src/main/java/moa/classifiers/trees/EFDT.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,16 @@ public String getPurposeString() {
return "Hoeffding Tree or VFDT.";
}

public int calcByteSize() {
int size = (int) SizeOf.sizeOf(this);
public long calcByteSize() {
long size = SizeOf.sizeOf(this);
if (this.treeRoot != null) {
size += this.treeRoot.calcByteSizeIncludingSubtree();
}
return size;
}

@Override
public int measureByteSize() {
public long measureByteSize() {
return calcByteSize();
}

Expand Down Expand Up @@ -352,7 +352,7 @@ public void estimateModelByteSizes() {
this.inactiveLeafByteSizeEstimate = (double) totalInactiveSize
/ this.inactiveLeafNodeCount;
}
int actualModelSize = this.measureByteSize();
long actualModelSize = this.measureByteSize();
double estimatedModelSize = (this.activeLeafNodeCount
* this.activeLeafByteSizeEstimate + this.inactiveLeafNodeCount
* this.inactiveLeafByteSizeEstimate);
Expand Down Expand Up @@ -699,11 +699,11 @@ public void setInfogainSum(HashMap<Integer, Double> igs) {
infogainSum = igs;
}

public int calcByteSize() {
return (int) (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution));
public long calcByteSize() {
return (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution));
}

public int calcByteSizeIncludingSubtree() {
public long calcByteSizeIncludingSubtree() {
return calcByteSize();
}

Expand Down Expand Up @@ -769,14 +769,14 @@ public static class SplitNode extends Node {
protected AutoExpandVector<Node> children; // = new AutoExpandVector<Node>();

@Override
public int calcByteSize() {
public long calcByteSize() {
return super.calcByteSize()
+ (int) (SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest));
+ SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest);
}

@Override
public int calcByteSizeIncludingSubtree() {
int byteSize = calcByteSize();
public long calcByteSizeIncludingSubtree() {
long byteSize = calcByteSize();
for (Node child : this.children) {
if (child != null) {
byteSize += child.calcByteSizeIncludingSubtree();
Expand Down Expand Up @@ -1256,9 +1256,9 @@ public ActiveLearningNode(double[] initialClassObservations) {
}

@Override
public int calcByteSize() {
public long calcByteSize() {
return super.calcByteSize()
+ (int) (SizeOf.fullSizeOf(this.attributeObservers));
+ (SizeOf.fullSizeOf(this.attributeObservers));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public static class AdaSplitNode extends SplitNode implements NewNode {
// return ErrorChange;
//}
@Override
public int calcByteSizeIncludingSubtree() {
int byteSize = calcByteSize();
public long calcByteSizeIncludingSubtree() {
long byteSize = calcByteSize();
if (alternateTree != null) {
byteSize += alternateTree.calcByteSizeIncludingSubtree();
}
Expand Down Expand Up @@ -314,8 +314,8 @@ public static class AdaLearningNode extends LearningNodeNBAdaptive implements Ne
protected Random classifierRandom;

@Override
public int calcByteSize() {
int byteSize = super.calcByteSize();
public long calcByteSize() {
long byteSize = super.calcByteSize();
if (estimationErrorWeight != null) {
byteSize += estimationErrorWeight.measureByteSize();
}
Expand Down
26 changes: 13 additions & 13 deletions moa/src/main/java/moa/classifiers/trees/HoeffdingOptionTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ public Node(double[] classObservations) {
this.observedClassDistribution = new DoubleVector(classObservations);
}

public int calcByteSize() {
return (int) (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution));
public long calcByteSize() {
return SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution);
}

public int calcByteSizeIncludingSubtree() {
public long calcByteSizeIncludingSubtree() {
return calcByteSize();
}

Expand Down Expand Up @@ -290,14 +290,14 @@ public static class SplitNode extends Node {
protected AutoExpandVector<Node> children = new AutoExpandVector<Node>();

@Override
public int calcByteSize() {
public long calcByteSize() {
return super.calcByteSize()
+ (int) (SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest));
+ SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest);
}

@Override
public int calcByteSizeIncludingSubtree() {
int byteSize = calcByteSize();
public long calcByteSizeIncludingSubtree() {
long byteSize = calcByteSize();
for (Node child : this.children) {
if (child != null) {
byteSize += child.calcByteSizeIncludingSubtree();
Expand Down Expand Up @@ -539,9 +539,9 @@ public ActiveLearningNode(double[] initialClassObservations) {
}

@Override
public int calcByteSize() {
public long calcByteSize() {
return super.calcByteSize()
+ (int) (SizeOf.fullSizeOf(this.attributeObservers));
+ SizeOf.fullSizeOf(this.attributeObservers);
}

@Override
Expand Down Expand Up @@ -617,16 +617,16 @@ public void disableAttribute(int attIndex) {

protected int maxPredictionPaths;

public int calcByteSize() {
int size = (int) SizeOf.sizeOf(this);
public long calcByteSize() {
long size = SizeOf.sizeOf(this);
if (this.treeRoot != null) {
size += this.treeRoot.calcByteSizeIncludingSubtree();
}
return size;
}

@Override
public int measureByteSize() {
public long measureByteSize() {
return calcByteSize();
}

Expand Down Expand Up @@ -1040,7 +1040,7 @@ public void estimateModelByteSizes() {
this.inactiveLeafByteSizeEstimate = (double) totalInactiveSize
/ this.inactiveLeafNodeCount;
}
int actualModelSize = this.measureByteSize();
long actualModelSize = this.measureByteSize();
double estimatedModelSize = (this.activeLeafNodeCount
* this.activeLeafByteSizeEstimate + this.inactiveLeafNodeCount
* this.inactiveLeafByteSizeEstimate);
Expand Down
26 changes: 13 additions & 13 deletions moa/src/main/java/moa/classifiers/trees/HoeffdingTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ public Node(double[] classObservations) {
this.observedClassDistribution = new DoubleVector(classObservations);
}

public int calcByteSize() {
return (int) (SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution));
public long calcByteSize() {
return SizeOf.sizeOf(this) + SizeOf.fullSizeOf(this.observedClassDistribution);
}

public int calcByteSizeIncludingSubtree() {
public long calcByteSizeIncludingSubtree() {
return calcByteSize();
}

Expand Down Expand Up @@ -262,14 +262,14 @@ public static class SplitNode extends Node {
protected AutoExpandVector<Node> children; // = new AutoExpandVector<Node>();

@Override
public int calcByteSize() {
public long calcByteSize() {
return super.calcByteSize()
+ (int) (SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest));
+ SizeOf.sizeOf(this.children) + SizeOf.fullSizeOf(this.splitTest);
}

@Override
public int calcByteSizeIncludingSubtree() {
int byteSize = calcByteSize();
public long calcByteSizeIncludingSubtree() {
long byteSize = calcByteSize();
for (Node child : this.children) {
if (child != null) {
byteSize += child.calcByteSizeIncludingSubtree();
Expand Down Expand Up @@ -429,9 +429,9 @@ public ActiveLearningNode(double[] initialClassObservations) {
}

@Override
public int calcByteSize() {
public long calcByteSize() {
return super.calcByteSize()
+ (int) (SizeOf.fullSizeOf(this.attributeObservers));
+ SizeOf.fullSizeOf(this.attributeObservers);
}

@Override
Expand Down Expand Up @@ -511,8 +511,8 @@ public void disableAttribute(int attIndex) {

protected boolean growthAllowed;

public int calcByteSize() {
int size = (int) SizeOf.sizeOf(this);
public long calcByteSize() {
long size = SizeOf.sizeOf(this);
if (this.treeRoot != null) {
size += this.treeRoot.calcByteSizeIncludingSubtree();
}
Expand All @@ -528,7 +528,7 @@ public Node getTreeRoot() {
}

@Override
public int measureByteSize() {
public long measureByteSize() {
return calcByteSize();
}

Expand Down Expand Up @@ -804,7 +804,7 @@ public void estimateModelByteSizes() {
this.inactiveLeafByteSizeEstimate = (double) totalInactiveSize
/ this.inactiveLeafNodeCount;
}
int actualModelSize = this.measureByteSize();
long actualModelSize = this.measureByteSize();
double estimatedModelSize = (this.activeLeafNodeCount
* this.activeLeafByteSizeEstimate + this.inactiveLeafNodeCount
* this.inactiveLeafByteSizeEstimate);
Expand Down
2 changes: 1 addition & 1 deletion moa/src/main/java/moa/core/AutoExpandVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public MOAObject copy() {
}

@Override
public int measureByteSize() {
public long measureByteSize() {
return AbstractMOAObject.measureByteSize(this);
}

Expand Down

0 comments on commit 2a3b750

Please sign in to comment.