- Notifications
You must be signed in to change notification settings - Fork 44
add Partitioner and HashPartitioner #29
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
Conversation
int workerId = partitioner.workerId(partitionId); | ||
workerStat[workerId]++; | ||
} | ||
LOG.info("partitionStat: {}", Arrays.toString(partitionStat)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sum all partitionStat elem, it should be equal with 1024, then assert it.
| ||
@Override | ||
public int partitionId(Id vertexId) { | ||
return Math.abs(vertexId.hashCode() % this.partitionCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashCode = vertexId.hashCode() & 0x7fffffff
hashCode % this.partitionCount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
ComputerOptions.WORKER_PARTITIONER); | ||
partitioner.init(config); | ||
Id vertexId1 = new LongId(1L); | ||
Id vertexId2 = new LongId(2L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id vertexId2 = new LongId(-1L);
Id vertexId2 = new LongId(-100L);
Id vertexId2 = new LongId(Long.MIN);
Id vertexId2 = new LongId(Long.MAX);
workerStat[workerId]++; | ||
} | ||
LOG.info("partitionStat: {}", Arrays.toString(partitionStat)); | ||
LOG.info("workerStat: {}", Arrays.toString(workerStat)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve log message
and add case:
- 1 worker 3 partition
- 1 worker 1 partition
- 3 worker 1 partition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
); | ||
Config config = ComputerContext.instance().config(); | ||
Partitioner partitioner = config.createObject( | ||
ComputerOptions.WORKER_PARTITIONER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public static final ConfigOption<Class<?>> WORKER_PARTITIONER = | ||
new ConfigOption<>( | ||
"worker.partitioner", | ||
"The partitioner that decides partition id by vertex id, " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@Override | ||
public void init(Config config) { | ||
this.partitionCount = config.get(ComputerOptions.JOB_PARTITIONS_COUNT); | ||
this.workerCount = config.get(ComputerOptions.JOB_WORKERS_COUNT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check not 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options required positiveInt()
private int workerCount; | ||
| ||
public HashPartitioner() { | ||
// pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set -1 for all the fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Co-authored-by: Jermy Li <lizhangmei@baidu.com>
No description provided.