1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18package org.apache.giraph.io.gora.generated;
1920/**21 * Example class for defining a Giraph-vertex.22 */23 @SuppressWarnings("all")
24publicclassGVertexextends org.apache.gora.persistency.impl.PersistentBase
25implements org.apache.avro.specific.SpecificRecord,
26 org.apache.gora.persistency.Persistent {
2728/**29 * Schema used for the class.30 */31publicstaticfinal org.apache.avro.Schema SCHEMAS =
32new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\"," +
33"\"name\":\"GVertex\"," +
34"\"namespace\":\"org.apache.giraph.io.gora.generated\"," +
35"\"fields\":[{\"name\":\"vertexId\",\"type\":\"string\"}," +
36"{\"name\":\"vertexValue\",\"type\":\"float\"}," +
37"{\"name\":\"edges\",\"type\":" +
38"{\"type\":\"map\",\"values\":\"string\"}}]}");
3940/** Enum containing all data bean's fields. */41publicstatic enum Field {
42/**43 * Vertex id.44 */45 VERTEX_ID(0, "vertexId"),
4647/**48 * Vertex value.49 */50 VERTEX_VALUE(1, "vertexValue"),
5152/**53 * Vertex edges.54 */55 EDGES(2, "edges");
5657/**58 * Field's index.59 */60privateint index;
6162/**63 * Field's name.64 */65private String name;
6667/**68 * Field's constructor69 * @param index field's index.70 * @param name field's name.71 */72Field(int index, String name) {
73this.index = index;
74this.name = name;
75 }
7677/**78 * Gets field's index.79 * @return int field's index.80 */81publicint getIndex() {
82return index;
83 }
8485/**86 * Gets field's name.87 * @return String field's name.88 */89public String getName() {
90return name;
91 }
9293/**94 * Gets field's attributes to string.95 * @return String field's attributes to string.96 */97public String toString() {
98return name;
99 }
100 };
101102/**103 * Array containing all fields/104 */105privatestaticfinal String[] ALL_FIELDS = {
106"vertexId", "vertexValue", "edges", };
107108/**109 * Tombstone.110 */111privatestaticfinalTombstone TOMBSTONE = newTombstone();
112113/**114 * vertexId.115 */116private java.lang.CharSequence vertexId;
117118/**119 * vertexValue.120 */121privatefloat vertexValue;
122123/**124 * edges.125 */126private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges;
127128/**129 * Gets the total field count.130 * @return int field count131 */132publicint getFieldsCount() {
133return GVertex.ALL_FIELDS.length;
134 }
135136/**137 * Gets the schema138 * @return Schema139 */140public org.apache.avro.Schema getSchema() {
141return SCHEMAS;
142 }
143144/**145 * Gets field146 * @param field index field.147 * @return Object from an index.148 */149public java.lang.Object get(int field) {
150switch (field) {
151case 0:
152return vertexId;
153case 1:
154return vertexValue;
155case 2:
156return edges;
157default:
158thrownew org.apache.avro.AvroRuntimeException("Bad index");
159 }
160 }
161162/**163 * Puts a value into a field.164 * @param field index of field used.165 * @param value value of field used.166 */167 @SuppressWarnings(value = "unchecked")
168publicvoid put(int field, java.lang.Object value) {
169switch (field) {
170case 0:
171 vertexId = (java.lang.CharSequence) value;
172break;
173case 1:
174 vertexValue = (java.lang.Float) value;
175break;
176case 2:
177 edges = (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
178 ((value instanceof org.apache.gora.persistency.Dirtyable) ? value :
179new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)
180 value));
181break;
182default:
183thrownew org.apache.avro.AvroRuntimeException("Bad index");
184 }
185 }
186187/**188 * Gets the value of the 'vertexId' field.189 * @return CharSequence190 */191public java.lang.CharSequence getVertexId() {
192return vertexId;
193 }
194195/**196 * Sets the value of the 'vertexId' field.197 * @param value the value to set.198 */199publicvoid setVertexId(java.lang.CharSequence value) {
200this.vertexId = value;
201 setDirty(0);
202 }
203204/**205 * Checks the dirty status of the 'vertexId' field. A field is dirty if it206 * represents a change that has not yet been written to the database.207 * @param value the value to set.208 * @return boolean209 */210publicboolean isVertexIdDirty(java.lang.CharSequence value) {
211return isDirty(0);
212 }
213214/**215 * Gets the value of the 'vertexValue' field.216 * @return Float217 */218public java.lang.Float getVertexValue() {
219return vertexValue;
220 }
221222/**223 * Sets the value of the 'vertexValue' field.224 * @param value the value to set.225 */226publicvoid setVertexValue(java.lang.Float value) {
227this.vertexValue = value;
228 setDirty(1);
229 }
230231/**232 * Checks the dirty status of the 'vertexValue' field. A field is dirty if it233 * represents a change that has not yet been written to the database.234 * @param value the value to set.235 * @return boolean236 */237publicboolean isVertexValueDirty(java.lang.Float value) {
238return isDirty(1);
239 }
240241/**242 * Gets the value of the 'edges' field.243 * @return java.util.Map244 */245public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
246 getEdges() {
247return edges;
248 }
249250/**251 * Sets the value of the 'edges' field.252 * @param value the value to set.253 */254publicvoid setEdges(
255 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
256this.edges =
257 (value instanceof org.apache.gora.persistency.Dirtyable) ? value :
258new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
259 setDirty(2);
260 }
261262/**263 * Checks the dirty status of the 'edges' field. A field is dirty if it264 * represents a change that has not yet been written to the database.265 * @param value the value to set.266 * @return boolean267 */268publicboolean isEdgesDirty(
269 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
270return isDirty(2);
271 }
272273/**274 * Creates a new GVertex RecordBuilder.275 * @return GVertex.Builder276 */277publicstatic org.apache.giraph.io.gora.generated.GVertex.Builder
278 newBuilder() {
279returnnew org.apache.giraph.io.gora.generated.GVertex.Builder();
280 }
281282/**283 * Creates a new GVertex RecordBuilder by copying an existing Builder.284 * @param other GVertex.Builder285 * @return GVertex.Builder286 */287publicstatic org.apache.giraph.io.gora.generated.GVertex.Builder newBuilder(
288 org.apache.giraph.io.gora.generated.GVertex.Builder other) {
289returnnew org.apache.giraph.io.gora.generated.GVertex.Builder(other);
290 }
291292/**293 * Creates a new GVertex RecordBuilder by copying294 * an existing GVertex instance295 * @param other GVertex296 * @return GVertex.Builder297 */298publicstatic org.apache.giraph.io.gora.generated.GVertex.Builder newBuilder(
299 org.apache.giraph.io.gora.generated.GVertex other) {
300returnnew org.apache.giraph.io.gora.generated.GVertex.Builder(other);
301 }
302303/**304 * Makes a deep copy from a bytebuffer.305 * @param input ByteBuffer306 * @return ByteBuffer307 */308privatestatic java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
309 java.nio.ByteBuffer input) {
310 java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
311int position = input.position();
312 input.reset();
313int mark = input.position();
314int limit = input.limit();
315 input.rewind();
316 input.limit(input.capacity());
317 copy.put(input);
318 input.rewind();
319 copy.rewind();
320 input.position(mark);
321 input.mark();
322 copy.position(mark);
323 copy.mark();
324 input.position(position);
325 copy.position(position);
326 input.limit(limit);
327 copy.limit(limit);
328return copy.asReadOnlyBuffer();
329 }
330331/**332 * RecordBuilder for GVertex instances.333 */334publicstaticclassBuilderextends335 org.apache.avro.specific.SpecificRecordBuilderBase<GVertex> implements336 org.apache.avro.data.RecordBuilder<GVertex> {
337338/**339 * vertexId340 */341private java.lang.CharSequence vertexId;
342343/**344 * vertexValue345 */346privatefloat vertexValue;
347348/**349 * edges350 */351private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges;
352353/** Creates a new Builder */354privateBuilder() {
355super(org.apache.giraph.io.gora.generated.GVertex.SCHEMAS);
356 }
357358/**359 * Creates a Builder by copying an existing Builder.360 * @param other GVertex361 */362privateBuilder(org.apache.giraph.io.gora.generated.GVertex.Builder other) {
363super(other);
364 }
365366/**367 * Creates a Builder by copying an existing GVertex instance.368 * @param other GVertex369 */370// CHECKSTYLE: stop Indentation371privateBuilder(org.apache.giraph.io.gora.generated.GVertex other) {
372super(org.apache.giraph.io.gora.generated.GVertex.SCHEMAS);
373if (isValidValue(fields()[0], other.vertexId)) {
374this.vertexId = (java.lang.CharSequence) data().deepCopy(
375 fields()[0].schema(), other.vertexId);
376 fieldSetFlags()[0] = true;
377 }
378if (isValidValue(fields()[1], other.vertexValue)) {
379this.vertexValue = (java.lang.Float) data().deepCopy(
380 fields()[1].schema(), other.vertexValue);
381 fieldSetFlags()[1] = true;
382 }
383if (isValidValue(fields()[2], other.edges)) {
384this.edges =
385 (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
386 data().deepCopy(fields()[2].schema(), other.edges);
387 fieldSetFlags()[2] = true;
388 }
389 }
390// CHECKSTYLE: resume Indentation391392/**393 * Gets the value of the 'vertexId' field.394 * @return CharSsequence395 */396public java.lang.CharSequence getVertexId() {
397return vertexId;
398 }
399400/**401 * Sets the value of the 'vertexId' field.402 * @param value CharSequence403 * @return GVertex.Builder404 */405// CHECKSTYLE: stop Indentation406public org.apache.giraph.io.gora.generated.GVertex.Builder setVertexId(
407 java.lang.CharSequence value) {
408 validate(fields()[0], value);
409this.vertexId = value;
410 fieldSetFlags()[0] = true;
411returnthis;
412 }
413// CHECKSTYLE: resume Indentation414415/**416 * Checks whether the 'vertexId' field has been set.417 * @return boolean418 */419publicboolean hasVertexId() {
420return fieldSetFlags()[0];
421 }
422423/**424 * Clears the value of the 'vertexId' field425 * @return GVertex.Builder426 */427// CHECKSTYLE: stop Indentation428public org.apache.giraph.io.gora.generated.GVertex.Builder clearVertexId() {
429 vertexId = null;
430 fieldSetFlags()[0] = false;
431returnthis;
432 }
433// CHECKSTYLE: resume Indentation434435/**436 * Gets the value of the 'vertexValue' field437 * @return Float438 */439public java.lang.Float getVertexValue() {
440return vertexValue;
441 }
442443/**444 * Sets the value of the 'vertexValue' field.445 * @param value float446 * @return GVertex.Builder447 */448// CHECKSTYLE: stop Indentation449public org.apache.giraph.io.gora.generated.GVertex.Builder setVertexValue(
450float value) {
451 validate(fields()[1], value);
452this.vertexValue = value;
453 fieldSetFlags()[1] = true;
454returnthis;
455 }
456// CHECKSTYLE: resume Indentation457458/**459 * Checks whether the 'vertexValue' field has been set.460 * @return boolean461 */462publicboolean hasVertexValue() {
463return fieldSetFlags()[1];
464 }
465466/**467 * Clears the value of the 'vertexValue' field.468 * @return GVertex.Builder469 */470// CHECKSTYLE: stop Indentation471public org.apache.giraph.io.gora.generated.GVertex.Builder
472 clearVertexValue() {
473 fieldSetFlags()[1] = false;
474returnthis;
475 }
476// CHECKSTYLE: resume Indentation477478/**479 * Gets the value of the 'edges' field.480 * @return java.util.Map481 */482public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
483 getEdges() {
484return edges;
485 }
486487/**488 * Sets the value of the 'edges' field.489 * @param value java.util.Map490 * @return GVertex.Builder491 */492// CHECKSTYLE: stop Indentation493public org.apache.giraph.io.gora.generated.GVertex.Builder setEdges(
494 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
495 validate(fields()[2], value);
496this.edges = value;
497 fieldSetFlags()[2] = true;
498returnthis;
499 }
500// CHECKSTYLE: resume Indentation501502/**503 * Checks whether the 'edges' field has been set.504 * @return boolean505 */506publicboolean hasEdges() {
507return fieldSetFlags()[2];
508 }
509510/**511 * Clears the value of the 'edges' field.512 * @return org.apache.giraph.io.gora.generated.GVertex.Builder513 */514// CHECKSTYLE: stop Indentation515public org.apache.giraph.io.gora.generated.GVertex.Builder clearEdges() {
516 edges = null;
517 fieldSetFlags()[2] = false;
518returnthis;
519 }
520// CHECKSTYLE: resume Indentation521522 @Override
523/**524 * Builds a GVertex.525 * @return GVertex526 */527// CHECKSTYLE: stop IllegalCatch528publicGVertex build() {
529try {
530GVertex record = newGVertex();
531 record.vertexId = fieldSetFlags()[0] ? this.vertexId :
532 (java.lang.CharSequence) defaultValue(fields()[0]);
533 record.vertexValue = fieldSetFlags()[1] ? this.vertexValue :
534 (java.lang.Float) defaultValue(fields()[1]);
535 record.edges = fieldSetFlags()[2] ? this.edges :
536 (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
537new org.apache.gora.persistency.impl.DirtyMapWrapper(
538 (java.util.Map) defaultValue(fields()[2]));
539return record;
540 } catch (Exception e) {
541thrownew org.apache.avro.AvroRuntimeException(e);
542 }
543 }
544// CHECKSTYLE: resume IllegalCatch545 }
546547/**548 * Gets tombstone549 * @return GVertex.Tombstone550 */551public GVertex.Tombstone getTombstone() {
552return TOMBSTONE;
553 }
554555/**556 * Gets a new instance557 * @return GVertex.558 */559publicGVertex newInstance() {
560return newBuilder().build();
561 }
562563/**564 * Tombstone class.565 */566publicstaticfinalclassTombstoneextendsGVerteximplements567 org.apache.gora.persistency.Tombstone {
568569/**570 * Default constructor.571 */572privateTombstone() {
573 }
574575/**576 * Gets the value of the 'vertexId' field.577 * @return java.lang.CharSequence578 */579public java.lang.CharSequence getVertexId() {
580thrownew java.lang.UnsupportedOperationException(
581"Get is not supported on tombstones");
582 }
583584/**585 * Sets the value of the 'vertexId' field.586 * @param value the value to set.587 */588publicvoid setVertexId(java.lang.CharSequence value) {
589thrownew java.lang.UnsupportedOperationException(
590"Set is not supported on tombstones");
591 }
592593/**594 * Checks the dirty status of the 'vertexId' field. A field is dirty if it595 * represents a change that has not yet been written to the database.596 * @param value the value to set.597 * @return boolean598 */599publicboolean isVertexIdDirty(java.lang.CharSequence value) {
600thrownew java.lang.UnsupportedOperationException(
601"IsDirty is not supported on tombstones");
602 }
603604/**605 * Gets the value of the 'vertexValue' field.606 * @return Float607 */608public java.lang.Float getVertexValue() {
609thrownew java.lang.UnsupportedOperationException(
610"Get is not supported on tombstones");
611 }
612613/**614 * Sets the value of the 'vertexValue' field.615 * @param value the value to set.616 */617publicvoid setVertexValue(java.lang.Float value) {
618thrownew java.lang.UnsupportedOperationException(
619"Set is not supported on tombstones");
620 }
621622/**623 * Checks the dirty status of the 'vertexValue' field. A field is dirty if624 * it represents a change that has not yet been written to the database.625 * @param value the value to set.626 * @return boolean627 */628publicboolean isVertexValueDirty(java.lang.Float value) {
629thrownew java.lang.UnsupportedOperationException(
630"IsDirty is not supported on tombstones");
631 }
632633/**634 * Gets the value of the 'edges' field.635 * @return java.util.Map636 */637public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
638 getEdges() {
639thrownew java.lang.UnsupportedOperationException(
640"Get is not supported on tombstones");
641 }
642643/**644 * Sets the value of the 'edges' field.645 * @param value the value to set.646 */647publicvoid setEdges(
648 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
649thrownew java.lang.UnsupportedOperationException(
650"Set is not supported on tombstones");
651 }
652653/**654 * Checks the dirty status of the 'edges' field. A field is dirty if it655 * represents a change that has not yet been written to the database.656 * @param value the value to set.657 * @return boolean658 */659publicboolean isEdgesDirty(
660 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
661thrownew java.lang.UnsupportedOperationException(
662"IsDirty is not supported on tombstones");
663 }
664 }
665 }