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

Pushed down method & fields to increase coherence #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ public abstract int visitRightNode(
double weight
);

public void resetWithRequest(SalsaRequest incomingSalsaRequest) {
this.salsaRequest = incomingSalsaRequest;
}
}


public abstract static class WithRightNodeVisitor extends NodeVisitor {


public WithRightNodeVisitor(Long2ObjectMap<NodeInfo> visitedRightNodes) {
super(visitedRightNodes);
}

protected int simpleRightNodeVisitor(long rightNode) {
int numVisits = 1;
if (visitedRightNodes.containsKey(rightNode)) {
Expand All @@ -65,25 +78,25 @@ protected int simpleRightNodeVisitor(long rightNode) {
} else {
visitedRightNodes.put(rightNode,
new NodeInfo(
rightNode,
1.0,
salsaRequest.getMaxSocialProofTypeSize()
rightNode,
1.0,
salsaRequest.getMaxSocialProofTypeSize()
)
);
}
return numVisits;
}

public void resetWithRequest(SalsaRequest incomingSalsaRequest) {
this.salsaRequest = incomingSalsaRequest;
}

public abstract int visitRightNode(long leftNode, long rightNode, byte edgeType,
long metadata, double weight);
}

/**
* A simple visitor that just updates the visit counters and doesn't incorporate the starting
* point/weight info.
*/
public static class SimpleNodeVisitor extends NodeVisitor {
public static class SimpleNodeVisitor extends WithRightNodeVisitor {
public SimpleNodeVisitor(Long2ObjectMap<NodeInfo> visitedRightNodes) {
super(visitedRightNodes);
}
Expand Down Expand Up @@ -136,7 +149,7 @@ public int visitRightNode(
/**
* A visitor that both updates the visit counters and adds the starting point as social proof.
*/
public static class NodeVisitorWithSocialProof extends NodeVisitor {
public static class NodeVisitorWithSocialProof extends WithRightNodeVisitor {

public NodeVisitorWithSocialProof(Long2ObjectMap<NodeInfo> visitedRightNodes) {
super(visitedRightNodes);
Expand Down