当前位置: 首页>>代码示例>>Java>>正文


Java GiraphConfiguration.setComputationClass方法代码示例

本文整理汇总了Java中org.apache.giraph.conf.GiraphConfiguration.setComputationClass方法的典型用法代码示例。如果您正苦于以下问题:Java GiraphConfiguration.setComputationClass方法的具体用法?Java GiraphConfiguration.setComputationClass怎么用?Java GiraphConfiguration.setComputationClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.giraph.conf.GiraphConfiguration的用法示例。


在下文中一共展示了GiraphConfiguration.setComputationClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMax

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void testMax() throws Exception {

    Vertex v1 = graph.addVertex(T.id, 1, T.label, "hi");
    Vertex v2 = graph.addVertex(T.id, 2, T.label, "world");
    Vertex v5 = graph.addVertex(T.id, 5, T.label, "bye");
    v5.addEdge("e", v1);
    v1.addEdge("e", v5);
    v1.addEdge("e", v2);
    v2.addEdge("e", v5);

    HBaseGraphConfiguration hconf = graph.configuration();
    GiraphConfiguration conf = new GiraphConfiguration(hconf.toHBaseConfiguration());
    conf.setComputationClass(MaxComputation.class);
    conf.setEdgeInputFormatClass(HBaseEdgeInputFormat.class);
    conf.setVertexInputFormatClass(HBaseVertexInputFormat.class);
    conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);

    Iterable<String> results = InternalHBaseVertexRunner.run(conf);

    Map<Integer, Integer> values = parseResults(results);
    assertEquals(3, values.size());
    assertEquals(5, (int) values.get(1));
    assertEquals(5, (int) values.get(2));
    assertEquals(5, (int) values.get(5));
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:27,代码来源:MaxComputationTest.java

