GIRAPH-946. Upgrade to Gora 0.5 (Renato Javier MarroquÃn Mogrovejo via rvs)
Project: http://git-wip-us.apache.org/repos/asf/giraph/repo Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/7c61dcf4 Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/7c61dcf4 Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/7c61dcf4 Branch: refs/heads/trunk Commit: 7c61dcf4abaa422637a68839bf0d547a164375a3 Parents: 0bcc76d Author: Roman Shaposhnik <[email protected]> Authored: Sun Oct 19 16:54:39 2014 -0700 Committer: Roman Shaposhnik <[email protected]> Committed: Sun Oct 19 16:54:39 2014 -0700 ---------------------------------------------------------------------- giraph-gora/conf/edge_result.avsc | 12 + giraph-gora/conf/vertex.avsc | 10 + giraph-gora/conf/vertex.json | 18 - giraph-gora/conf/vertex_result.avsc | 10 + giraph-gora/pom.xml | 241 +++--- .../giraph/io/gora/GoraEdgeInputFormat.java | 12 +- .../giraph/io/gora/GoraEdgeOutputFormat.java | 10 +- .../io/gora/GoraGEdgeEdgeInputFormat.java | 9 +- .../io/gora/GoraGEdgeEdgeOutputFormat.java | 5 +- .../io/gora/GoraGVertexVertexInputFormat.java | 10 +- .../io/gora/GoraGVertexVertexOutputFormat.java | 11 +- .../giraph/io/gora/GoraVertexInputFormat.java | 14 +- .../giraph/io/gora/GoraVertexOutputFormat.java | 8 +- .../apache/giraph/io/gora/generated/GEdge.java | 842 +++++++++++++++--- .../giraph/io/gora/generated/GEdgeResult.java | 849 ++++++++++++++++--- .../giraph/io/gora/generated/GVertex.java | 641 +++++++++++--- .../giraph/io/gora/generated/GVertexResult.java | 644 +++++++++++--- .../io/gora/utils/ExtraGoraInputFormat.java | 9 +- .../apache/giraph/io/gora/utils/GoraUtils.java | 42 +- .../giraph/io/gora/GoraTestEdgeInputFormat.java | 14 +- .../io/gora/GoraTestEdgeOutputFormat.java | 25 +- .../io/gora/GoraTestVertexInputFormat.java | 12 +- .../io/gora/GoraTestVertexOutputFormat.java | 23 +- .../giraph/io/gora/TestGoraEdgeInputFormat.java | 4 +- .../io/gora/TestGoraEdgeOutputFormat.java | 2 +- pom.xml | 4 +- 26 files changed, 2728 insertions(+), 753 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/conf/edge_result.avsc ---------------------------------------------------------------------- diff --git a/giraph-gora/conf/edge_result.avsc b/giraph-gora/conf/edge_result.avsc new file mode 100644 index 0000000..9319fa1 --- /dev/null +++ b/giraph-gora/conf/edge_result.avsc @@ -0,0 +1,12 @@ +{ + "type": "record", + "name": "GEdgeResult", + "namespace": "org.apache.giraph.io.gora.generated", + "fields" : [ + {"name": "edgeId", "type": "string"}, + {"name": "edgeWeight", "type": "float"}, + {"name": "vertexInId", "type": "string"}, + {"name": "vertexOutId", "type": "string"}, + {"name": "label", "type": "string"} + ] +} http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/conf/vertex.avsc ---------------------------------------------------------------------- diff --git a/giraph-gora/conf/vertex.avsc b/giraph-gora/conf/vertex.avsc new file mode 100644 index 0000000..88d4234 --- /dev/null +++ b/giraph-gora/conf/vertex.avsc @@ -0,0 +1,10 @@ +{ + "type": "record", + "name": "GVertex", + "namespace": "org.apache.giraph.io.gora.generated", + "fields" : [ + {"name": "vertexId", "type": "string"}, + {"name": "vertexValue", "type": "float"}, + {"name": "edges", "type": {"type": "map", "values": "string"}} + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/conf/vertex.json ---------------------------------------------------------------------- diff --git a/giraph-gora/conf/vertex.json b/giraph-gora/conf/vertex.json deleted file mode 100644 index 9f435fa..0000000 --- a/giraph-gora/conf/vertex.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "record", - "name": "Vertex", - "namespace": "org.apache.giraph.gora.generated", - "fields" : [ - {"name": "vertexId", "type": "long"}, - {"name": "value", "type": "float"}, - {"name": "edges", "type": {"type":"array", "items": { - "name": "Edge", - "type": "record", - "namespace": "org.apache.giraph.gora.generated", - "fields": [ - {"name": "vertexId", "type": "long"}, - {"name": "edgeValue", "type": "float"} - ] - }}} - ] -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/conf/vertex_result.avsc ---------------------------------------------------------------------- diff --git a/giraph-gora/conf/vertex_result.avsc b/giraph-gora/conf/vertex_result.avsc new file mode 100644 index 0000000..b594ca9 --- /dev/null +++ b/giraph-gora/conf/vertex_result.avsc @@ -0,0 +1,10 @@ +{ + "type": "record", + "name": "GVertexResult", + "namespace": "org.apache.giraph.io.gora.generated", + "fields" : [ + {"name": "vertexId", "type": "string"}, + {"name": "vertexValue", "type": "float"}, + {"name": "edges", "type": {"type": "map", "values": "string"}} + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/pom.xml ---------------------------------------------------------------------- diff --git a/giraph-gora/pom.xml b/giraph-gora/pom.xml index 38e3ab7..7f499c6 100644 --- a/giraph-gora/pom.xml +++ b/giraph-gora/pom.xml @@ -1,122 +1,139 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor + license agreements. See the NOTICE file distributed with this work for additional + information regarding copyright ownership. The ASF licenses this file to + you under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of + the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.giraph</groupId> - <artifactId>giraph-parent</artifactId> - <version>1.1.0-SNAPSHOT</version> - </parent> - <artifactId>giraph-gora</artifactId> - <packaging>jar</packaging> + <parent> + <groupId>org.apache.giraph</groupId> + <artifactId>giraph-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <artifactId>giraph-gora</artifactId> + <packaging>jar</packaging> - <name>Apache Giraph Gora I/O</name> - <url>http://gora.apache.org/giraph-gora/</url> - <description>Giraph Gora input/output classes</description> + <name>Apache Giraph Gora I/O</name> + <url>http://gora.apache.org/giraph-gora/</url> + <description>Giraph Gora input/output classes</description> - <properties> - <top.dir>${project.basedir}/..</top.dir> - </properties> + <properties> + <top.dir>${project.basedir}/..</top.dir> + </properties> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <configuration> - <siteDirectory>${project.basedir}/src/site</siteDirectory> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.6</version> - <configuration> - <systemProperties> - <property> - <name>prop.jarLocation</name> - <value>${top.dir}/giraph-core/target/giraph-${project.version}-${forHadoop}-jar-with-dependencies.jar</value> - </property> - </systemProperties> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>findbugs-maven-plugin</artifactId> - </plugin> - </plugins> - </build> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <siteDirectory>${project.basedir}/src/site</siteDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.6</version> + <configuration> + <systemProperties> + <property> + <name>prop.jarLocation</name> + <value>${top.dir}/giraph-core/target/giraph-${project.version}-${forHadoop}-jar-with-dependencies.jar</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + </plugin> + </plugins> + </build> - <dependencies> - <!-- compile dependencies. sorted lexicographically. --> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>org.apache.giraph</groupId> - <artifactId>giraph-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.gora</groupId> - <artifactId>gora-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.hadoop</groupId> - <artifactId>avro</artifactId> - </dependency> - <dependency> - <groupId>org.apache.zookeeper</groupId> - <artifactId>zookeeper</artifactId> - </dependency> + <dependencies> + <!-- compile dependencies. sorted lexicographically. --> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </dependency> + <dependency> + <groupId>org.apache.giraph</groupId> + <artifactId>giraph-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.gora</groupId> + <artifactId>gora-core</artifactId> + <exclusions> + <exclusion> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.gora</groupId> + <artifactId>gora-shims-distribution</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.avro</groupId> + <artifactId>avro</artifactId> + <version>${dep.avro.version}</version> + <exclusions> + <exclusion> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.zookeeper</groupId> + <artifactId>zookeeper</artifactId> + </dependency> - <!-- runtime dependency --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <scope>runtime</scope> - </dependency> + <!-- runtime dependency --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>runtime</scope> + </dependency> - <!-- test dependencies. sorted lexicographically. --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> + <!-- test dependencies. sorted lexicographically. --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> </project> http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeInputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeInputFormat.java index d0dcc32..8ef91f6 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeInputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeInputFormat.java @@ -34,8 +34,8 @@ import org.apache.giraph.io.gora.utils.ExtraGoraInputFormat; import org.apache.giraph.io.gora.utils.GoraUtils; import org.apache.giraph.io.gora.utils.KeyFactory; import org.apache.gora.persistency.Persistent; -import org.apache.gora.query.Query; import org.apache.gora.query.Result; +import org.apache.gora.query.impl.QueryBase; import org.apache.gora.store.DataStore; import org.apache.gora.util.GoraException; import org.apache.hadoop.conf.Configuration; @@ -114,7 +114,7 @@ public abstract class GoraEdgeInputFormat setPersistentClass((Class<? extends Persistent>) persistentClass); setDatastoreClass((Class<? extends DataStore>) dataStoreClass); setKeyFactoryClass(keyFactoryClass); - setDataStore(createDataStore()); + setDataStore(createDataStore(getConf())); GORA_INPUT_FORMAT.setDataStore(getDataStore()); } catch (ClassNotFoundException e) { LOG.error("Error while reading Gora Input parameters"); @@ -154,8 +154,9 @@ public abstract class GoraEdgeInputFormat kFact.setDataStore(getDataStore()); setStartKey(kFact.buildKey(sKey)); setEndKey(kFact.buildKey(eKey)); - Query tmpQuery = GoraUtils.getQuery( + QueryBase tmpQuery = GoraUtils.getQuery( getDataStore(), getStartKey(), getEndKey()); + tmpQuery.setConf(context.getConfiguration()); GORA_INPUT_FORMAT.setQuery(tmpQuery); List<InputSplit> splits = GORA_INPUT_FORMAT.getSplits(context); return splits; @@ -273,12 +274,13 @@ public abstract class GoraEdgeInputFormat /** * Gets the data store object initialized. + * @param conf Configuration * @return DataStore created */ - public DataStore createDataStore() { + public DataStore createDataStore(Configuration conf) { DataStore dsCreated = null; try { - dsCreated = GoraUtils.createSpecificDataStore(getDatastoreClass(), + dsCreated = GoraUtils.createSpecificDataStore(conf, getDatastoreClass(), getKeyClass(), getPersistentClass()); } catch (GoraException e) { LOG.error("Error creating data store."); http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeOutputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeOutputFormat.java index be9f472..d030d70 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeOutputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraEdgeOutputFormat.java @@ -30,11 +30,12 @@ import org.apache.giraph.io.gora.utils.GoraUtils; import org.apache.gora.persistency.Persistent; import org.apache.gora.store.DataStore; import org.apache.gora.util.GoraException; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; import org.apache.hadoop.mapreduce.JobContext; -import org.apache.hadoop.mapreduce.TaskAttemptContext; import org.apache.hadoop.mapreduce.OutputCommitter; +import org.apache.hadoop.mapreduce.TaskAttemptContext; import org.apache.log4j.Logger; /** @@ -83,12 +84,13 @@ public abstract class GoraEdgeOutputFormat<I extends WritableComparable, /** * Gets the data store object initialized. + * @param conf Configuration * @return DataStore created */ - public DataStore createDataStore() { + public DataStore createDataStore(Configuration conf) { DataStore dsCreated = null; try { - dsCreated = GoraUtils.createSpecificDataStore(getDatastoreClass(), + dsCreated = GoraUtils.createSpecificDataStore(conf, getDatastoreClass(), getKeyClass(), getPersistentClass()); } catch (GoraException e) { getLogger().error("Error creating data store."); @@ -159,7 +161,7 @@ public abstract class GoraEdgeOutputFormat<I extends WritableComparable, setKeyClass(keyClass); setPersistentClass((Class<? extends Persistent>) persistentClass); setDatastoreClass((Class<? extends DataStore>) dataStoreClass); - setDataStore(createDataStore()); + setDataStore(createDataStore(context.getConfiguration())); if (getDataStore() != null) { getLogger().debug("The data store has been created."); } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeInputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeInputFormat.java index e738f36..a2a3417 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeInputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeInputFormat.java @@ -69,14 +69,11 @@ public class GoraGEdgeEdgeInputFormat (Object goraObject) { Edge<LongWritable, FloatWritable> edge = null; GEdge goraEdge = (GEdge) goraObject; - Long dest; - Long value; - dest = Long.valueOf(goraEdge.getVertexOutId().toString()); this.sourceId = new LongWritable(); this.sourceId.set(Long.valueOf(goraEdge.getVertexInId().toString())); - value = (long) goraEdge.getEdgeWeight(); - edge = EdgeFactory.create(new LongWritable(dest), - new FloatWritable(value)); + edge = EdgeFactory.create( + new LongWritable(Long.valueOf(goraEdge.getVertexOutId().toString())), + new FloatWritable(goraEdge.getEdgeWeight())); return edge; } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeOutputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeOutputFormat.java index d350d37..82b02d0 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeOutputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGEdgeEdgeOutputFormat.java @@ -19,7 +19,6 @@ package org.apache.giraph.io.gora; import java.io.IOException; -import org.apache.avro.util.Utf8; import org.apache.giraph.edge.Edge; import org.apache.giraph.io.gora.generated.GEdgeResult; import org.apache.gora.persistency.Persistent; @@ -57,9 +56,9 @@ public class GoraGEdgeEdgeOutputFormat protected Persistent getGoraEdge(LongWritable srcId, DoubleWritable srcValue, Edge<LongWritable, FloatWritable> edge) { GEdgeResult tmpGEdge = new GEdgeResult(); - tmpGEdge.setEdgeId(new Utf8(srcId.toString())); + tmpGEdge.setEdgeId(srcId.toString()); tmpGEdge.setEdgeWeight(edge.getValue().get()); - tmpGEdge.setVertexOutId(new Utf8(edge.getTargetVertexId().toString())); + tmpGEdge.setVertexOutId(edge.getTargetVertexId().toString()); getLogger().debug("GoraObject created: " + tmpGEdge.toString()); return tmpGEdge; } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexInputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexInputFormat.java index cb0f005..34ba7ec 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexInputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexInputFormat.java @@ -20,7 +20,6 @@ package org.apache.giraph.io.gora; import java.io.IOException; import java.util.Set; -import org.apache.avro.util.Utf8; import org.apache.giraph.edge.Edge; import org.apache.giraph.edge.EdgeFactory; import org.apache.giraph.graph.Vertex; @@ -75,12 +74,13 @@ public class GoraGVertexVertexInputFormat GVertex tmpGVertex = (GVertex) goraObject; LongWritable vrtxId = new LongWritable( - Long.parseLong(tmpGVertex.getVertexId().toString())); - DoubleWritable vrtxValue = new DoubleWritable(tmpGVertex.getValue()); + Long.parseLong(tmpGVertex.getVertexId().toString())); + DoubleWritable vrtxValue = new DoubleWritable( + tmpGVertex.getVertexValue()); vertex.initialize(vrtxId, vrtxValue); if (tmpGVertex.getEdges() != null && !tmpGVertex.getEdges().isEmpty()) { - Set<Utf8> keyIt = tmpGVertex.getEdges().keySet(); - for (Utf8 key : keyIt) { + Set<CharSequence> keyIt = tmpGVertex.getEdges().keySet(); + for (CharSequence key : keyIt) { String keyVal = key.toString(); String valVal = tmpGVertex.getEdges().get(key).toString(); Edge<LongWritable, FloatWritable> edge; http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexOutputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexOutputFormat.java index 893e083..4a9c229 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexOutputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraGVertexVertexOutputFormat.java @@ -20,7 +20,6 @@ package org.apache.giraph.io.gora; import java.io.IOException; import java.util.Iterator; -import org.apache.avro.util.Utf8; import org.apache.giraph.edge.Edge; import org.apache.giraph.graph.Vertex; import org.apache.giraph.io.VertexWriter; @@ -60,15 +59,15 @@ public class GoraGVertexVertexOutputFormat protected Persistent getGoraVertex( Vertex<LongWritable, DoubleWritable, FloatWritable> vertex) { GVertexResult tmpGVertex = new GVertexResult(); - tmpGVertex.setVertexId(new Utf8(vertex.getId().toString())); - tmpGVertex.setValue(Float.parseFloat(vertex.getValue().toString())); + tmpGVertex.setVertexId(vertex.getId().toString()); + tmpGVertex.setVertexValue(Float.parseFloat(vertex.getValue().toString())); Iterator<Edge<LongWritable, FloatWritable>> it = vertex.getEdges().iterator(); while (it.hasNext()) { Edge<LongWritable, FloatWritable> edge = it.next(); - tmpGVertex.putToEdges( - new Utf8(edge.getTargetVertexId().toString()), - new Utf8(edge.getValue().toString())); + tmpGVertex.getEdges().put( + edge.getTargetVertexId().toString(), + edge.getValue().toString()); } return tmpGVertex; } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexInputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexInputFormat.java index 9a6ad8c..ee5e7b6 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexInputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexInputFormat.java @@ -30,12 +30,12 @@ import java.util.List; import org.apache.giraph.graph.Vertex; import org.apache.giraph.io.VertexInputFormat; import org.apache.giraph.io.VertexReader; -import org.apache.giraph.io.gora.utils.KeyFactory; import org.apache.giraph.io.gora.utils.ExtraGoraInputFormat; import org.apache.giraph.io.gora.utils.GoraUtils; +import org.apache.giraph.io.gora.utils.KeyFactory; import org.apache.gora.persistency.Persistent; -import org.apache.gora.query.Query; import org.apache.gora.query.Result; +import org.apache.gora.query.impl.QueryBase; import org.apache.gora.store.DataStore; import org.apache.gora.util.GoraException; import org.apache.hadoop.conf.Configuration; @@ -115,7 +115,7 @@ public abstract class GoraVertexInputFormat< setPersistentClass((Class<? extends Persistent>) persistentClass); setDatastoreClass((Class<? extends DataStore>) dataStoreClass); setKeyFactoryClass(keyFactoryClass); - setDataStore(createDataStore()); + setDataStore(createDataStore(conf)); GORA_INPUT_FORMAT.setDataStore(getDataStore()); } catch (ClassNotFoundException e) { LOG.error("Error while reading Gora Input parameters"); @@ -170,8 +170,9 @@ public abstract class GoraVertexInputFormat< setStartKey(kFact.buildKey(sKey)); setEndKey(kFact.buildKey(eKey)); } - Query tmpQuery = GoraUtils.getQuery( + QueryBase tmpQuery = GoraUtils.getQuery( getDataStore(), getStartKey(), getEndKey()); + tmpQuery.setConf(getConf()); GORA_INPUT_FORMAT.setQuery(tmpQuery); List<InputSplit> splits = GORA_INPUT_FORMAT.getSplits(context); return splits; @@ -179,12 +180,13 @@ public abstract class GoraVertexInputFormat< /** * Gets the data store object initialized. + * @param conf Configuration * @return DataStore created */ - public DataStore createDataStore() { + public DataStore createDataStore(Configuration conf) { DataStore dsCreated = null; try { - dsCreated = GoraUtils.createSpecificDataStore(getDatastoreClass(), + dsCreated = GoraUtils.createSpecificDataStore(conf, getDatastoreClass(), getKeyClass(), getPersistentClass()); } catch (GoraException e) { LOG.error("Error creating data store."); http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexOutputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexOutputFormat.java index 5fcc684..93143da 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexOutputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/GoraVertexOutputFormat.java @@ -30,6 +30,7 @@ import org.apache.giraph.io.gora.utils.GoraUtils; import org.apache.gora.persistency.Persistent; import org.apache.gora.store.DataStore; import org.apache.gora.util.GoraException; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; import org.apache.hadoop.mapreduce.JobContext; @@ -89,12 +90,13 @@ public abstract class GoraVertexOutputFormat< /** * Gets the data store object initialized. + * @param conf Configuration. * @return DataStore created */ - public DataStore createDataStore() { + public DataStore createDataStore(Configuration conf) { DataStore dsCreated = null; try { - dsCreated = GoraUtils.createSpecificDataStore(getDatastoreClass(), + dsCreated = GoraUtils.createSpecificDataStore(conf, getDatastoreClass(), getKeyClass(), getPersistentClass()); } catch (GoraException e) { getLogger().error("Error creating data store."); @@ -166,7 +168,7 @@ public abstract class GoraVertexOutputFormat< setKeyClass(keyClass); setPersistentClass((Class<? extends Persistent>) persistentClass); setDatastoreClass((Class<? extends DataStore>) dataStoreClass); - setDataStore(createDataStore()); + setDataStore(createDataStore(context.getConfiguration())); if (getDataStore() != null) { getLogger().info("The output data store has been created."); } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdge.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdge.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdge.java index f6ac3f7..c8b0667 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdge.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdge.java @@ -15,35 +15,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.giraph.io.gora.generated; -import org.apache.avro.Schema; -import org.apache.avro.AvroRuntimeException; -import org.apache.avro.util.Utf8; -import org.apache.gora.persistency.StateManager; -import org.apache.gora.persistency.impl.PersistentBase; -import org.apache.gora.persistency.impl.StateManagerImpl; - /** * Example class for defining a Giraph-Edge. */ @SuppressWarnings("all") -public class GEdge extends PersistentBase { - /** - * Schema used for the class. - */ - public static final Schema OBJ_SCHEMA = Schema.parse("{\"type\":\"record\"," + - "\"name\":\"GEdge\",\"namespace\":\"org.apache.giraph.gora.generated\"," + - "\"fields\":[{\"name\":\"edgeId\",\"type\":\"string\"}," + - "{\"name\":\"edgeWeight\",\"type\":\"float\"}," + - "{\"name\":\"vertexInId\",\"type\":\"string\"}," + - "{\"name\":\"vertexOutId\",\"type\":\"string\"}," + - "{\"name\":\"label\",\"type\":\"string\"}]}"); +public class GEdge extends org.apache.gora.persistency.impl.PersistentBase + implements org.apache.avro.specific.SpecificRecord, + org.apache.gora.persistency.Persistent { /** - * Field enum + * Schema used for the class. */ + public static final org.apache.avro.Schema SCHEMAS = + new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\"," + + "\"name\":\"GEdge\"," + + "\"namespace\":\"org.apache.giraph.gora.generated\"," + + "\"fields\":[{\"name\":\"edgeId\",\"type\":\"string\"}," + + "{\"name\":\"edgeWeight\",\"type\":\"float\"}," + + "{\"name\":\"vertexInId\",\"type\":\"string\"}," + + "{\"name\":\"vertexOutId\",\"type\":\"string\"}," + + "{\"name\":\"label\",\"type\":\"string\"}]}"); + + /** Enum containing all data bean's fields. */ public static enum Field { /** * Edge id. @@ -71,19 +66,19 @@ public class GEdge extends PersistentBase { LABEL(4, "label"); /** - * Field index + * Field's index. */ private int index; /** - * Field name + * Field's name. */ private String name; /** - * Field constructor - * @param index of attribute - * @param name of attribute + * Field's constructor + * @param index field's index. + * @param name field's name. */ Field(int index, String name) { this.index = index; @@ -91,24 +86,24 @@ public class GEdge extends PersistentBase { } /** - * Gets index - * @return int of attribute. + * Gets field's index. + * @return int field's index. */ public int getIndex() { return index; } /** - * Gets name - * @return String of name. + * Gets field's name. + * @return String field's name. */ public String getName() { return name; } /** - * Gets name - * @return String of name. + * Gets field's attributes to string. + * @return String field's attributes to string. */ public String toString() { return name; @@ -119,77 +114,61 @@ public class GEdge extends PersistentBase { * Array containing all fields/ */ private static final String[] ALL_FIELDS = { - "edgeId", "edgeWeight", "vertexInId", "vertexOutId", "label" - }; - - static { - PersistentBase.registerFields(GEdge.class, ALL_FIELDS); - } - - /** - * edgeId - */ - private Utf8 edgeId; + "edgeId", "edgeWeight", "vertexInId", "vertexOutId", "label"}; /** - * edgeWeight + * Tombstone. */ - private float edgeWeight; + private static final Tombstone TOMBSTONE = new Tombstone(); /** - * vertexInId + * edgeId. */ - private Utf8 vertexInId; + private java.lang.CharSequence edgeId; /** - * vertexOutId + * edgeWeight. */ - private Utf8 vertexOutId; + private float edgeWeight; /** - * label + * vertexInId. */ - private Utf8 label; + private java.lang.CharSequence vertexInId; /** - * Default constructor. + * vertexOutId. */ - public GEdge() { - this(new StateManagerImpl()); - } + private java.lang.CharSequence vertexOutId; /** - * Constructor - * @param stateManager from which the object will be created. + * label. */ - public GEdge(StateManager stateManager) { - super(stateManager); - } + private java.lang.CharSequence label; /** - * Creates a new instance - * @param stateManager from which the object will be created. - * @return GEdge created + * Gets the total field count. + * @return int field count */ - public GEdge newInstance(StateManager stateManager) { - return new GEdge(stateManager); + public int getFieldsCount() { + return GEdge.ALL_FIELDS.length; } /** - * Gets the object schema - * @return Schema of the object. + * Gets the schema + * @return Schema */ - public Schema getSchema() { - return OBJ_SCHEMA; + public org.apache.avro.Schema getSchema() { + return SCHEMAS; } /** * Gets field - * @param fieldIndex index field. + * @param field index field. * @return Object from an index. */ - public Object get(int fieldIndex) { - switch (fieldIndex) { + public java.lang.Object get(int field) { + switch (field) { case 0: return edgeId; case 1: @@ -201,114 +180,725 @@ public class GEdge extends PersistentBase { case 4: return label; default: - throw new AvroRuntimeException("Bad index"); + throw new org.apache.avro.AvroRuntimeException("Bad index"); } } /** * Puts a value into a field. - * @param fieldIndex index of field used. - * @param fieldValue value of field used. + * @param field index of field used. + * @param value value of field used. */ @SuppressWarnings(value = "unchecked") - public void put(int fieldIndex, Object fieldValue) { - if (isFieldEqual(fieldIndex, fieldValue)) { - return; - } - getStateManager().setDirty(this, fieldIndex); - switch (fieldIndex) { + public void put(int field, java.lang.Object value) { + switch (field) { case 0: - edgeId = (Utf8) fieldValue; break; + edgeId = (java.lang.CharSequence) value; + break; case 1: - edgeWeight = (Float) fieldValue; break; + edgeWeight = (java.lang.Float) value; + break; case 2: - vertexInId = (Utf8) fieldValue; break; + vertexInId = (java.lang.CharSequence) value; + break; case 3: - vertexOutId = (Utf8) fieldValue; break; + vertexOutId = (java.lang.CharSequence) value; + break; case 4: - label = (Utf8) fieldValue; break; + label = (java.lang.CharSequence) value; + break; default: - throw new AvroRuntimeException("Bad index"); + throw new org.apache.avro.AvroRuntimeException("Bad index"); } } /** - * Gets edgeId - * @return Utf8 edgeId + * Gets the value of the 'edgeId' field. + * @return CharSequence. + */ + public java.lang.CharSequence getEdgeId() { + return edgeId; + } + + /** + * Sets the value of the 'edgeId' field. + * @param value the value to set. + */ + public void setEdgeId(java.lang.CharSequence value) { + this.edgeId = value; + setDirty(0); + } + + /** + * Checks the dirty status of the 'edgeId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeIdDirty(java.lang.CharSequence value) { + return isDirty(0); + } + + /** + * Gets the value of the 'edgeWeight' field. + * @return Float */ - public Utf8 getEdgeId() { - return (Utf8) get(0); + public java.lang.Float getEdgeWeight() { + return edgeWeight; } /** - * Sets edgeId - * @param value edgeId + * Sets the value of the 'edgeWeight' field. + * @param value the value to set. */ - public void setEdgeId(Utf8 value) { - put(0, value); + public void setEdgeWeight(java.lang.Float value) { + this.edgeWeight = value; + setDirty(1); } /** - * Gets edgeWeight - * @return float edgeWeight + * Checks the dirty status of the 'edgeWeight' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean */ - public float getEdgeWeight() { - return (Float) get(1); + public boolean isEdgeWeightDirty(java.lang.Float value) { + return isDirty(1); } /** - * Sets edgeWeight - * @param value edgeWeight + * Gets the value of the 'vertexInId' field. + * @return CharSequence */ - public void setEdgeWeight(float value) { - put(1, value); + public java.lang.CharSequence getVertexInId() { + return vertexInId; } /** - * Gets edgeVertexInId - * @return Utf8 edgeVertexInId + * Sets the value of the 'vertexInId' field. + * @param value the value to set. */ - public Utf8 getVertexInId() { - return (Utf8) get(2); + public void setVertexInId(java.lang.CharSequence value) { + this.vertexInId = value; + setDirty(2); } /** - * Sets edgeVertexInId - * @param value edgeVertexInId + * Checks the dirty status of the 'vertexInId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean */ - public void setVertexInId(Utf8 value) { - put(2, value); + public boolean isVertexInIdDirty(java.lang.CharSequence value) { + return isDirty(2); } /** - * Gets edgeVertexOutId - * @return Utf8 edgeVertexOutId + * Gets the value of the 'vertexOutId' field. + * @return CharSequence */ - public Utf8 getVertexOutId() { - return (Utf8) get(3); + public java.lang.CharSequence getVertexOutId() { + return vertexOutId; } /** - * Sets edgeVertexOutId - * @param value edgeVertexOutId + * Sets the value of the 'vertexOutId' field. + * @param value the value to set. */ - public void setVertexOutId(Utf8 value) { - put(3, value); + public void setVertexOutId(java.lang.CharSequence value) { + this.vertexOutId = value; + setDirty(3); } /** - * Gets edgeLabel - * @return Utf8 edgeLabel + * Checks the dirty status of the 'vertexOutId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean */ - public Utf8 getLabel() { - return (Utf8) get(4); + public boolean isVertexOutIdDirty(java.lang.CharSequence value) { + return isDirty(3); } /** - * Sets edgeLabel - * @param value edgeLabel + * Gets the value of the 'label' field. + * @return CharSequence */ - public void setLabel(Utf8 value) { - put(4, value); + public java.lang.CharSequence getLabel() { + return label; + } + + /** + * Sets the value of the 'label' field. + * @param value the value to set. + */ + public void setLabel(java.lang.CharSequence value) { + this.label = value; + setDirty(4); + } + + /** + * Checks the dirty status of the 'label' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isLabelDirty(java.lang.CharSequence value) { + return isDirty(4); + } + + /** + * Creates a new GEdge RecordBuilder. + * @return GEdge.Builder + */ + public static org.apache.giraph.io.gora.generated.GEdge.Builder newBuilder() { + return new org.apache.giraph.io.gora.generated.GEdge.Builder(); + } + + /** + * Creates a new GEdge RecordBuilder by copying an existing Builder + * @param other GEdge.Builder + * @return org.apache.giraph.io.gora.generated.GEdge.Builder + */ + public static org.apache.giraph.io.gora.generated.GEdge.Builder newBuilder( + org.apache.giraph.io.gora.generated.GEdge.Builder other) { + return new org.apache.giraph.io.gora.generated.GEdge.Builder(other); + } + + /** + * Creates a new GEdge RecordBuilder by copying an existing GEdge instance. + * @param other GEdge + * @return org.apache.giraph.io.gora.generated.GEdge.Builder + */ + public static org.apache.giraph.io.gora.generated.GEdge.Builder newBuilder( + org.apache.giraph.io.gora.generated.GEdge other) { + return new org.apache.giraph.io.gora.generated.GEdge.Builder(other); + } + + /** + * Makes a deep copy from a bytebuffer. + * @param input ByteBuffer + * @return ByteBuffer + */ + private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer( + java.nio.ByteBuffer input) { + java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity()); + int position = input.position(); + input.reset(); + int mark = input.position(); + int limit = input.limit(); + input.rewind(); + input.limit(input.capacity()); + copy.put(input); + input.rewind(); + copy.rewind(); + input.position(mark); + input.mark(); + copy.position(mark); + copy.mark(); + input.position(position); + copy.position(position); + input.limit(limit); + copy.limit(limit); + return copy.asReadOnlyBuffer(); + } + + /** + * RecordBuilder for GEdge instances. + */ + public static class Builder extends + org.apache.avro.specific.SpecificRecordBuilderBase<GEdge> implements + org.apache.avro.data.RecordBuilder<GEdge> { + + /** + * edgeId. + */ + private java.lang.CharSequence edgeId; + + /** + * edgeWeight. + */ + private float edgeWeight; + + /** + * vertexInId + */ + private java.lang.CharSequence vertexInId; + + /** + * vertexOutId. + */ + private java.lang.CharSequence vertexOutId; + + /** + * label. + */ + private java.lang.CharSequence label; + + /** + * Creates a new Builder + */ + private Builder() { + super(org.apache.giraph.io.gora.generated.GEdge.SCHEMAS); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other GEdge.Builder + */ + private Builder(org.apache.giraph.io.gora.generated.GEdge.Builder other) { + super(other); + } + + /** + * Creates a Builder by copying an existing GEdge instance. + * @param other GEdge + */ + // CHECKSTYLE: stop Indentation + private Builder(org.apache.giraph.io.gora.generated.GEdge other) { + super(org.apache.giraph.io.gora.generated.GEdge.SCHEMAS); + if (isValidValue(fields()[0], other.edgeId)) { + this.edgeId = (java.lang.CharSequence) data().deepCopy( + fields()[0].schema(), other.edgeId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.edgeWeight)) { + this.edgeWeight = (java.lang.Float) data().deepCopy( + fields()[1].schema(), other.edgeWeight); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.vertexInId)) { + this.vertexInId = (java.lang.CharSequence) data().deepCopy( + fields()[2].schema(), other.vertexInId); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.vertexOutId)) { + this.vertexOutId = (java.lang.CharSequence) data().deepCopy( + fields()[3].schema(), other.vertexOutId); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.label)) { + this.label = (java.lang.CharSequence) data().deepCopy( + fields()[4].schema(), other.label); + fieldSetFlags()[4] = true; + } + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'edgeId' field + * @return CharSequence + */ + public java.lang.CharSequence getEdgeId() { + return edgeId; + } + + /** + * Sets the value of the 'edgeId' field + * @param value CharSequence + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder setEdgeId( + java.lang.CharSequence value) { + validate(fields()[0], value); + this.edgeId = value; + fieldSetFlags()[0] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'edgeId' field has been set. + * @return boolean. + */ + public boolean hasEdgeId() { + return fieldSetFlags()[0]; + } + + /** + * Clears the value of the 'edgeId' field. + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder clearEdgeId() { + edgeId = null; + fieldSetFlags()[0] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'edgeWeight' field. + * @return Float + */ + public java.lang.Float getEdgeWeight() { + return edgeWeight; + } + + /** + * Sets the value of the 'edgeWeight' field + * @param value float + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder setEdgeWeight( + float value) { + validate(fields()[1], value); + this.edgeWeight = value; + fieldSetFlags()[1] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'edgeWeight' field has been set. + * @return boolean + */ + public boolean hasEdgeWeight() { + return fieldSetFlags()[1]; + } + + /** + * Clears the value of the 'edgeWeight' field. + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder clearEdgeWeight() { + fieldSetFlags()[1] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexInId' field + * @return CharSequence + */ + public java.lang.CharSequence getVertexInId() { + return vertexInId; + } + + /** + * Sets the value of the 'vertexInId' field. + * @param value CharSequence + * @return value + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder setVertexInId( + java.lang.CharSequence value) { + validate(fields()[2], value); + this.vertexInId = value; + fieldSetFlags()[2] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexInId' field has been set. + * @return boolean + */ + public boolean hasVertexInId() { + return fieldSetFlags()[2]; + } + + /** + * Clears the value of the 'vertexInId' field. + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder + clearVertexInId() { + vertexInId = null; + fieldSetFlags()[2] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexOutId' field. + * @return java.lang.CharSequence + */ + public java.lang.CharSequence getVertexOutId() { + return vertexOutId; + } + + /** + * Sets the value of the 'vertexOutId' field. + * @param value CharSequence + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder setVertexOutId( + java.lang.CharSequence value) { + validate(fields()[3], value); + this.vertexOutId = value; + fieldSetFlags()[3] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexOutId' field has been set. + * @return boolean + */ + public boolean hasVertexOutId() { + return fieldSetFlags()[3]; + } + + /** + * Clears the value of the 'vertexOutId' field. + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder + clearVertexOutId() { + vertexOutId = null; + fieldSetFlags()[3] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'label' field. + * @return CharSequence + */ + public java.lang.CharSequence getLabel() { + return label; + } + + /** + * Sets the value of the 'label' field. + * @param value CharSequence + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder setLabel( + java.lang.CharSequence value) { + validate(fields()[4], value); + this.label = value; + fieldSetFlags()[4] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'label' field has been set. + * @return boolean + */ + public boolean hasLabel() { + return fieldSetFlags()[4]; + } + + /** + * Clears the value of the 'label' field. + * @return GEdge.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdge.Builder clearLabel() { + label = null; + fieldSetFlags()[4] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + @Override + /** + * Builds a GEdge. + * @return GEdge + */ + // CHECKSTYLE: stop IllegalCatch + public GEdge build() { + try { + GEdge record = new GEdge(); + record.edgeId = fieldSetFlags()[0] ? this.edgeId : + (java.lang.CharSequence) defaultValue(fields()[0]); + record.edgeWeight = fieldSetFlags()[1] ? this.edgeWeight : + (java.lang.Float) defaultValue(fields()[1]); + record.vertexInId = fieldSetFlags()[2] ? this.vertexInId : + (java.lang.CharSequence) defaultValue(fields()[2]); + record.vertexOutId = fieldSetFlags()[3] ? this.vertexOutId : + (java.lang.CharSequence) defaultValue(fields()[3]); + record.label = fieldSetFlags()[4] ? this.label : + (java.lang.CharSequence) defaultValue(fields()[4]); + return record; + } catch (Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + // CHECKSTYLE: resume IllegalCatch + } + + /** + * Gets a tombstone + * @return GEdge.Tombstone + */ + public GEdge.Tombstone getTombstone() { + return TOMBSTONE; + } + + /** + * Gets a new instance + * @return GEdge. + */ + public GEdge newInstance() { + return newBuilder().build(); + } + + /** + * Tombstone class. + */ + public static final class Tombstone extends GEdge implements + org.apache.gora.persistency.Tombstone { + + /** + * Default constructor. + */ + private Tombstone() { + } + + /** + * Gets the value of the 'edgeId' field. + * @return java.lang.CharSequence + */ + public java.lang.CharSequence getEdgeId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'edgeId' field. + * @param value the value to set. + */ + public void setEdgeId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'edgeId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'edgeWeight' field. + * @return Float + */ + public java.lang.Float getEdgeWeight() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'edgeWeight' field. + * @param value the value to set. + */ + public void setEdgeWeight(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'edgeWeight' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeWeightDirty(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'vertexInId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexInId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexInId' field. + * @param value the value to set. + */ + public void setVertexInId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexInId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isVertexInIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'vertexOutId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexOutId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexOutId' field. + * @param value the value to set. + */ + public void setVertexOutId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexOutId' field. A field is dirty if + * it represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isVertexOutIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'label' field. + * @return CharSequence + */ + public java.lang.CharSequence getLabel() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'label' field. + * @param value the value to set. + */ + public void setLabel(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'label' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isLabelDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } } } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdgeResult.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdgeResult.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdgeResult.java index 0c3501c..c54e40e 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdgeResult.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GEdgeResult.java @@ -15,35 +15,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.giraph.io.gora.generated; -import org.apache.avro.Schema; -import org.apache.avro.AvroRuntimeException; -import org.apache.avro.util.Utf8; -import org.apache.gora.persistency.StateManager; -import org.apache.gora.persistency.impl.PersistentBase; -import org.apache.gora.persistency.impl.StateManagerImpl; - /** - * Example Class for defining a Giraph-Edge. + * Example class for defining a Giraph-Edge result. */ @SuppressWarnings("all") -public class GEdgeResult extends PersistentBase { - /** - * Schema used for the class. - */ - public static final Schema OBJ_SCHEMA = Schema.parse("{\"type\":\"record\"," + - "\"name\":\"GEdge\",\"namespace\":\"org.apache.giraph.gora.generated\"," + - "\"fields\":[{\"name\":\"edgeId\",\"type\":\"string\"}," + - "{\"name\":\"edgeWeight\",\"type\":\"float\"}," + - "{\"name\":\"vertexInId\",\"type\":\"string\"}," + - "{\"name\":\"vertexOutId\",\"type\":\"string\"}," + - "{\"name\":\"label\",\"type\":\"string\"}]}"); +public class GEdgeResult extends + org.apache.gora.persistency.impl.PersistentBase implements + org.apache.avro.specific.SpecificRecord, + org.apache.gora.persistency.Persistent { /** - * Field enum + * Schema used for the class. */ + public static final org.apache.avro.Schema SCHEMAS = + new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\"," + + "\"name\":\"GEdgeResult\"," + + "\"namespace\":\"org.apache.giraph.io.gora.generated\"," + + "\"fields\":[{\"name\":\"edgeId\",\"type\":\"string\"}," + + "{\"name\":\"edgeWeight\",\"type\":\"float\"}," + + "{\"name\":\"vertexInId\",\"type\":\"string\"}," + + "{\"name\":\"vertexOutId\",\"type\":\"string\"}," + + "{\"name\":\"label\",\"type\":\"string\"}]}"); + + /** Enum containing all data bean's fields. */ public static enum Field { /** * Edge id. @@ -71,19 +67,19 @@ public class GEdgeResult extends PersistentBase { LABEL(4, "label"); /** - * Field index + * Field's index. */ private int index; /** - * Field name + * Field's name. */ private String name; /** - * Field constructor - * @param index of attribute - * @param name of attribute + * Field's constructor + * @param index field's index. + * @param name field's name. */ Field(int index, String name) { this.index = index; @@ -91,24 +87,24 @@ public class GEdgeResult extends PersistentBase { } /** - * Gets index - * @return int of attribute. + * Gets field's index. + * @return int field's index. */ public int getIndex() { return index; } /** - * Gets name - * @return String of name. + * Gets field's name. + * @return String field's name. */ public String getName() { return name; } /** - * Gets name - * @return String of name. + * Gets field's attributes to string. + * @return String field's attributes to string. */ public String toString() { return name; @@ -119,77 +115,61 @@ public class GEdgeResult extends PersistentBase { * Array containing all fields/ */ private static final String[] ALL_FIELDS = { - "edgeId", "edgeWeight", "vertexInId", "vertexOutId", "label" - }; - - static { - PersistentBase.registerFields(GEdgeResult.class, ALL_FIELDS); - } - - /** - * edgeId - */ - private Utf8 edgeId; + "edgeId", "edgeWeight", "vertexInId", "vertexOutId", "label"}; /** - * edgeWeight + * Tombstone. */ - private float edgeWeight; + private static final Tombstone TOMBSTONE = new Tombstone(); /** - * vertexInId + * edgeId. */ - private Utf8 vertexInId; + private java.lang.CharSequence edgeId; /** - * vertexOutId + * edgeWeight. */ - private Utf8 vertexOutId; + private float edgeWeight; /** - * label + * vertexInId. */ - private Utf8 label; + private java.lang.CharSequence vertexInId; /** - * Default constructor. + * vertexOutId. */ - public GEdgeResult() { - this(new StateManagerImpl()); - } + private java.lang.CharSequence vertexOutId; /** - * Constructor - * @param stateManager from which the object will be created. + * label. */ - public GEdgeResult(StateManager stateManager) { - super(stateManager); - } + private java.lang.CharSequence label; /** - * Creates a new instance - * @param stateManager from which the object will be created. - * @return GEdge created + * Gets the total field count. + * @return int field count */ - public GEdgeResult newInstance(StateManager stateManager) { - return new GEdgeResult(stateManager); + public int getFieldsCount() { + return GEdgeResult.ALL_FIELDS.length; } /** - * Gets the object schema - * @return Schema of the object. + * Gets the schema + * @return Schema */ - public Schema getSchema() { - return OBJ_SCHEMA; + public org.apache.avro.Schema getSchema() { + return SCHEMAS; } /** * Gets field - * @param fieldIndex index field. + * @param field index field. * @return Object from an index. */ - public Object get(int fieldIndex) { - switch (fieldIndex) { + public java.lang.Object get(int field) { + switch (field) { case 0: return edgeId; case 1: @@ -201,114 +181,729 @@ public class GEdgeResult extends PersistentBase { case 4: return label; default: - throw new AvroRuntimeException("Bad index"); + throw new org.apache.avro.AvroRuntimeException("Bad index"); } } /** * Puts a value into a field. - * @param fieldIndex index of field used. - * @param fieldValue value of field used. + * @param field index of field used. + * @param value value of field used. */ @SuppressWarnings(value = "unchecked") - public void put(int fieldIndex, Object fieldValue) { - if (isFieldEqual(fieldIndex, fieldValue)) { - return; - } - getStateManager().setDirty(this, fieldIndex); - switch (fieldIndex) { + public void put(int field, java.lang.Object value) { + switch (field) { case 0: - edgeId = (Utf8) fieldValue; break; + edgeId = (java.lang.CharSequence) value; + break; case 1: - edgeWeight = (Float) fieldValue; break; + edgeWeight = (java.lang.Float) value; + break; case 2: - vertexInId = (Utf8) fieldValue; break; + vertexInId = (java.lang.CharSequence) value; + break; case 3: - vertexOutId = (Utf8) fieldValue; break; + vertexOutId = (java.lang.CharSequence) value; + break; case 4: - label = (Utf8) fieldValue; break; + label = (java.lang.CharSequence) value; + break; default: - throw new AvroRuntimeException("Bad index"); + throw new org.apache.avro.AvroRuntimeException("Bad index"); } } /** - * Gets edgeId - * @return Utf8 edgeId + * Gets the value of the 'edgeId' field. + * @return CharSequence. + */ + public java.lang.CharSequence getEdgeId() { + return edgeId; + } + + /** + * Sets the value of the 'edgeId' field. + * @param value the value to set. + */ + public void setEdgeId(java.lang.CharSequence value) { + this.edgeId = value; + setDirty(0); + } + + /** + * Checks the dirty status of the 'edgeId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeIdDirty(java.lang.CharSequence value) { + return isDirty(0); + } + + /** + * Gets the value of the 'edgeWeight' field. + * @return Float + */ + public java.lang.Float getEdgeWeight() { + return edgeWeight; + } + + /** + * Sets the value of the 'edgeWeight' field. + * @param value the value to set. + */ + public void setEdgeWeight(java.lang.Float value) { + this.edgeWeight = value; + setDirty(1); + } + + /** + * Checks the dirty status of the 'edgeWeight' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeWeightDirty(java.lang.Float value) { + return isDirty(1); + } + + /** + * Gets the value of the 'vertexInId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexInId() { + return vertexInId; + } + + /** + * Sets the value of the 'vertexInId' field. + * @param value the value to set. */ - public Utf8 getEdgeId() { - return (Utf8) get(0); + public void setVertexInId(java.lang.CharSequence value) { + this.vertexInId = value; + setDirty(2); } /** - * Sets edgeId - * @param value edgeId + * Checks the dirty status of the 'vertexInId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean */ - public void setEdgeId(Utf8 value) { - put(0, value); + public boolean isVertexInIdDirty(java.lang.CharSequence value) { + return isDirty(2); } /** - * Gets edgeWeight - * @return float edgeWeight + * Gets the value of the 'vertexOutId' field. + * @return CharSequence */ - public float getEdgeWeight() { - return (Float) get(1); + public java.lang.CharSequence getVertexOutId() { + return vertexOutId; } /** - * Sets edgeWeight - * @param value edgeWeight + * Sets the value of the 'vertexOutId' field. + * @param value the value to set. */ - public void setEdgeWeight(float value) { - put(1, value); + public void setVertexOutId(java.lang.CharSequence value) { + this.vertexOutId = value; + setDirty(3); } /** - * Gets edgeVertexInId - * @return Utf8 edgeVertexInId + * Checks the dirty status of the 'vertexOutId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean */ - public Utf8 getVertexInId() { - return (Utf8) get(2); + public boolean isVertexOutIdDirty(java.lang.CharSequence value) { + return isDirty(3); } /** - * Sets edgeVertexInId - * @param value edgeVertexInId + * Gets the value of the 'label' field. + * @return CharSequence */ - public void setVertexInId(Utf8 value) { - put(2, value); + public java.lang.CharSequence getLabel() { + return label; } /** - * Gets edgeVertexOutId - * @return Utf8 edgeVertexOutId + * Sets the value of the 'label' field. + * @param value the value to set. */ - public Utf8 getVertexOutId() { - return (Utf8) get(3); + public void setLabel(java.lang.CharSequence value) { + this.label = value; + setDirty(4); } /** - * Sets edgeVertexOutId - * @param value edgeVertexOutId + * Checks the dirty status of the 'label' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean */ - public void setVertexOutId(Utf8 value) { - put(3, value); + public boolean isLabelDirty(java.lang.CharSequence value) { + return isDirty(4); } /** - * Gets edgeLabel - * @return Utf8 edgeLabel + * Creates a new GEdgeResult RecordBuilder. + * @return GEdge.Builder */ - public Utf8 getLabel() { - return (Utf8) get(4); + public static org.apache.giraph.io.gora.generated.GEdgeResult.Builder + newBuilder() { + return new org.apache.giraph.io.gora.generated.GEdgeResult.Builder(); } /** - * Sets edgeLabel - * @param value edgeLabel + * Creates a new GEdgeResult RecordBuilder by copying an existing Builder. + * @param other GEdgeResult.Builder + * @return GEdge.Builder */ - public void setLabel(Utf8 value) { - put(4, value); + public static org.apache.giraph.io.gora.generated.GEdgeResult.Builder + newBuilder(org.apache.giraph.io.gora.generated.GEdgeResult.Builder other) { + return new org.apache.giraph.io.gora.generated.GEdgeResult.Builder(other); + } + + /** + * Creates a new GEdgeResult RecordBuilder by copying an existing GEdgeResult + * instance + * @param other GEdgeResult + * @return GEdge.Builder + */ + public static org.apache.giraph.io.gora.generated.GEdgeResult.Builder + newBuilder(org.apache.giraph.io.gora.generated.GEdgeResult other) { + return new org.apache.giraph.io.gora.generated.GEdgeResult.Builder(other); + } + + /** + * Makes a deep copy from a bytebuffer. + * @param input ByteBuffer + * @return ByteBuffer + */ + private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer( + java.nio.ByteBuffer input) { + java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity()); + int position = input.position(); + input.reset(); + int mark = input.position(); + int limit = input.limit(); + input.rewind(); + input.limit(input.capacity()); + copy.put(input); + input.rewind(); + copy.rewind(); + input.position(mark); + input.mark(); + copy.position(mark); + copy.mark(); + input.position(position); + copy.position(position); + input.limit(limit); + copy.limit(limit); + return copy.asReadOnlyBuffer(); + } + + /** + * RecordBuilder for GEdgeResult instances. + */ + public static class Builder extends + org.apache.avro.specific.SpecificRecordBuilderBase<GEdgeResult> implements + org.apache.avro.data.RecordBuilder<GEdgeResult> { + + /** + * edgeId. + */ + private java.lang.CharSequence edgeId; + + /** + * edgeWeight. + */ + private float edgeWeight; + + /** + * vertexInId + */ + private java.lang.CharSequence vertexInId; + + /** + * vertexOutId. + */ + private java.lang.CharSequence vertexOutId; + + /** + * label. + */ + private java.lang.CharSequence label; + + /** Creates a new Builder */ + private Builder() { + super(org.apache.giraph.io.gora.generated.GEdgeResult.SCHEMAS); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other GEdgeResult.Builder + */ + private Builder( + org.apache.giraph.io.gora.generated.GEdgeResult.Builder other) { + super(other); + } + + /** + * Creates a Builder by copying an existing GEdgeResult instance. + * @param other GEdgeResult + */ + // CHECKSTYLE: stop Indentation + private Builder(org.apache.giraph.io.gora.generated.GEdgeResult other) { + super(org.apache.giraph.io.gora.generated.GEdgeResult.SCHEMAS); + if (isValidValue(fields()[0], other.edgeId)) { + this.edgeId = (java.lang.CharSequence) data().deepCopy( + fields()[0].schema(), other.edgeId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.edgeWeight)) { + this.edgeWeight = (java.lang.Float) data().deepCopy( + fields()[1].schema(), other.edgeWeight); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.vertexInId)) { + this.vertexInId = (java.lang.CharSequence) data().deepCopy( + fields()[2].schema(), other.vertexInId); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.vertexOutId)) { + this.vertexOutId = (java.lang.CharSequence) data().deepCopy( + fields()[3].schema(), other.vertexOutId); + fieldSetFlags()[3] = true; + } + if (isValidValue(fields()[4], other.label)) { + this.label = (java.lang.CharSequence) data().deepCopy( + fields()[4].schema(), other.label); + fieldSetFlags()[4] = true; + } + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'edgeId' field. + * @return CharSequence + */ + public java.lang.CharSequence getEdgeId() { + return edgeId; + } + + /** + * Sets the value of the 'edgeId' field. + * @param value CharSequence + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder setEdgeId( + java.lang.CharSequence value) { + validate(fields()[0], value); + this.edgeId = value; + fieldSetFlags()[0] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'edgeId' field has been set. + * @return boolean + */ + public boolean hasEdgeId() { + return fieldSetFlags()[0]; + } + + /** + * Clears the value of the 'edgeId' field. + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + clearEdgeId() { + edgeId = null; + fieldSetFlags()[0] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'edgeWeight' field. + * @return Float + */ + public java.lang.Float getEdgeWeight() { + return edgeWeight; + } + + /** + * Sets the value of the 'edgeWeight' field. + * @param value float + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + setEdgeWeight(float value) { + validate(fields()[1], value); + this.edgeWeight = value; + fieldSetFlags()[1] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'edgeWeight' field has been set. + * @return boolean + */ + public boolean hasEdgeWeight() { + return fieldSetFlags()[1]; + } + + /** + * Clears the value of the 'edgeWeight' field. + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + clearEdgeWeight() { + fieldSetFlags()[1] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexInId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexInId() { + return vertexInId; + } + + /** + * Sets the value of the 'vertexInId' field. + * @param value CharSequence + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + setVertexInId(java.lang.CharSequence value) { + validate(fields()[2], value); + this.vertexInId = value; + fieldSetFlags()[2] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexInId' field has been set. + * @return boolean. + */ + public boolean hasVertexInId() { + return fieldSetFlags()[2]; + } + + /** + * Clears the value of the 'vertexInId' field. + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + clearVertexInId() { + vertexInId = null; + fieldSetFlags()[2] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexOutId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexOutId() { + return vertexOutId; + } + + /** + * Sets the value of the 'vertexOutId' field. + * @param value CharSequence + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + setVertexOutId(java.lang.CharSequence value) { + validate(fields()[3], value); + this.vertexOutId = value; + fieldSetFlags()[3] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexOutId' field has been set. + * @return boolean + */ + public boolean hasVertexOutId() { + return fieldSetFlags()[3]; + } + + /** + * Clears the value of the 'vertexOutId' field. + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + clearVertexOutId() { + vertexOutId = null; + fieldSetFlags()[3] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'label' field. + * @return CharSequence + */ + public java.lang.CharSequence getLabel() { + return label; + } + + /** + * Sets the value of the 'label' field. + * @param value CharSequence + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder setLabel( + java.lang.CharSequence value) { + validate(fields()[4], value); + this.label = value; + fieldSetFlags()[4] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'label' field has been set. + * @return boolean + */ + public boolean hasLabel() { + return fieldSetFlags()[4]; + } + + /** + * Clears the value of the 'label' field. + * @return GEdgeResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GEdgeResult.Builder + clearLabel() { + label = null; + fieldSetFlags()[4] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + @Override + /** + * Builds a GEdgeResult. + * @return GEdgeResult + */ + // CHECKSTYLE: stop IllegalCatch + public GEdgeResult build() { + try { + GEdgeResult record = new GEdgeResult(); + record.edgeId = fieldSetFlags()[0] ? this.edgeId : + (java.lang.CharSequence) defaultValue(fields()[0]); + record.edgeWeight = fieldSetFlags()[1] ? this.edgeWeight : + (java.lang.Float) defaultValue(fields()[1]); + record.vertexInId = fieldSetFlags()[2] ? this.vertexInId : + (java.lang.CharSequence) defaultValue(fields()[2]); + record.vertexOutId = fieldSetFlags()[3] ? this.vertexOutId : + (java.lang.CharSequence) defaultValue(fields()[3]); + record.label = fieldSetFlags()[4] ? this.label : + (java.lang.CharSequence) defaultValue(fields()[4]); + return record; + } catch (Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + // CHECKSTYLE: resume IllegalCatch + } + + /** + * Gets tombstone + * @return GEdgeResult.Tombstone + */ + public GEdgeResult.Tombstone getTombstone() { + return TOMBSTONE; + } + + /** + * Gets a new instance + * @return GEdgeResult. + */ + public GEdgeResult newInstance() { + return newBuilder().build(); + } + + /** + * Tombstone class. + */ + public static final class Tombstone extends GEdgeResult implements + org.apache.gora.persistency.Tombstone { + + /** + * Default constructor. + */ + private Tombstone() { + } + + /** + * Gets the value of the 'edgeId' field. + * @return CharSequence + */ + public java.lang.CharSequence getEdgeId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'edgeId' field. + * @param value the value to set. + */ + public void setEdgeId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'edgeId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'edgeWeight' field. + * @return Float + */ + public java.lang.Float getEdgeWeight() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'edgeWeight' field. + * @param value the value to set. + */ + public void setEdgeWeight(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'edgeWeight' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isEdgeWeightDirty(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'vertexInId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexInId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexInId' field. + * @param value the value to set. + */ + public void setVertexInId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexInId' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isVertexInIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'vertexOutId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexOutId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexOutId' field. + * @param value the value to set. + */ + public void setVertexOutId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexOutId' field. A field is dirty if + * it represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isVertexOutIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'label' field. + * @return CharSequence + */ + public java.lang.CharSequence getLabel() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'label' field. + * @param value the value to set. + */ + public void setLabel(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'label' field. A field is dirty if it + * represents a change that has not yet been written to the database. + * @param value the value to set. + * @return boolean + */ + public boolean isLabelDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } } }
