Skip to content

Conversation

houzhizhen
Copy link
Contributor

No description provided.

int workerId = partitioner.workerId(partitionId);
workerStat[workerId]++;
}
LOG.info("partitionStat: {}", Arrays.toString(partitionStat));
Copy link
Contributor

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.

Linary
Linary previously approved these changes Apr 2, 2021

@Override
public int partitionId(Id vertexId) {
return Math.abs(vertexId.hashCode() % this.partitionCount);
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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));
Copy link
Contributor

@javeme javeme Apr 2, 2021

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
Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

align with config

Copy link
Contributor Author

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, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

improve description

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

check not 0

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Linary Linary merged commit fb4c829 into master Apr 7, 2021
@Linary Linary deleted the partitioner branch April 7, 2021 02:40
coderzc pushed a commit that referenced this pull request Nov 9, 2021
Co-authored-by: Jermy Li <lizhangmei@baidu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants