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

Pulled the common field & method one hierarchy up #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -17,6 +17,7 @@

package com.twitter.graphjet.algorithms;

import it.unimi.dsi.fastutil.longs.Long2DoubleMap;
import it.unimi.dsi.fastutil.longs.LongSet;

/**
Expand All @@ -43,14 +44,18 @@ public abstract class RecommendationRequest {
public static final int MAX_EDGES_PER_NODE = 500;
public static final int MAX_RECOMMENDATION_RESULTS = 2500;

private final Long2DoubleMap leftSeedNodesWithWeight;

protected RecommendationRequest(
long queryNode,
LongSet toBeFiltered,
byte[] socialProofTypes
byte[] socialProofTypes,
Long2DoubleMap leftSeedNodesWithWeight
) {
this.queryNode = queryNode;
this.toBeFiltered = toBeFiltered;
this.socialProofTypes = socialProofTypes;
this.leftSeedNodesWithWeight = leftSeedNodesWithWeight;
}

public long getQueryNode() {
Expand All @@ -70,4 +75,8 @@ public LongSet getToBeFiltered() {
public byte[] getSocialProofTypes() {
return socialProofTypes;
}

public Long2DoubleMap getLeftSeedNodesWithWeight() {
return leftSeedNodesWithWeight;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
public abstract class TopSecondDegreeByCountRequest extends RecommendationRequest {

private final Long2DoubleMap leftSeedNodesWithWeight;
private final int maxSocialProofTypeSize;
private final ResultFilterChain resultFilterChain;
private final long maxRightNodeAgeInMillis;
Expand All @@ -54,18 +53,13 @@ public TopSecondDegreeByCountRequest(
long maxRightNodeAgeInMillis,
long maxEdgeAgeInMillis,
ResultFilterChain resultFilterChain) {
super(queryNode, toBeFiltered, socialProofTypes);
this.leftSeedNodesWithWeight = leftSeedNodesWithWeight;
super(queryNode, toBeFiltered, socialProofTypes, leftSeedNodesWithWeight);
this.maxSocialProofTypeSize = maxSocialProofTypeSize;
this.maxRightNodeAgeInMillis = maxRightNodeAgeInMillis;
this.maxEdgeAgeInMillis = maxEdgeAgeInMillis;
this.resultFilterChain = resultFilterChain;
}

public Long2DoubleMap getLeftSeedNodesWithWeight() {
return leftSeedNodesWithWeight;
}

public int getMaxSocialProofTypeSize() {
return maxSocialProofTypeSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* {@link SalsaRequestBuilder}.
*/
public class SalsaRequest extends RecommendationRequest {
private final Long2DoubleMap leftSeedNodesWithWeight;

private final int numRandomWalks;
private final int maxRandomWalkLength;
private final double resetProbability;
Expand Down Expand Up @@ -76,8 +76,7 @@ protected SalsaRequest(
double queryNodeWeightFraction,
boolean removeCustomizedBitsNodes,
ResultFilterChain resultFilterChain) {
super(queryNode, toBeFiltered, socialProofTypes);
this.leftSeedNodesWithWeight = leftSeedNodesWithWeight;
super(queryNode, toBeFiltered, socialProofTypes, leftSeedNodesWithWeight);
this.numRandomWalks = numRandomWalks;
this.maxRandomWalkLength = maxRandomWalkLength;
this.resetProbability = resetProbability;
Expand All @@ -89,10 +88,6 @@ protected SalsaRequest(
this.resultFilterChain = resultFilterChain;
}

public Long2DoubleMap getLeftSeedNodesWithWeight() {
return leftSeedNodesWithWeight;
}

public int getNumRandomWalks() {
return numRandomWalks;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

public class NodeMetadataSocialProofRequest extends RecommendationRequest {
private static final LongSet EMPTY_SET = new LongArraySet();

private final Long2DoubleMap leftSeedNodesWithWeight;

private final Byte2ObjectMap<IntSet> nodeMetadataTypeToIdsMap;

/**
Expand All @@ -46,15 +45,10 @@ public NodeMetadataSocialProofRequest(
Long2DoubleMap weightedSeedNodes,
byte[] socialProofTypes
) {
super(0, EMPTY_SET, socialProofTypes);
this.leftSeedNodesWithWeight = weightedSeedNodes;
super(0, EMPTY_SET, socialProofTypes, weightedSeedNodes);
this.nodeMetadataTypeToIdsMap = nodeMetadataTypeToIdsMap;
}

public Long2DoubleMap getLeftSeedNodesWithWeight() {
return leftSeedNodesWithWeight;
}

public Byte2ObjectMap<IntSet> getNodeMetadataTypeToIdsMap() {
return this.nodeMetadataTypeToIdsMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
public class SocialProofRequest extends RecommendationRequest {
private static final LongSet EMPTY_SET = new LongArraySet();

private final Long2DoubleMap leftSeedNodesWithWeight;
private final LongSet rightNodeIds;

/**
Expand All @@ -41,15 +40,10 @@ public SocialProofRequest(
Long2DoubleMap weightedSeedNodes,
byte[] socialProofTypes
) {
super(0, EMPTY_SET, socialProofTypes);
this.leftSeedNodesWithWeight = weightedSeedNodes;
super(0, EMPTY_SET, socialProofTypes, weightedSeedNodes);
this.rightNodeIds = rightNodeIds;
}

public Long2DoubleMap getLeftSeedNodesWithWeight() {
return leftSeedNodesWithWeight;
}

public LongSet getRightNodeIds() {
return this.rightNodeIds;
}
Expand Down