View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.giraph.io.gora;
19  
20  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_DATASTORE_CLASS;
21  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_END_KEY;
22  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_KEYS_FACTORY_CLASS;
23  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_KEY_CLASS;
24  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_PERSISTENT_CLASS;
25  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_START_KEY;
26  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_OUTPUT_DATASTORE_CLASS;
27  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_OUTPUT_KEY_CLASS;
28  import static org.apache.giraph.io.gora.constants.GiraphGoraConstants.GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS;
29  
30  import org.apache.giraph.conf.GiraphConfiguration;
31  import org.apache.giraph.io.gora.TestGoraVertexInputFormat.EmptyComputation;
32  import org.apache.giraph.utils.InternalVertexRunner;
33  import org.junit.Assert;
34  import org.junit.Test;
35  
36  /**
37   * Test class for Gora vertex output formats.
38   */
39  public class TestGoraVertexOutputFormat {
40  
41    @Test
42    public void getWritingDb() throws Exception {
43      Iterable<String>    results;
44      GiraphConfiguration conf    = new GiraphConfiguration();
45      GIRAPH_GORA_DATASTORE_CLASS.
46      set(conf, "org.apache.gora.memory.store.MemStore");
47      GIRAPH_GORA_KEYS_FACTORY_CLASS.
48      set(conf,"org.apache.giraph.io.gora.utils.DefaultKeyFactory");
49      GIRAPH_GORA_KEY_CLASS.set(conf,"java.lang.String");
50      GIRAPH_GORA_PERSISTENT_CLASS.
51      set(conf,"org.apache.giraph.io.gora.generated.GVertex");
52      GIRAPH_GORA_START_KEY.set(conf,"1");
53      GIRAPH_GORA_END_KEY.set(conf,"10");
54      GIRAPH_GORA_OUTPUT_DATASTORE_CLASS.
55      set(conf, "org.apache.gora.memory.store.MemStore");
56      GIRAPH_GORA_OUTPUT_KEY_CLASS.set(conf, "java.lang.String");
57      GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS.
58      set(conf, "org.apache.giraph.io.gora.generated.GVertex");
59      conf.set("io.serializations",
60          "org.apache.hadoop.io.serializer.WritableSerialization," +
61          "org.apache.hadoop.io.serializer.JavaSerialization");
62      conf.setComputationClass(EmptyComputation.class);
63      conf.setVertexInputFormatClass(GoraTestVertexInputFormat.class);
64      // Parameters for output
65      GIRAPH_GORA_OUTPUT_DATASTORE_CLASS.
66      set(conf, "org.apache.gora.memory.store.MemStore");
67      GIRAPH_GORA_OUTPUT_KEY_CLASS.set(conf, "java.lang.String");
68      GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS.
69      set(conf,"org.apache.giraph.io.gora.generated.GVertex");
70      conf.setVertexOutputFormatClass(GoraTestVertexOutputFormat.class);
71      results = InternalVertexRunner.run(conf, new String[0], new String[0]);
72      Assert.assertNotNull(results);
73    }
74  }