http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertex.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertex.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertex.java index efd7b95..81b7c9a 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertex.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertex.java @@ -15,67 +15,59 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.giraph.io.gora.generated; -import java.util.Map; - -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.StatefulHashMap; -import org.apache.gora.persistency.impl.PersistentBase; -import org.apache.gora.persistency.impl.StateManagerImpl; - /** - * Example class for defining a Giraph-Vertex. + * Example class for defining a Giraph-vertex. */ @SuppressWarnings("all") -public class GVertex extends PersistentBase { - /** - * Schema used for the class. - */ - public static final Schema OBJ_SCHEMA = Schema.parse( - "{\"type\":\"record\",\"name\":\"Vertex\"," + - "\"namespace\":\"org.apache.giraph.gora.generated\"," + - "\"fields\":[{\"name\":\"vertexId\",\"type\":\"string\"}," + - "{\"name\":\"value\",\"type\":\"float\"},{\"name\":\"edges\"," + - "\"type\":{\"type\":\"map\",\"values\":\"string\"}}]}"); +public class GVertex 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\":\"GVertex\"," + + "\"namespace\":\"org.apache.giraph.io.gora.generated\"," + + "\"fields\":[{\"name\":\"vertexId\",\"type\":\"string\"}," + + "{\"name\":\"vertexValue\",\"type\":\"float\"}," + + "{\"name\":\"edges\",\"type\":" + + "{\"type\":\"map\",\"values\":\"string\"}}]}"); + + /** Enum containing all data bean's fields. */ public static enum Field { /** - * VertexId + * Vertex id. */ VERTEX_ID(0, "vertexId"), /** - * Field value + * Vertex value. */ - VALUE(1, "value"), + VERTEX_VALUE(1, "vertexValue"), /** - * Edges + * Vertex edges. */ EDGES(2, "edges"); /** - * 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; @@ -83,24 +75,24 @@ public class GVertex 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; @@ -111,170 +103,563 @@ public class GVertex extends PersistentBase { * Array containing all fields/ */ private static final String[] ALL_FIELDS = { - "vertexId", "value", "edges" - }; - - static { - PersistentBase.registerFields(GVertex.class, ALL_FIELDS); - } + "vertexId", "vertexValue", "edges", }; /** - * Vertex Id + * Tombstone. */ - private Utf8 vertexId; + private static final Tombstone TOMBSTONE = new Tombstone(); /** - * Value + * vertexId. */ - private float value; + private java.lang.CharSequence vertexId; /** - * Edges + * vertexValue. */ - private Map<Utf8, Utf8> edges; + private float vertexValue; /** - * Default constructor + * edges. */ - public GVertex() { - this(new StateManagerImpl()); - } + private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges; /** - * Constructor - * @param stateManager from which the object will be created. + * Gets the total field count. + * @return int field count */ - public GVertex(StateManager stateManager) { - super(stateManager); - edges = new StatefulHashMap<Utf8, Utf8>(); + public int getFieldsCount() { + return GVertex.ALL_FIELDS.length; } /** - * Creates a new instance - * @param stateManager from which the object will be created. - * @return GVertex created + * Gets the schema + * @return Schema */ - public GVertex newInstance(StateManager stateManager) { - return new GVertex(stateManager); - } - - /** - * Gets the object schema - * @return Schema of the object. - */ - public Schema getSchema() { - return OBJ_SCHEMA; + public org.apache.avro.Schema getSchema() { + return SCHEMAS; } /** * Gets field - * @param fieldIndex index of field to be used. + * @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 vertexId; case 1: - return value; + return vertexValue; case 2: return edges; 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: - vertexId = (Utf8) fieldValue; break; + vertexId = (java.lang.CharSequence) value; + break; case 1: - value = (Float) fieldValue; break; + vertexValue = (java.lang.Float) value; + break; case 2: - edges = (Map<Utf8, Utf8>) fieldValue; break; + edges = (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) + ((value instanceof org.apache.gora.persistency.Dirtyable) ? value : + new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map) + value)); + break; default: - throw new AvroRuntimeException("Bad index"); + throw new org.apache.avro.AvroRuntimeException("Bad index"); } } /** - * Gets vertexId - * @return Utf8 vertexId + * Gets the value of the 'vertexId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexId() { + return vertexId; + } + + /** + * Sets the value of the 'vertexId' field. + * @param value the value to set. + */ + public void setVertexId(java.lang.CharSequence value) { + this.vertexId = value; + setDirty(0); + } + + /** + * Checks the dirty status of the 'vertexId' 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 isVertexIdDirty(java.lang.CharSequence value) { + return isDirty(0); + } + + /** + * Gets the value of the 'vertexValue' field. + * @return Float + */ + public java.lang.Float getVertexValue() { + return vertexValue; + } + + /** + * Sets the value of the 'vertexValue' field. + * @param value the value to set. */ - public Utf8 getVertexId() { - return (Utf8) get(0); + public void setVertexValue(java.lang.Float value) { + this.vertexValue = value; + setDirty(1); } /** - * Sets vertexId - * @param value vertexId + * Checks the dirty status of the 'vertexValue' 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 setVertexId(Utf8 value) { - put(0, value); + public boolean isVertexValueDirty(java.lang.Float value) { + return isDirty(1); } /** - * Gets value - * @return String of value. + * Gets the value of the 'edges' field. + * @return java.util.Map */ - public float getValue() { - return (Float) get(1); + public java.util.Map<java.lang.CharSequence, java.lang.CharSequence> + getEdges() { + return edges; } /** - * Sets value - * @param value . + * Sets the value of the 'edges' field. + * @param value the value to set. */ - public void setValue(float value) { - put(1, value); + public void setEdges( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + this.edges = + (value instanceof org.apache.gora.persistency.Dirtyable) ? value : + new org.apache.gora.persistency.impl.DirtyMapWrapper(value); + setDirty(2); } /** - * Get edges. - * @return Map of edges. + * Checks the dirty status of the 'edges' 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 Map<Utf8, Utf8> getEdges() { - return (Map<Utf8, Utf8>) get(2); + public boolean isEdgesDirty( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + return isDirty(2); } /** - * Gets value from edge. - * @param key Edge key. - * @return Utf8 containing the value of edge. + * Creates a new GVertex RecordBuilder. + * @return GVertex.Builder */ - public Utf8 getFromEdges(Utf8 key) { - if (edges == null) { return null; } - return edges.get(key); + public static org.apache.giraph.io.gora.generated.GVertex.Builder + newBuilder() { + return new org.apache.giraph.io.gora.generated.GVertex.Builder(); } /** - * Puts a new edge. - * @param key of new edge. - * @param value of new edge. + * Creates a new GVertex RecordBuilder by copying an existing Builder. + * @param other GVertex.Builder + * @return GVertex.Builder */ - public void putToEdges(Utf8 key, Utf8 value) { - getStateManager().setDirty(this, 2); - edges.put(key, value); + public static org.apache.giraph.io.gora.generated.GVertex.Builder newBuilder( + org.apache.giraph.io.gora.generated.GVertex.Builder other) { + return new org.apache.giraph.io.gora.generated.GVertex.Builder(other); } /** - * Remove from edges - * @param key of edge to be deleted. - * @return Utf8 containing value of deleted key. + * Creates a new GVertex RecordBuilder by copying + * an existing GVertex instance + * @param other GVertex + * @return GVertex.Builder */ - public Utf8 removeFromEdges(Utf8 key) { - if (edges == null) { return null; } - getStateManager().setDirty(this, 2); - return edges.remove(key); + public static org.apache.giraph.io.gora.generated.GVertex.Builder newBuilder( + org.apache.giraph.io.gora.generated.GVertex other) { + return new org.apache.giraph.io.gora.generated.GVertex.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 GVertex instances. + */ + public static class Builder extends + org.apache.avro.specific.SpecificRecordBuilderBase<GVertex> implements + org.apache.avro.data.RecordBuilder<GVertex> { + + /** + * vertexId + */ + private java.lang.CharSequence vertexId; + + /** + * vertexValue + */ + private float vertexValue; + + /** + * edges + */ + private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges; + + /** Creates a new Builder */ + private Builder() { + super(org.apache.giraph.io.gora.generated.GVertex.SCHEMAS); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other GVertex + */ + private Builder(org.apache.giraph.io.gora.generated.GVertex.Builder other) { + super(other); + } + + /** + * Creates a Builder by copying an existing GVertex instance. + * @param other GVertex + */ + // CHECKSTYLE: stop Indentation + private Builder(org.apache.giraph.io.gora.generated.GVertex other) { + super(org.apache.giraph.io.gora.generated.GVertex.SCHEMAS); + if (isValidValue(fields()[0], other.vertexId)) { + this.vertexId = (java.lang.CharSequence) data().deepCopy( + fields()[0].schema(), other.vertexId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.vertexValue)) { + this.vertexValue = (java.lang.Float) data().deepCopy( + fields()[1].schema(), other.vertexValue); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.edges)) { + this.edges = + (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) + data().deepCopy(fields()[2].schema(), other.edges); + fieldSetFlags()[2] = true; + } + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexId' field. + * @return CharSsequence + */ + public java.lang.CharSequence getVertexId() { + return vertexId; + } + + /** + * Sets the value of the 'vertexId' field. + * @param value CharSequence + * @return GVertex.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertex.Builder setVertexId( + java.lang.CharSequence value) { + validate(fields()[0], value); + this.vertexId = value; + fieldSetFlags()[0] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexId' field has been set. + * @return boolean + */ + public boolean hasVertexId() { + return fieldSetFlags()[0]; + } + + /** + * Clears the value of the 'vertexId' field + * @return GVertex.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertex.Builder clearVertexId() { + vertexId = null; + fieldSetFlags()[0] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexValue' field + * @return Float + */ + public java.lang.Float getVertexValue() { + return vertexValue; + } + + /** + * Sets the value of the 'vertexValue' field. + * @param value float + * @return GVertex.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertex.Builder setVertexValue( + float value) { + validate(fields()[1], value); + this.vertexValue = value; + fieldSetFlags()[1] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexValue' field has been set. + * @return boolean + */ + public boolean hasVertexValue() { + return fieldSetFlags()[1]; + } + + /** + * Clears the value of the 'vertexValue' field. + * @return GVertex.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertex.Builder + clearVertexValue() { + fieldSetFlags()[1] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'edges' field. + * @return java.util.Map + */ + public java.util.Map<java.lang.CharSequence, java.lang.CharSequence> + getEdges() { + return edges; + } + + /** + * Sets the value of the 'edges' field. + * @param value java.util.Map + * @return GVertex.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertex.Builder setEdges( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + validate(fields()[2], value); + this.edges = value; + fieldSetFlags()[2] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'edges' field has been set. + * @return boolean + */ + public boolean hasEdges() { + return fieldSetFlags()[2]; + } + + /** + * Clears the value of the 'edges' field. + * @return org.apache.giraph.io.gora.generated.GVertex.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertex.Builder clearEdges() { + edges = null; + fieldSetFlags()[2] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + @Override + /** + * Builds a GVertex. + * @return GVertex + */ + // CHECKSTYLE: stop IllegalCatch + public GVertex build() { + try { + GVertex record = new GVertex(); + record.vertexId = fieldSetFlags()[0] ? this.vertexId : + (java.lang.CharSequence) defaultValue(fields()[0]); + record.vertexValue = fieldSetFlags()[1] ? this.vertexValue : + (java.lang.Float) defaultValue(fields()[1]); + record.edges = fieldSetFlags()[2] ? this.edges : + (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) + new org.apache.gora.persistency.impl.DirtyMapWrapper( + (java.util.Map) defaultValue(fields()[2])); + return record; + } catch (Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + // CHECKSTYLE: resume IllegalCatch + } + + /** + * Gets tombstone + * @return GVertex.Tombstone + */ + public GVertex.Tombstone getTombstone() { + return TOMBSTONE; + } + + /** + * Gets a new instance + * @return GVertex. + */ + public GVertex newInstance() { + return newBuilder().build(); + } + + /** + * Tombstone class. + */ + public static final class Tombstone extends GVertex implements + org.apache.gora.persistency.Tombstone { + + /** + * Default constructor. + */ + private Tombstone() { + } + + /** + * Gets the value of the 'vertexId' field. + * @return java.lang.CharSequence + */ + public java.lang.CharSequence getVertexId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexId' field. + * @param value the value to set. + */ + public void setVertexId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexId' 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 isVertexIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'vertexValue' field. + * @return Float + */ + public java.lang.Float getVertexValue() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexValue' field. + * @param value the value to set. + */ + public void setVertexValue(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexValue' 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 isVertexValueDirty(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'edges' field. + * @return java.util.Map + */ + public java.util.Map<java.lang.CharSequence, java.lang.CharSequence> + getEdges() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'edges' field. + * @param value the value to set. + */ + public void setEdges( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'edges' 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 isEdgesDirty( + java.util.Map<java.lang.CharSequence, 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/GVertexResult.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertexResult.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertexResult.java index 2c1952d..394fb8b 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertexResult.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/generated/GVertexResult.java @@ -15,67 +15,60 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.giraph.io.gora.generated; -import java.util.Map; - -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.StatefulHashMap; -import org.apache.gora.persistency.impl.PersistentBase; -import org.apache.gora.persistency.impl.StateManagerImpl; - /** - * Example class for defining a Giraph-Vertex. + * Example class for defining a Giraph-vertex result. */ @SuppressWarnings("all") -public class GVertexResult extends PersistentBase { - /** - * Schema used for the class. - */ - public static final Schema OBJ_SCHEMA = Schema.parse( - "{\"type\":\"record\",\"name\":\"Vertex\"," + - "\"namespace\":\"org.apache.giraph.gora.generated\"," + - "\"fields\":[{\"name\":\"vertexId\",\"type\":\"string\"}," + - "{\"name\":\"value\",\"type\":\"float\"},{\"name\":\"edges\"," + - "\"type\":{\"type\":\"map\",\"values\":\"string\"}}]}"); +public class GVertexResult 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\":\"GVertexResult\"," + + "\"namespace\":\"org.apache.giraph.io.gora.generated\"," + + "\"fields\":[{\"name\":\"vertexId\",\"type\":\"string\"}," + + "{\"name\":\"vertexValue\",\"type\":\"float\"}," + + "{\"name\":\"edges\",\"type\":" + + "{\"type\":\"map\",\"values\":\"string\"}}]}"); + + /** Enum containing all data bean's fields. */ public static enum Field { /** - * VertexId + * Vertex id. */ VERTEX_ID(0, "vertexId"), /** - * Field value + * Vertex value. */ - VALUE(1, "value"), + VERTEX_VALUE(1, "vertexValue"), /** - * Edges + * Vertex edges. */ EDGES(2, "edges"); /** - * 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; @@ -83,24 +76,24 @@ public class GVertexResult 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; @@ -111,170 +104,565 @@ public class GVertexResult extends PersistentBase { * Array containing all fields/ */ private static final String[] ALL_FIELDS = { - "vertexId", "value", "edges" - }; - - static { - PersistentBase.registerFields(GVertexResult.class, ALL_FIELDS); - } + "vertexId", "vertexValue", "edges", }; /** - * Vertex Id + * Tombstone. */ - private Utf8 vertexId; + private static final Tombstone TOMBSTONE = new Tombstone(); /** - * Value + * vertexId. */ - private float value; + private java.lang.CharSequence vertexId; /** - * Edges + * vertexValue. */ - private Map<Utf8, Utf8> edges; + private float vertexValue; /** - * Default constructor + * edges. */ - public GVertexResult() { - this(new StateManagerImpl()); - } + private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges; /** - * Constructor - * @param stateManager from which the object will be created. + * Gets the total field count. + * @return int field count */ - public GVertexResult(StateManager stateManager) { - super(stateManager); - edges = new StatefulHashMap<Utf8, Utf8>(); + public int getFieldsCount() { + return GVertexResult.ALL_FIELDS.length; } /** - * Creates a new instance - * @param stateManager from which the object will be created. - * @return GVertex created + * Gets the schema + * @return Schema */ - public GVertexResult newInstance(StateManager stateManager) { - return new GVertexResult(stateManager); - } - - /** - * Gets the object schema - * @return Schema of the object. - */ - public Schema getSchema() { - return OBJ_SCHEMA; + public org.apache.avro.Schema getSchema() { + return SCHEMAS; } /** * Gets field - * @param fieldIndex index of field to be used. + * @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 vertexId; case 1: - return value; + return vertexValue; case 2: return edges; 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: - vertexId = (Utf8) fieldValue; break; + vertexId = (java.lang.CharSequence) value; + break; case 1: - value = (Float) fieldValue; break; + vertexValue = (java.lang.Float) value; + break; case 2: - edges = (Map<Utf8, Utf8>) fieldValue; break; + edges = (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) + ((value instanceof org.apache.gora.persistency.Dirtyable) ? value : + new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map) + value)); + break; default: - throw new AvroRuntimeException("Bad index"); + throw new org.apache.avro.AvroRuntimeException("Bad index"); } } /** - * Gets vertexId - * @return Utf8 vertexId + * Gets the value of the 'vertexId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexId() { + return vertexId; + } + + /** + * Sets the value of the 'vertexId' field. + * @param value the value to set. + */ + public void setVertexId(java.lang.CharSequence value) { + this.vertexId = value; + setDirty(0); + } + + /** + * Checks the dirty status of the 'vertexId' 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 isVertexIdDirty(java.lang.CharSequence value) { + return isDirty(0); + } + + /** + * Gets the value of the 'vertexValue' field. + * @return Float + */ + public java.lang.Float getVertexValue() { + return vertexValue; + } + + /** + * Sets the value of the 'vertexValue' field. + * @param value the value to set. */ - public Utf8 getVertexId() { - return (Utf8) get(0); + public void setVertexValue(java.lang.Float value) { + this.vertexValue = value; + setDirty(1); } /** - * Sets vertexId - * @param value vertexId + * Checks the dirty status of the 'vertexValue' 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 setVertexId(Utf8 value) { - put(0, value); + public boolean isVertexValueDirty(java.lang.Float value) { + return isDirty(1); } /** - * Gets value - * @return String of value. + * Gets the value of the 'edges' field. + * @return Edges */ - public float getValue() { - return (Float) get(1); + public java.util.Map<java.lang.CharSequence, java.lang.CharSequence> + getEdges() { + return edges; } /** - * Sets value - * @param value . + * Sets the value of the 'edges' field. + * @param value the value to set. */ - public void setValue(float value) { - put(1, value); + public void setEdges( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + this.edges = (value instanceof org.apache.gora.persistency.Dirtyable) ? + value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value); + setDirty(2); } /** - * Get edges. - * @return Map of edges. + * Checks the dirty status of the 'edges' 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 Map<Utf8, Utf8> getEdges() { - return (Map<Utf8, Utf8>) get(2); + public boolean isEdgesDirty( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + return isDirty(2); } /** - * Gets value from edge. - * @param key Edge key. - * @return Utf8 containing the value of edge. + * Creates a new GVertexResult RecordBuilder + * @return GVertexResult.Builder */ - public Utf8 getFromEdges(Utf8 key) { - if (edges == null) { return null; } - return edges.get(key); + public static org.apache.giraph.io.gora.generated.GVertexResult.Builder + newBuilder() { + return new org.apache.giraph.io.gora.generated.GVertexResult.Builder(); } /** - * Puts a new edge. - * @param key of new edge. - * @param value of new edge. + * Creates a new GVertexResult RecordBuilder by copying an existing Builder. + * @param other GVertexResult.Builder + * @return GVertexResult.Builder */ - public void putToEdges(Utf8 key, Utf8 value) { - getStateManager().setDirty(this, 2); - edges.put(key, value); + public static org.apache.giraph.io.gora.generated.GVertexResult.Builder + newBuilder(org.apache.giraph.io.gora.generated.GVertexResult.Builder other) { + return new org.apache.giraph.io.gora.generated.GVertexResult.Builder(other); } /** - * Remove from edges - * @param key of edge to be deleted. - * @return Utf8 containing value of deleted key. + * Creates a new GVertexResult RecordBuilder by copying an existing + * GVertexResult instance + * @param other GVertexResult + * @return GVertexResult.Builder */ - public Utf8 removeFromEdges(Utf8 key) { - if (edges == null) { return null; } - getStateManager().setDirty(this, 2); - return edges.remove(key); + public static org.apache.giraph.io.gora.generated.GVertexResult.Builder + newBuilder(org.apache.giraph.io.gora.generated.GVertexResult other) { + return new org.apache.giraph.io.gora.generated.GVertexResult.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 GVertexResult instances. + */ + public static class Builder extends + org.apache.avro.specific.SpecificRecordBuilderBase<GVertexResult> + implements org.apache.avro.data.RecordBuilder<GVertexResult> { + + /** + * vertexId + */ + private java.lang.CharSequence vertexId; + + /** + * vertexValue + */ + private float vertexValue; + + /** + * edges + */ + private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges; + + /** Creates a new Builder */ + private Builder() { + super(org.apache.giraph.io.gora.generated.GVertexResult.SCHEMAS); + } + + /** + * Creates a Builder by copying an existing Builder. + * @param other GVertexResult.Builder + */ + private Builder( + org.apache.giraph.io.gora.generated.GVertexResult.Builder other) { + super(other); + } + + /** + * Creates a Builder by copying an existing GVertexResult instance. + * @param other GVertexResult + */ + // CHECKSTYLE: stop Indentation + private Builder(org.apache.giraph.io.gora.generated.GVertexResult other) { + super(org.apache.giraph.io.gora.generated.GVertexResult.SCHEMAS); + if (isValidValue(fields()[0], other.vertexId)) { + this.vertexId = (java.lang.CharSequence) data().deepCopy( + fields()[0].schema(), other.vertexId); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.vertexValue)) { + this.vertexValue = (java.lang.Float) data().deepCopy( + fields()[1].schema(), other.vertexValue); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.edges)) { + this.edges = + (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) + data().deepCopy(fields()[2].schema(), other.edges); + fieldSetFlags()[2] = true; + } + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexId' field. + * @return CharSequence + */ + public java.lang.CharSequence getVertexId() { + return vertexId; + } + + /** + * Sets the value of the 'vertexId' field. + * @param value CharSequence + * @return GVertexResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertexResult.Builder + setVertexId(java.lang.CharSequence value) { + validate(fields()[0], value); + this.vertexId = value; + fieldSetFlags()[0] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexId' field has been set. + * @return boolean + */ + public boolean hasVertexId() { + return fieldSetFlags()[0]; + } + + /** + * Clears the value of the 'vertexId' field + * @return GVertexResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertexResult.Builder + clearVertexId() { + vertexId = null; + fieldSetFlags()[0] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'vertexValue' field. + * @return Float + */ + public java.lang.Float getVertexValue() { + return vertexValue; + } + + /** + * Sets the value of the 'vertexValue' field. + * @param value float + * @return GVertexResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertexResult.Builder + setVertexValue(float value) { + validate(fields()[1], value); + this.vertexValue = value; + fieldSetFlags()[1] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'vertexValue' field has been set. + * @return boolean + */ + public boolean hasVertexValue() { + return fieldSetFlags()[1]; + } + + /** + * Clears the value of the 'vertexValue' field. + * @return GVertexResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertexResult.Builder + clearVertexValue() { + fieldSetFlags()[1] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Gets the value of the 'edges' field. + * @return java.util.Map + */ + public java.util.Map<java.lang.CharSequence, java.lang.CharSequence> + getEdges() { + return edges; + } + + /** + * Sets the value of the 'edges' field + * @param value java.util.Map + * @return GVertexResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertexResult.Builder setEdges( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + validate(fields()[2], value); + this.edges = value; + fieldSetFlags()[2] = true; + return this; + } + // CHECKSTYLE: resume Indentation + + /** + * Checks whether the 'edges' field has been set. + * @return boolean + */ + public boolean hasEdges() { + return fieldSetFlags()[2]; + } + + /** + * Clears the value of the 'edges' field. + * @return org.apache.giraph.io.gora.generated.GVertexResult.Builder + */ + // CHECKSTYLE: stop Indentation + public org.apache.giraph.io.gora.generated.GVertexResult.Builder + clearEdges() { + edges = null; + fieldSetFlags()[2] = false; + return this; + } + // CHECKSTYLE: resume Indentation + + @Override + /** + * Builds a GVertexResult. + * @return GVertexResult + */ + // CHECKSTYLE: stop IllegalCatch + public GVertexResult build() { + try { + GVertexResult record = new GVertexResult(); + record.vertexId = fieldSetFlags()[0] ? this.vertexId : + (java.lang.CharSequence) defaultValue(fields()[0]); + record.vertexValue = fieldSetFlags()[1] ? this.vertexValue : + (java.lang.Float) defaultValue(fields()[1]); + record.edges = fieldSetFlags()[2] ? this.edges : + (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) + new org.apache.gora.persistency.impl.DirtyMapWrapper( + (java.util.Map) defaultValue(fields()[2])); + return record; + } catch (Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + // CHECKSTYLE: resume IllegalCatch + } + + /** + * Gets tombstone + * @return GVertex.Tombstone + */ + public GVertexResult.Tombstone getTombstone() { + return TOMBSTONE; + } + + /** + * Gets a new instance + * @return GVertexResult. + */ + public GVertexResult newInstance() { + return newBuilder().build(); + } + + /** + * Tombstone class. + */ + public static final class Tombstone extends GVertexResult implements + org.apache.gora.persistency.Tombstone { + + /** + * Default constructor. + */ + private Tombstone() { + } + + /** + * Gets the value of the 'vertexId' field. + * @return java.lang.CharSequence + */ + public java.lang.CharSequence getVertexId() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexId' field. + * @param value the value to set. + */ + public void setVertexId(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexId' 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 isVertexIdDirty(java.lang.CharSequence value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'vertexValue' field. + * @return Float + */ + public java.lang.Float getVertexValue() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'vertexValue' field. + * @param value the value to set. + */ + public void setVertexValue(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'vertexValue' 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 isVertexValueDirty(java.lang.Float value) { + throw new java.lang.UnsupportedOperationException( + "IsDirty is not supported on tombstones"); + } + + /** + * Gets the value of the 'edges' field. + * @return java.util.Map + */ + public java.util.Map<java.lang.CharSequence, java.lang.CharSequence> + getEdges() { + throw new java.lang.UnsupportedOperationException( + "Get is not supported on tombstones"); + } + + /** + * Sets the value of the 'edges' field. + * @param value the value to set. + */ + public void setEdges( + java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) { + throw new java.lang.UnsupportedOperationException( + "Set is not supported on tombstones"); + } + + /** + * Checks the dirty status of the 'edges' 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 isEdgesDirty( + java.util.Map<java.lang.CharSequence, 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/utils/ExtraGoraInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/ExtraGoraInputFormat.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/ExtraGoraInputFormat.java index e11f910..b40a361 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/ExtraGoraInputFormat.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/ExtraGoraInputFormat.java @@ -28,6 +28,7 @@ import org.apache.gora.persistency.Persistent; import org.apache.gora.persistency.impl.PersistentBase; import org.apache.gora.query.PartitionQuery; import org.apache.gora.query.Query; +import org.apache.gora.query.impl.PartitionQueryImpl; import org.apache.gora.store.DataStore; import org.apache.gora.util.IOUtils; import org.apache.hadoop.conf.Configuration; @@ -83,17 +84,21 @@ public class ExtraGoraInputFormat<K, T extends PersistentBase> return new GoraRecordReader<K, T>(partitionQuery, context); } + /** + * Gets splits. + * @param context for the job. + * @return List<InputSplit> splits found + */ @Override public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException { List<PartitionQuery<K, T>> queries = getDataStore().getPartitions(getQuery()); List<InputSplit> splits = new ArrayList<InputSplit>(queries.size()); - for (PartitionQuery<K, T> partQuery : queries) { + ((PartitionQueryImpl) partQuery).setConf(context.getConfiguration()); splits.add(new GoraInputSplit(context.getConfiguration(), partQuery)); } - return splits; } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/GoraUtils.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/GoraUtils.java b/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/GoraUtils.java index c3fc268..932e2f3 100644 --- a/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/GoraUtils.java +++ b/giraph-gora/src/main/java/org/apache/giraph/io/gora/utils/GoraUtils.java @@ -20,6 +20,7 @@ package org.apache.giraph.io.gora.utils; 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.store.DataStoreFactory; import org.apache.gora.util.GoraException; @@ -36,11 +37,6 @@ public class GoraUtils { private static Class<? extends DataStore> DATASTORECLASS; /** - * Attribute handling configuration for data stores. - */ - private static Configuration CONF = new Configuration(); - - /** * The default constructor is set to be private by default so that the * class is not instantiated. */ @@ -49,6 +45,7 @@ public class GoraUtils { /** * Creates a generic data store using the data store class. * set using the class property + * @param conf Configuration * @param <K> key class * @param <T> value class * @param keyClass key class used @@ -58,20 +55,22 @@ public class GoraUtils { */ @SuppressWarnings("unchecked") public static <K, T extends Persistent> DataStore<K, T> - createDataStore(Class<K> keyClass, Class<T> persistentClass) + createDataStore(Configuration conf, + Class<K> keyClass, Class<T> persistentClass) throws GoraException { DataStoreFactory.createProps(); DataStore<K, T> dataStore = DataStoreFactory.createDataStore((Class<? extends DataStore<K, T>>) DATASTORECLASS, keyClass, persistentClass, - getConf()); + conf); return dataStore; } /** * Creates a specific data store specified by. + * @param conf Configuration * @param <K> key class * @param <T> value class * @param dataStoreClass Defines the type of data store used. @@ -81,10 +80,11 @@ public class GoraUtils { * @throws GoraException if an error occurs. */ public static <K, T extends Persistent> DataStore<K, T> - createSpecificDataStore(Class<? extends DataStore> dataStoreClass, + createSpecificDataStore(Configuration conf, + Class<? extends DataStore> dataStoreClass, Class<K> keyClass, Class<T> persistentClass) throws GoraException { DATASTORECLASS = dataStoreClass; - return createDataStore(keyClass, persistentClass); + return createDataStore(conf, keyClass, persistentClass); } /** @@ -98,7 +98,7 @@ public class GoraUtils { */ public static <K, T extends Persistent> Result<K, T> getRequest(DataStore<K, T> pDataStore, K pStartKey, K pEndKey) { - Query<K, T> query = getQuery(pDataStore, pStartKey, pEndKey); + QueryBase query = getQuery(pDataStore, pStartKey, pEndKey); return getRequest(pDataStore, query); } @@ -137,9 +137,9 @@ public class GoraUtils { * @param <T> value class * @return range query object. */ - public static <K, T extends Persistent> Query<K, T> - getQuery(DataStore<K, T> pDataStore, K pStartKey, K pEndKey) { - Query<K, T> query = pDataStore.newQuery(); + public static <K, T extends Persistent> QueryBase + getQuery(DataStore pDataStore, K pStartKey, K pEndKey) { + QueryBase query = (QueryBase) pDataStore.newQuery(); query.setStartKey(pStartKey); query.setEndKey(pEndKey); return query; @@ -175,20 +175,4 @@ public class GoraUtils { query.setEndKey(null); return query; } - - /** - * Gets the configuration object. - * @return the configuration object. - */ - public static Configuration getConf() { - return CONF; - } - - /** - * Sets the configuration object. - * @param conf to be set as the configuration object. - */ - public static void setConf(Configuration conf) { - CONF = conf; - } } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeInputFormat.java b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeInputFormat.java index ba71ce4..c339eb0 100644 --- a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeInputFormat.java +++ b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeInputFormat.java @@ -19,10 +19,8 @@ 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.edge.EdgeFactory; -import org.apache.giraph.io.gora.GoraEdgeInputFormat; import org.apache.giraph.io.gora.generated.GEdge; import org.apache.hadoop.io.FloatWritable; import org.apache.hadoop.io.LongWritable; @@ -82,10 +80,10 @@ public class GoraTestEdgeInputFormat private static GEdge createEdge(String id, String vertexInId, String vertexOutId, String edgeLabel, float edgeWeight) { GEdge newEdge = new GEdge(); - newEdge.setEdgeId(new Utf8(id)); - newEdge.setVertexInId(new Utf8(vertexInId)); - newEdge.setVertexOutId(new Utf8(vertexOutId)); - newEdge.setLabel(new Utf8(edgeLabel)); + newEdge.setEdgeId(id); + newEdge.setVertexInId(vertexInId); + newEdge.setVertexOutId(vertexOutId); + newEdge.setLabel(edgeLabel); newEdge.setEdgeWeight(edgeWeight); return newEdge; } @@ -109,11 +107,11 @@ public class GoraTestEdgeInputFormat Edge<LongWritable, FloatWritable> edge = null; GEdge goraEdge = (GEdge) goraObject; Long dest; - Long value; + Float value; dest = Long.valueOf(goraEdge.getVertexOutId().toString()); this.sourceId = new LongWritable(); this.sourceId.set(Long.valueOf(goraEdge.getVertexInId().toString())); - value = (long) goraEdge.getEdgeWeight(); + value = (float) goraEdge.getEdgeWeight(); edge = EdgeFactory.create(new LongWritable(dest), new FloatWritable(value)); return edge; http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeOutputFormat.java b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeOutputFormat.java index 0254498..f2e88c6 100644 --- a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeOutputFormat.java +++ b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestEdgeOutputFormat.java @@ -19,11 +19,8 @@ package org.apache.giraph.io.gora; import java.io.IOException; -import junit.framework.Assert; - import org.apache.avro.util.Utf8; import org.apache.giraph.edge.Edge; -import org.apache.giraph.io.gora.GoraEdgeOutputFormat; import org.apache.giraph.io.gora.generated.GEdge; import org.apache.giraph.io.gora.generated.GEdgeResult; import org.apache.gora.persistency.Persistent; @@ -31,6 +28,7 @@ import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.FloatWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.mapreduce.TaskAttemptContext; +import org.junit.Assert; /** * Implementation of a specific writer for a generated data bean. @@ -63,11 +61,11 @@ public class GoraTestEdgeOutputFormat GEdgeResult tmpGEdge = new GEdgeResult(); Utf8 keyLabel = new Utf8(srcId.toString() + "-" + edge.getTargetVertexId().toString()); - tmpGEdge.setEdgeId(keyLabel); + tmpGEdge.setEdgeId(keyLabel.toString()); tmpGEdge.setEdgeWeight(edge.getValue().get()); - tmpGEdge.setVertexInId(new Utf8(srcId.toString())); - tmpGEdge.setVertexOutId(new Utf8(edge.getTargetVertexId().toString())); - tmpGEdge.setLabel(keyLabel); + tmpGEdge.setVertexInId(srcId.toString()); + tmpGEdge.setVertexOutId(edge.getTargetVertexId().toString()); + tmpGEdge.setLabel(keyLabel.toString()); getLogger().debug("GoraObject created: " + tmpGEdge.toString()); return tmpGEdge; } @@ -80,6 +78,7 @@ public class GoraTestEdgeOutputFormat return goraKey; } + @SuppressWarnings("unchecked") @Override public void writeEdge(LongWritable srcId, DoubleWritable srcValue, Edge<LongWritable, FloatWritable> edge) @@ -105,13 +104,13 @@ public class GoraTestEdgeOutputFormat * @param edgeWeight Edge wight. * @return GEdge created. */ - private GEdge createEdge(String id, String vertexInId, + private GEdgeResult createEdge(String id, String vertexInId, String vertexOutId, String edgeLabel, float edgeWeight) { - GEdge newEdge = new GEdge(); - newEdge.setEdgeId(new Utf8(id)); - newEdge.setVertexInId(new Utf8(vertexInId)); - newEdge.setVertexOutId(new Utf8(vertexOutId)); - newEdge.setLabel(new Utf8(edgeLabel)); + GEdgeResult newEdge = new GEdgeResult(); + newEdge.setEdgeId(id); + newEdge.setVertexInId(vertexInId); + newEdge.setVertexOutId(vertexOutId); + newEdge.setLabel(edgeLabel); newEdge.setEdgeWeight(edgeWeight); return newEdge; } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexInputFormat.java b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexInputFormat.java index 7de9346..d79a8fa 100644 --- a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexInputFormat.java +++ b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexInputFormat.java @@ -18,11 +18,9 @@ package org.apache.giraph.io.gora; import java.io.IOException; -import java.util.HashMap; import java.util.Map; 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; @@ -78,10 +76,10 @@ public class GoraTestVertexInputFormat */ public static GVertex createVertex(String id, Map<String, String> edges) { GVertex newVrtx = new GVertex(); - newVrtx.setVertexId(new Utf8(id)); + newVrtx.setVertexId(id); if (edges != null) { for (String edgeId : edges.keySet()) - newVrtx.putToEdges(new Utf8(edgeId), new Utf8(edges.get(edgeId))); + newVrtx.getEdges().put(edgeId, edges.get(edgeId)); } return newVrtx; } @@ -106,11 +104,11 @@ public class GoraTestVertexInputFormat LongWritable vrtxId = new LongWritable( Long.parseLong(tmpGVertex.getVertexId().toString())); - DoubleWritable vrtxValue = new DoubleWritable(tmpGVertex.getValue()); + 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/test/java/org/apache/giraph/io/gora/GoraTestVertexOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexOutputFormat.java b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexOutputFormat.java index 5170d03..1cb1f14 100644 --- a/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexOutputFormat.java +++ b/giraph-gora/src/test/java/org/apache/giraph/io/gora/GoraTestVertexOutputFormat.java @@ -21,9 +21,6 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; -import junit.framework.Assert; - -import org.apache.avro.util.Utf8; import org.apache.giraph.edge.Edge; import org.apache.giraph.graph.Vertex; import org.apache.giraph.io.VertexWriter; @@ -34,6 +31,7 @@ import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.FloatWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.mapreduce.TaskAttemptContext; +import org.junit.Assert; /** * Implementation of a specific reader for a generated data bean. @@ -64,20 +62,21 @@ public class GoraTestVertexOutputFormat 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()); } getLogger().debug("GoraObject created: " + tmpGVertex.toString()); return tmpGVertex; } + @SuppressWarnings("unchecked") @Override public void writeVertex( Vertex<LongWritable, DoubleWritable, FloatWritable> vertex) @@ -94,12 +93,12 @@ public class GoraTestVertexOutputFormat * @param edges Set of edges. * @return GVertex created. */ - public GVertex createVertex(String id, Map<String, String> edges) { - GVertex newVrtx = new GVertex(); - newVrtx.setVertexId(new Utf8(id)); + public GVertexResult createVertex(String id, Map<String, String> edges) { + GVertexResult newVrtx = new GVertexResult(); + newVrtx.setVertexId(id); if (edges != null) { for (String edgeId : edges.keySet()) - newVrtx.putToEdges(new Utf8(edgeId), new Utf8(edges.get(edgeId))); + newVrtx.getEdges().put(edgeId, edges.get(edgeId)); } return newVrtx; } http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeInputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeInputFormat.java b/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeInputFormat.java index a01fbd3..cf2df34 100644 --- a/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeInputFormat.java +++ b/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeInputFormat.java @@ -60,8 +60,8 @@ public class TestGoraEdgeInputFormat { 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"); + "org.apache.hadoop.io.serializer.JavaSerialization," + + "org.apache.hadoop.io.serializer.WritableSerialization"); conf.setComputationClass(EmptyComputation.class); conf.setEdgeInputFormatClass(GoraGEdgeEdgeInputFormat.class); results = InternalVertexRunner.run(conf, new String[0], new String[0]); http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeOutputFormat.java ---------------------------------------------------------------------- diff --git a/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeOutputFormat.java b/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeOutputFormat.java index c9ac38a..7de6d01 100644 --- a/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeOutputFormat.java +++ b/giraph-gora/src/test/java/org/apache/giraph/io/gora/TestGoraEdgeOutputFormat.java @@ -68,7 +68,7 @@ public class TestGoraEdgeOutputFormat { set(conf, "org.apache.gora.memory.store.MemStore"); GIRAPH_GORA_OUTPUT_KEY_CLASS.set(conf, "java.lang.String"); GIRAPH_GORA_OUTPUT_PERSISTENT_CLASS. - set(conf,"org.apache.giraph.io.gora.generated.GEdge"); + set(conf,"org.apache.giraph.io.gora.generated.GEdgeResult"); conf.setEdgeOutputFormatClass(GoraTestEdgeOutputFormat.class); results = InternalVertexRunner.run(conf, new String[0], new String[0]); Assert.assertNotNull(results); http://git-wip-us.apache.org/repos/asf/giraph/blob/7c61dcf4/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index e654ff3..6804de9 100644 --- a/pom.xml +++ b/pom.xml @@ -273,10 +273,10 @@ under the License. <giraph.maven.dependency.plugin.skip>false</giraph.maven.dependency.plugin.skip> <giraph.maven.duplicate.finder.skip>false</giraph.maven.duplicate.finder.skip> - <dep.avro.version>1.3.3</dep.avro.version> + <dep.avro.version>1.7.6</dep.avro.version> <dep.accumulo.version>1.4.0</dep.accumulo.version> <dep.asm.version>3.2</dep.asm.version> - <dep.gora.version>0.3</dep.gora.version> + <dep.gora.version>0.5</dep.gora.version> <dep.airline.version>0.5</dep.airline.version> <dep.base64.version>2.3.8</dep.base64.version> <dep.cli-parser.version>1.1</dep.cli-parser.version>
