Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Java code:
----------
Java
public static void main(String[] args) {
	
   if(args.length != 12){
      System.out.println("Usage: ParamFile1 ParamFile2 ParamFile3 ParamFile4 ofset num");
      System.exit(1);
   }
		
   int numDeactivation = Integer.parseInt(args[4]);
   double offset_factor = Double.parseDouble(args[5]);
   .
   .
   .


Converting to running with Apache Giraph abstractions:
--------------------------------
Java
public int run(String[] argArray) throws Exception {
   if (argArray.length != 12) {
      throw new IllegalArgumentException(
         "run: Usage: ParamFile1 ParamFile2 ParamFile3 ParamFile4 ofset num");
      }

      GiraphJob job = new GiraphJob(getConf(), getClass().getName());
      job.setVertexClass(getClass());
    
      job.setVertexInputFormatClass(SRankVertexInputFormat.class);
   
      job.setVertexOutputFormatClass(SRankVertexOutputFormat.class);

      int numDeactivation = Integer.parseInt(args[4]);
      double offset_factor = Double.parseDouble(args[5]);
    
      if (job.run(true) == true) {
         return 0;
      } 
      else {
         return -1;
      }
   }
}

public static void main(String[] args) throws Exception {
    System.exit(ToolRunner.run(new SRank(), args));
}


I have no experience with Apache Giraph but I want to make Java code (that processing a graph with an algorithm like ShortestPath) to run in Apache Giraph an iterative graph processing system using it's abstractions.
Is this correct conversion from clearly Java code to Apache Giraph??
Posted
Updated 28-Dec-13 14:16pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900