示例2: testMax

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void testMax() throws Exception {
    HBaseGraphConfiguration hconf = graph.configuration();

    GiraphConfiguration conf = new GiraphConfiguration(hconf.toHBaseConfiguration());
    conf.setComputationClass(MaxComputation.class);
    conf.setEdgeInputFormatClass(HBaseEdgeInputFormat.class);
    conf.setVertexInputFormatClass(HBaseVertexInputFormat.class);
    conf.setEdgeOutputFormatClass(CreateEdgeOutputFormat.class);
    conf.setVertexOutputFormatClass(MaxPropertyVertexOutputFormat.class);

    Vertex v1 = graph.addVertex(T.id, 1, T.label, "hi");
    Vertex v2 = graph.addVertex(T.id, 2, T.label, "world");
    Vertex v5 = graph.addVertex(T.id, 5, T.label, "bye");
    v5.addEdge("e", v1);
    v1.addEdge("e", v5);
    v1.addEdge("e", v2);
    v2.addEdge("e", v5);

    InternalHBaseVertexRunner.run(conf);

    graph.vertices().forEachRemaining(v -> assertEquals(5, v.property("max").value()));
    assertEquals(4, IteratorUtils.count(IteratorUtils.filter(graph.edges(), e -> e.label().equals("e2"))));
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:25,代码来源:MaxComputationWithGraphOutputTest.java

示例3: testComputeOutput

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void testComputeOutput() throws Exception {
    GiraphConfiguration conf = new GiraphConfiguration();
    conf.setComputationClass(WeaklyConnectedComponentComputation.class);
    conf.setVertexOutputFormatClass(InMemoryVertexOutputFormat.class);
    TestGraph<Text,Text,Text> testGraph = getGraph(conf);
    InMemoryVertexOutputFormat.initializeOutputGraph(conf);
    InternalVertexRunner.run(conf, testGraph);
    TestGraph<Text, Text, Text> graph = InMemoryVertexOutputFormat.getOutputGraph();
    assertEquals(6, graph.getVertices().size());
    assertEquals("2", graph.getVertex(new Text("1")).getValue().toString());
    assertEquals("2", graph.getVertex(new Text("2")).getValue().toString());
    assertEquals("4", graph.getVertex(new Text("3")).getValue().toString());
    assertEquals("4", graph.getVertex(new Text("4")).getValue().toString());
    assertEquals("6", graph.getVertex(new Text("5")).getValue().toString());
    assertEquals("6", graph.getVertex(new Text("6")).getValue().toString());
}
 
开发者ID:Sotera,项目名称:distributed-graph-analytics,代码行数:18,代码来源:WeaklyConnectedComponentComputationTest.java

示例4: getEmptyDb

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void getEmptyDb() throws Exception {
  Iterable<String>    results;
  Iterator<String>    result;
  GiraphConfiguration conf    = new GiraphConfiguration();
  GIRAPH_GORA_DATASTORE_CLASS.
  set(conf, "org.apache.gora.memory.store.MemStore");
  GIRAPH_GORA_KEYS_FACTORY_CLASS.
  set(conf,"org.apache.giraph.io.gora.utils.DefaultKeyFactory");
  GIRAPH_GORA_KEY_CLASS.set(conf,"java.lang.String");
  GIRAPH_GORA_PERSISTENT_CLASS.
  set(conf,"org.apache.giraph.io.gora.generated.GEdge");
  GIRAPH_GORA_START_KEY.set(conf,"1");
  GIRAPH_GORA_END_KEY.set(conf,"3");
  conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.WritableSerialization," +
      "org.apache.hadoop.io.serializer.JavaSerialization");
  conf.setComputationClass(EmptyComputation.class);
  conf.setEdgeInputFormatClass(GoraGEdgeEdgeInputFormat.class);
  results = InternalVertexRunner.run(conf, new String[0], new String[0]);
  Assert.assertNotNull(results);
  result = results.iterator();
  Assert.assertFalse(result.hasNext());
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:25,代码来源:TestGoraEdgeInputFormat.java

示例5: testMaxSuperstep

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
 * Run a job that tests that this job completes in the desired number of
 * supersteps
 *
 * @throws java.io.IOException
 * @throws ClassNotFoundException
 * @throws InterruptedException
 */
@Test
public void testMaxSuperstep()
        throws IOException, InterruptedException, ClassNotFoundException {
  GiraphConfiguration conf = new GiraphConfiguration();
  conf.setComputationClass(InfiniteLoopComputation.class);
  conf.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
  conf.setVertexOutputFormatClass(SimplePageRankVertexOutputFormat.class);
  GiraphJob job = prepareJob(getCallingMethodName(), conf,
      getTempPath(getCallingMethodName()));
  job.getConfiguration().setMaxNumberOfSupersteps(3);
  assertTrue(job.run(true));
  if (!runningInDistributedMode()) {
    GiraphHadoopCounter superstepCounter =
        GiraphStats.getInstance().getSuperstepCounter();
    assertEquals(superstepCounter.getValue(), 3L);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:26,代码来源:TestMaxSuperstep.java

示例6: testCheckFailsJob

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void testCheckFailsJob() throws Exception {
  String tableName = "test1";
  hiveServer.createTable("CREATE TABLE " + tableName +
     " (i1 INT, i2 BIGINT) ");

  GiraphConfiguration conf = new GiraphConfiguration();
  String[] edges = new String[] {
      "1 2",
      "2 3",
      "2 4",
      "4 1"
  };

  GiraphHiveConstants.HIVE_VERTEX_OUTPUT_TABLE.set(conf, tableName);
  GiraphHiveConstants.VERTEX_TO_HIVE_CLASS.set(conf, HiveOutputIntIntVertex.class);

  conf.setComputationClass(ComputationCountEdges.class);
  conf.setOutEdgesClass(ByteArrayEdges.class);
  conf.setEdgeInputFormatClass(IntNullTextEdgeInputFormat.class);
  conf.setVertexOutputFormatClass(HiveVertexOutputFormat.class);
  try {
    Iterable<String> result = InternalVertexRunner.run(conf, null, edges);
    assertNull(result);
  } catch (IllegalArgumentException e) { }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:27,代码来源:CheckOutputTest.java

示例7: prepareConfiguration

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Override
protected void prepareConfiguration(GiraphConfiguration conf,
    CommandLine cmd) {
  conf.setComputationClass(RandomMessageComputation.class);
  conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
  conf.setWorkerContextClass(RandomMessageBenchmarkWorkerContext.class);
  conf.setMasterComputeClass(RandomMessageBenchmarkMasterCompute.class);
  conf.setLong(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
      BenchmarkOption.VERTICES.getOptionLongValue(cmd));
  conf.setLong(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
      BenchmarkOption.EDGES_PER_VERTEX.getOptionLongValue(cmd));
  conf.setInt(SUPERSTEP_COUNT,
      BenchmarkOption.SUPERSTEPS.getOptionIntValue(cmd));
  conf.setInt(RandomMessageBenchmark.NUM_BYTES_PER_MESSAGE,
      BYTES_PER_MESSAGE.getOptionIntValue(cmd));
  conf.setInt(RandomMessageBenchmark.NUM_MESSAGES_PER_EDGE,
      MESSAGES_PER_EDGE.getOptionIntValue(cmd));
  if (FLUSH_THREADS.optionTurnedOn(cmd)) {
    conf.setInt(GiraphConstants.MSG_NUM_FLUSH_THREADS,
        FLUSH_THREADS.getOptionIntValue(cmd));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:23,代码来源:RandomMessageBenchmark.java

示例8: getEmptyDb

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void getEmptyDb() throws Exception {
  Iterable<String>    results;
  Iterator<String>    result;
  GiraphConfiguration conf    = new GiraphConfiguration();
  GIRAPH_GORA_DATASTORE_CLASS.
  set(conf, "org.apache.gora.memory.store.MemStore");
  GIRAPH_GORA_KEYS_FACTORY_CLASS.
  set(conf,"org.apache.giraph.io.gora.utils.DefaultKeyFactory");
  GIRAPH_GORA_KEY_CLASS.set(conf,"java.lang.String");
  GIRAPH_GORA_PERSISTENT_CLASS.
  set(conf,"org.apache.giraph.io.gora.generated.GVertex");
  GIRAPH_GORA_START_KEY.set(conf,"1");
  GIRAPH_GORA_END_KEY.set(conf,"10");
  conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.WritableSerialization," +
      "org.apache.hadoop.io.serializer.JavaSerialization");
  conf.setComputationClass(EmptyComputation.class);
  conf.setVertexInputFormatClass(GoraTestVertexInputFormat.class);
  results = InternalVertexRunner.run(conf, new String[0], new String[0]);
  Assert.assertNotNull(results);
  result = results.iterator();
  Assert.assertFalse(result.hasNext());
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:25,代码来源:TestGoraVertexInputFormat.java

示例9: testBspSuperStep

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
 * Run a sample BSP job locally and test supersteps.
 *
 * @throws IOException
 * @throws ClassNotFoundException
 * @throws InterruptedException
 */
@Test
public void testBspSuperStep()
    throws IOException, InterruptedException, ClassNotFoundException {
  String callingMethod = getCallingMethodName();
  Path outputPath = getTempPath(callingMethod);
  GiraphConfiguration conf = new GiraphConfiguration();
  conf.setComputationClass(SimpleSuperstepComputation.class);
  conf.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
  conf.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
  GiraphJob job = prepareJob(callingMethod, conf, outputPath);
  Configuration configuration = job.getConfiguration();
  // GeneratedInputSplit will generate 10 vertices
  GeneratedVertexReader.READER_VERTICES.set(configuration, 10);
  assertTrue(job.run(true));
  if (!runningInDistributedMode()) {
    FileStatus fileStatus = getSinglePartFileStatus(configuration, outputPath);
    assertEquals(49l, fileStatus.getLen());
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:27,代码来源:TestBspBasic.java

示例10: testToyData

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
 * A local integration test on toy data
 */
@Test
public void testToyData() throws Exception {

    Vertex v1 = graph.addVertex(T.id, 1);
    Vertex v2 = graph.addVertex(T.id, 2);
    Vertex v3 = graph.addVertex(T.id, 3);
    Vertex v4 = graph.addVertex(T.id, 4);
    v1.addEdge("e", v2, "weight", 1.0);
    v1.addEdge("e", v3, "weight", 3.0);
    v2.addEdge("e", v3, "weight", 1.0);
    v2.addEdge("e", v4, "weight", 10.0);
    v3.addEdge("e", v4, "weight", 2.0);

    HBaseGraphConfiguration hconf = graph.configuration();
    GiraphConfiguration conf = new GiraphConfiguration(hconf.toHBaseConfiguration());
    // start from vertex 1
    SOURCE_ID.set(conf, 1);
    conf.setComputationClass(SimpleShortestPathsComputation.class);
    conf.setEdgeInputFormatClass(HBaseEdgeInputFormat.class);
    conf.setVertexInputFormatClass(HBaseVertexInputFormat.class);
    conf.setVertexOutputFormatClass(VertexWithDoubleValueNullEdgeTextOutputFormat.class);

    // run internally
    Iterable<String> results = InternalHBaseVertexRunner.run(conf);

    Map<Long, Double> distances = parseDistances(results);

    // verify results
    assertNotNull(distances);
    assertEquals(4, distances.size());
    assertEquals(0.0, distances.get(1L), 0d);
    assertEquals(1.0, distances.get(2L), 0d);
    assertEquals(2.0, distances.get(3L), 0d);
    assertEquals(4.0, distances.get(4L), 0d);
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:39,代码来源:SimpleShortestPathsComputationTest.java

示例11: run

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Override
public int run(String[] args) throws Exception {
    if (args.length != 3) {
        throw new IllegalArgumentException(
            "Syntax error: Must have 3 arguments <numbersOfWorkers> <inputLocaiton> <outputLocation>");
    }

    int numberOfWorkers = Integer.parseInt(args[0]);
    String inputLocation = args[1];
    String outputLocation = args[2];

    GiraphJob job = new GiraphJob(getConf(), getClass().getName());
    GiraphConfiguration gconf = job.getConfiguration();
    gconf.setWorkerConfiguration(numberOfWorkers, numberOfWorkers, 100.0f);

    GiraphFileInputFormat.addVertexInputPath(gconf, new Path(inputLocation));
    FileOutputFormat.setOutputPath(job.getInternalJob(), new Path(outputLocation));

    gconf.setComputationClass(ZombieComputation.class);
    gconf.setMasterComputeClass(ZombieMasterCompute.class);
    gconf.setVertexInputFormatClass(ZombieTextVertexInputFormat.class);
    gconf.setVertexOutputFormatClass(ZombieTextVertexOutputFormat.class);
    gconf.setWorkerContextClass(ZombieWorkerContext.class);

    boolean verbose = true;
    if (job.run(verbose)) {
        return 0;
    } else {
        return -1;
    }
}
 
开发者ID:amitchmca,项目名称:hadooparchitecturebook,代码行数:32,代码来源:ZombieBiteJob.java

示例12: getConfiguration

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
private GiraphConfiguration getConfiguration() {
  GiraphConfiguration conf = new GiraphConfiguration();
  conf.setComputationClass(DiffusionComputation.class);
  conf.setMasterComputeClass(DiffusionMasterComputation.class);
  conf.setVertexInputFormatClass(DiffusionTextVertexInputFormat.class);
  conf.setVertexOutputFormatClass(DiffusionTextVertexOutputFormat.class);
  conf.setBoolean(DiffusionTextVertexOutputFormat.TEST_OUTPUT, true);
  return conf;
}
 
开发者ID:galpha,项目名称:giraph-didic,代码行数:10,代码来源:DiffusionComputationTest.java

示例13: testRyaInput

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Test
public void testRyaInput() throws Exception {

    AccumuloRdfConfiguration conf = getConf();
    AccumuloRyaDAO ryaDAO = RyaSailFactory.getAccumuloDAO(conf);

    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"),
            new RyaURI("urn:test#pred1"),
            new RyaURI("urn:test#obj1")));
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"),
            new RyaURI("urn:test#pred2"),
            new RyaURI("urn:test#obj2")));
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"),
            new RyaURI("urn:test#pred3"),
            new RyaURI("urn:test#obj3")));
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"),
            new RyaURI("urn:test#pred4"),
            new RyaURI("urn:test#obj4")));
    ryaDAO.flush();

    GiraphJob job = new GiraphJob(conf, getCallingMethodName());

    setupConfiguration(job);
    GiraphConfiguration giraphConf = job.getConfiguration();
    giraphConf.setComputationClass(EdgeNotification.class);
    giraphConf.setVertexInputFormatClass(RyaVertexInputFormat.class);
    giraphConf.setVertexOutputFormatClass(TestTextOutputFormat.class);


    if (log.isInfoEnabled())
        log.info("Running edge notification job using Rya Vertex input");

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:34,代码来源:TestVertexFormat.java

示例14: getConfiguration

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
private GiraphConfiguration getConfiguration() {
  GiraphConfiguration conf = new GiraphConfiguration();
  conf.setComputationClass(ARPComputation.class);
  conf.setMasterComputeClass(ARPMasterComputation.class);
  conf.setVertexInputFormatClass(ARPTextVertexInputFormat.class);
  conf.setVertexOutputFormatClass(ARPTextVertexOutputFormat.class);
  return conf;
}
 
开发者ID:dbs-leipzig,项目名称:giraph-algorithms,代码行数:9,代码来源:ARPComputationTest.java

示例15: getConfiguration

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
private GiraphConfiguration getConfiguration() {
  GiraphConfiguration conf = new GiraphConfiguration();
  conf.setComputationClass(BTGComputation.class);
  conf.setVertexInputFormatClass(BTGTextVertexInputFormat.class);
  conf.setVertexOutputFormatClass(BTGTextVertexOutputFormat.class);
  return conf;
}
 
开发者ID:dbs-leipzig,项目名称:giraph-algorithms,代码行数:8,代码来源:BTGComputationTest.java


注:本文中的org.apache.giraph.conf.GiraphConfiguration.setComputationClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。