Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Feature diffusion computation and utils #82

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

AlessioRosatelli
Copy link

No description provided.

@@ -0,0 +1,39 @@
package org.apache.giraph.examples;
Copy link

Choose a reason for hiding this comment

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

Let's use some consistent code style to format the sources. I suggest Google's java formatting: http://google.github.io/styleguide/javaguide.html. You can use it directly in Eclispe/IDEA and apply formatting changes automatically.

@@ -0,0 +1,39 @@
package org.apache.giraph.examples;

import org.apache.giraph.block_app.framework.block.Block;
Copy link

Choose a reason for hiding this comment

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

Similarly, let's have checkstyle (http://checkstyle.sourceforge.net/google_style.html) and findbugs (http://findbugs.sourceforge.net/) in place. This will greatly improve the readability of the code

protected long label;
protected int treshold;
protected boolean changed = false;
protected double temp;
Copy link

Choose a reason for hiding this comment

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

please use readable names for all variables/objects

}*/

@Override
public void compute(Vertex<LongWritable, LabelingVertexValue, NullWritable> vertex, Iterable<Text> msgs)
Copy link

Choose a reason for hiding this comment

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

Let's send typed messages, e.g., LongLongWritable in this case.

Logger LOG = Logger.getLogger(this.getClass());


/*public void initialize(GraphState graphState,
Copy link

Choose a reason for hiding this comment

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

Please get rid of all debug code. It is hard to read the code otherwise

}

public boolean isVertexDead() {
return new BigDecimal(currentActivationProbability).setScale(2, RoundingMode.HALF_DOWN).floatValue() == 0;
Copy link

Choose a reason for hiding this comment

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

I believe BigDecimal are not needed in this case


protected int vertexThreshold;
protected int label;
protected double currentActivationProbability=0.2;
Copy link

Choose a reason for hiding this comment

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

I'm confused. This constant is also initialized in DiffusionMigrationSimulationComputation. Please define constants in a single place

private void setup(DiffusionVertexValue value) {
double delta = Double.parseDouble(getConf().getStrings("Delta", "0.005")[0]);
value.setDelta(delta);
double initialActivationProbability = Double.parseDouble(getConf().getStrings("InitialProbability","0.02")[0]);
Copy link

Choose a reason for hiding this comment

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

Please use org.apache.giraph.conf.FloatConfOption instead


import org.apache.giraph.examples.feature_diffusion_utils.datastructures.DiffusionVertexValue;

public class DiffusionMigrationSimulationComputation extends MigrationFullBasicComputation<LongWritable, DiffusionVertexValue, NullWritable, IntWritable> {
Copy link

Choose a reason for hiding this comment

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

Please add comment for all your classes, methods, and constants

import org.apache.giraph.examples.feature_diffusion_utils.datastructures.DiffusionVertexValue;


public class DiffusionMigrationBlockFactory extends MigrationFullBlockFactory {
Copy link

Choose a reason for hiding this comment

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

Let's add a few unit tests to make sure things are working as expected

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants