Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compact node manager #122

Merged
merged 1 commit into from
Jan 21, 2021
Merged

Conversation

jotok
Copy link
Collaborator

@jotok jotok commented Jan 15, 2021

Remove the CompactNodeManager class and move the functionality to `AbstractCompactRandomCutTree.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@sudiptoguha sudiptoguha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

In a previous revision, we introducted the CompactNodeManager class to
unify the handling of leaf nodes and internal nodes. The initial
implementation was a leaky abstraction, because the tree class was still
responsible for managing some node properties, like bounding boxes.
The change moves node management back into the tree class.
@jotok jotok marked this pull request as ready for review January 20, 2021 18:18
@jotok jotok added this to In progress in Random Cut Forest v2 via automation Jan 20, 2021
}

@Override
public void setParent(int index, int parent) {
parentIndex[index - super.capacity] = (short) parent;
parentIndex[index] = (short) parent;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question. we plan to eliminate unsafe type conversions in the code? if so, there is an issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will have a "large" node store/leafstore if the sampleSize is large (for large trees). Otherwise we have these small trees (but a large number of them). The trees always see int (irrespective of large/small size). The ILeafStore/INodeStore interfaces are int.


public AbstractCompactRandomCutTree(int maxSize, long seed, boolean enableCache, boolean enableCenterOfMass,
boolean enableSequenceIndices) {
super(seed, enableCache, enableCenterOfMass, enableSequenceIndices);
checkArgument(maxSize > 0, "maxSize must be greater than 0");
this.maxSize = maxSize;
nodeManager = new CompactNodeManager(maxSize);
leafStore = new LeafStore((short) maxSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remark. another type conversion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be an int (used just once in a constructor).

return getPointReference(intValue(node));
}

int getPointReference(int index) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the access level in this code base can be more consistent. For example,

  1. The interface of an object is public.
  2. Everything else should be private by default.
  3. If needed, protected is better than package since there is no reason to deny subclasses what is not private.

}

protected int incrementMass(int node) {
return isLeaf(node) ? leafStore.incrementMass(getLeafIndexForTreeIndex(node)) : nodeStore.incrementMass(node);
}

@Override
protected Integer getSibling(Integer node) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor. maybe the return type of the interface should be primitive since it's not nullable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getSibling is not nullable -- but the AbstractCompactTree can use either reference to Node or Integer ... so the non-primitive type came from the generics in AbstractCompactTree

@sudiptoguha sudiptoguha merged commit b619f17 into aws:compact-rcf Jan 21, 2021
Random Cut Forest v2 automation moved this from In progress to Done Jan 21, 2021
@jotok jotok deleted the remove-node-manager branch January 21, 2021 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants