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 result.22 */23 @SuppressWarnings("all")
24publicclassGVertexResultextends25 org.apache.gora.persistency.impl.PersistentBase implements26 org.apache.avro.specific.SpecificRecord,
27 org.apache.gora.persistency.Persistent {
2829/**30 * Schema used for the class.31 */32publicstaticfinal org.apache.avro.Schema SCHEMAS =
33new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\"," +
34"\"name\":\"GVertexResult\"," +
35"\"namespace\":\"org.apache.giraph.io.gora.generated\"," +
36"\"fields\":[{\"name\":\"vertexId\",\"type\":\"string\"}," +
37"{\"name\":\"vertexValue\",\"type\":\"float\"}," +
38"{\"name\":\"edges\",\"type\":" +
39"{\"type\":\"map\",\"values\":\"string\"}}]}");
4041/** Enum containing all data bean's fields. */42publicstatic enum Field {
43/**44 * Vertex id.45 */46 VERTEX_ID(0, "vertexId"),
4748/**49 * Vertex value.50 */51 VERTEX_VALUE(1, "vertexValue"),
5253/**54 * Vertex edges.55 */56 EDGES(2, "edges");
5758/**59 * Field's index.60 */61privateint index;
6263/**64 * Field's name.65 */66private String name;
6768/**69 * Field's constructor70 * @param index field's index.71 * @param name field's name.72 */73Field(int index, String name) {
74this.index = index;
75this.name = name;
76 }
7778/**79 * Gets field's index.80 * @return int field's index.81 */82publicint getIndex() {
83return index;
84 }
8586/**87 * Gets field's name.88 * @return String field's name.89 */90public String getName() {
91return name;
92 }
9394/**95 * Gets field's attributes to string.96 * @return String field's attributes to string.97 */98public String toString() {
99return name;
100 }
101 };
102103/**104 * Array containing all fields/105 */106privatestaticfinal String[] ALL_FIELDS = {
107"vertexId", "vertexValue", "edges", };
108109/**110 * Tombstone.111 */112privatestaticfinalTombstone TOMBSTONE = newTombstone();
113114/**115 * vertexId.116 */117private java.lang.CharSequence vertexId;
118119/**120 * vertexValue.121 */122privatefloat vertexValue;
123124/**125 * edges.126 */127private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges;
128129/**130 * Gets the total field count.131 * @return int field count132 */133publicint getFieldsCount() {
134return GVertexResult.ALL_FIELDS.length;
135 }
136137/**138 * Gets the schema139 * @return Schema140 */141public org.apache.avro.Schema getSchema() {
142return SCHEMAS;
143 }
144145/**146 * Gets field147 * @param field index field.148 * @return Object from an index.149 */150public java.lang.Object get(int field) {
151switch (field) {
152case 0:
153return vertexId;
154case 1:
155return vertexValue;
156case 2:
157return edges;
158default:
159thrownew org.apache.avro.AvroRuntimeException("Bad index");
160 }
161 }
162163/**164 * Puts a value into a field.165 * @param field index of field used.166 * @param value value of field used.167 */168 @SuppressWarnings(value = "unchecked")
169publicvoid put(int field, java.lang.Object value) {
170switch (field) {
171case 0:
172 vertexId = (java.lang.CharSequence) value;
173break;
174case 1:
175 vertexValue = (java.lang.Float) value;
176break;
177case 2:
178 edges = (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
179 ((value instanceof org.apache.gora.persistency.Dirtyable) ? value :
180new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)
181 value));
182break;
183default:
184thrownew org.apache.avro.AvroRuntimeException("Bad index");
185 }
186 }
187188/**189 * Gets the value of the 'vertexId' field.190 * @return CharSequence191 */192public java.lang.CharSequence getVertexId() {
193return vertexId;
194 }
195196/**197 * Sets the value of the 'vertexId' field.198 * @param value the value to set.199 */200publicvoid setVertexId(java.lang.CharSequence value) {
201this.vertexId = value;
202 setDirty(0);
203 }
204205/**206 * Checks the dirty status of the 'vertexId' field. A field is dirty if it207 * represents a change that has not yet been written to the database.208 * @param value the value to set.209 * @return boolean210 */211publicboolean isVertexIdDirty(java.lang.CharSequence value) {
212return isDirty(0);
213 }
214215/**216 * Gets the value of the 'vertexValue' field.217 * @return Float218 */219public java.lang.Float getVertexValue() {
220return vertexValue;
221 }
222223/**224 * Sets the value of the 'vertexValue' field.225 * @param value the value to set.226 */227publicvoid setVertexValue(java.lang.Float value) {
228this.vertexValue = value;
229 setDirty(1);
230 }
231232/**233 * Checks the dirty status of the 'vertexValue' field. A field is dirty if it234 * represents a change that has not yet been written to the database.235 * @param value the value to set.236 * @return boolean237 */238publicboolean isVertexValueDirty(java.lang.Float value) {
239return isDirty(1);
240 }
241242/**243 * Gets the value of the 'edges' field.244 * @return Edges245 */246public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
247 getEdges() {
248return edges;
249 }
250251/**252 * Sets the value of the 'edges' field.253 * @param value the value to set.254 */255publicvoid setEdges(
256 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
257this.edges = (value instanceof org.apache.gora.persistency.Dirtyable) ?
258 value : new 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 GVertexResult RecordBuilder275 * @return GVertexResult.Builder276 */277publicstatic org.apache.giraph.io.gora.generated.GVertexResult.Builder
278 newBuilder() {
279returnnew org.apache.giraph.io.gora.generated.GVertexResult.Builder();
280 }
281282/**283 * Creates a new GVertexResult RecordBuilder by copying an existing Builder.284 * @param other GVertexResult.Builder285 * @return GVertexResult.Builder286 */287publicstatic org.apache.giraph.io.gora.generated.GVertexResult.Builder
288 newBuilder(org.apache.giraph.io.gora.generated.GVertexResult.Builder other) {
289returnnew org.apache.giraph.io.gora.generated.GVertexResult.Builder(other);
290 }
291292/**293 * Creates a new GVertexResult RecordBuilder by copying an existing294 * GVertexResult instance295 * @param other GVertexResult296 * @return GVertexResult.Builder297 */298publicstatic org.apache.giraph.io.gora.generated.GVertexResult.Builder
299 newBuilder(org.apache.giraph.io.gora.generated.GVertexResult other) {
300returnnew org.apache.giraph.io.gora.generated.GVertexResult.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 GVertexResult instances.333 */334publicstaticclassBuilderextends335 org.apache.avro.specific.SpecificRecordBuilderBase<GVertexResult>
336implements org.apache.avro.data.RecordBuilder<GVertexResult> {
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.GVertexResult.SCHEMAS);
356 }
357358/**359 * Creates a Builder by copying an existing Builder.360 * @param other GVertexResult.Builder361 */362privateBuilder(
363 org.apache.giraph.io.gora.generated.GVertexResult.Builder other) {
364super(other);
365 }
366367/**368 * Creates a Builder by copying an existing GVertexResult instance.369 * @param other GVertexResult370 */371// CHECKSTYLE: stop Indentation372privateBuilder(org.apache.giraph.io.gora.generated.GVertexResult other) {
373super(org.apache.giraph.io.gora.generated.GVertexResult.SCHEMAS);
374if (isValidValue(fields()[0], other.vertexId)) {
375this.vertexId = (java.lang.CharSequence) data().deepCopy(
376 fields()[0].schema(), other.vertexId);
377 fieldSetFlags()[0] = true;
378 }
379if (isValidValue(fields()[1], other.vertexValue)) {
380this.vertexValue = (java.lang.Float) data().deepCopy(
381 fields()[1].schema(), other.vertexValue);
382 fieldSetFlags()[1] = true;
383 }
384if (isValidValue(fields()[2], other.edges)) {
385this.edges =
386 (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
387 data().deepCopy(fields()[2].schema(), other.edges);
388 fieldSetFlags()[2] = true;
389 }
390 }
391// CHECKSTYLE: resume Indentation392393/**394 * Gets the value of the 'vertexId' field.395 * @return CharSequence396 */397public java.lang.CharSequence getVertexId() {
398return vertexId;
399 }
400401/**402 * Sets the value of the 'vertexId' field.403 * @param value CharSequence404 * @return GVertexResult.Builder405 */406// CHECKSTYLE: stop Indentation407public org.apache.giraph.io.gora.generated.GVertexResult.Builder
408 setVertexId(java.lang.CharSequence value) {
409 validate(fields()[0], value);
410this.vertexId = value;
411 fieldSetFlags()[0] = true;
412returnthis;
413 }
414// CHECKSTYLE: resume Indentation415416/**417 * Checks whether the 'vertexId' field has been set.418 * @return boolean419 */420publicboolean hasVertexId() {
421return fieldSetFlags()[0];
422 }
423424/**425 * Clears the value of the 'vertexId' field426 * @return GVertexResult.Builder427 */428// CHECKSTYLE: stop Indentation429public org.apache.giraph.io.gora.generated.GVertexResult.Builder
430 clearVertexId() {
431 vertexId = null;
432 fieldSetFlags()[0] = false;
433returnthis;
434 }
435// CHECKSTYLE: resume Indentation436437/**438 * Gets the value of the 'vertexValue' field.439 * @return Float440 */441public java.lang.Float getVertexValue() {
442return vertexValue;
443 }
444445/**446 * Sets the value of the 'vertexValue' field.447 * @param value float448 * @return GVertexResult.Builder449 */450// CHECKSTYLE: stop Indentation451public org.apache.giraph.io.gora.generated.GVertexResult.Builder
452 setVertexValue(float value) {
453 validate(fields()[1], value);
454this.vertexValue = value;
455 fieldSetFlags()[1] = true;
456returnthis;
457 }
458// CHECKSTYLE: resume Indentation459460/**461 * Checks whether the 'vertexValue' field has been set.462 * @return boolean463 */464publicboolean hasVertexValue() {
465return fieldSetFlags()[1];
466 }
467468/**469 * Clears the value of the 'vertexValue' field.470 * @return GVertexResult.Builder471 */472// CHECKSTYLE: stop Indentation473public org.apache.giraph.io.gora.generated.GVertexResult.Builder
474 clearVertexValue() {
475 fieldSetFlags()[1] = false;
476returnthis;
477 }
478// CHECKSTYLE: resume Indentation479480/**481 * Gets the value of the 'edges' field.482 * @return java.util.Map483 */484public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
485 getEdges() {
486return edges;
487 }
488489/**490 * Sets the value of the 'edges' field491 * @param value java.util.Map492 * @return GVertexResult.Builder493 */494// CHECKSTYLE: stop Indentation495public org.apache.giraph.io.gora.generated.GVertexResult.Builder setEdges(
496 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
497 validate(fields()[2], value);
498this.edges = value;
499 fieldSetFlags()[2] = true;
500returnthis;
501 }
502// CHECKSTYLE: resume Indentation503504/**505 * Checks whether the 'edges' field has been set.506 * @return boolean507 */508publicboolean hasEdges() {
509return fieldSetFlags()[2];
510 }
511512/**513 * Clears the value of the 'edges' field.514 * @return org.apache.giraph.io.gora.generated.GVertexResult.Builder515 */516// CHECKSTYLE: stop Indentation517public org.apache.giraph.io.gora.generated.GVertexResult.Builder
518 clearEdges() {
519 edges = null;
520 fieldSetFlags()[2] = false;
521returnthis;
522 }
523// CHECKSTYLE: resume Indentation524525 @Override
526/**527 * Builds a GVertexResult.528 * @return GVertexResult529 */530// CHECKSTYLE: stop IllegalCatch531publicGVertexResult build() {
532try {
533GVertexResult record = newGVertexResult();
534 record.vertexId = fieldSetFlags()[0] ? this.vertexId :
535 (java.lang.CharSequence) defaultValue(fields()[0]);
536 record.vertexValue = fieldSetFlags()[1] ? this.vertexValue :
537 (java.lang.Float) defaultValue(fields()[1]);
538 record.edges = fieldSetFlags()[2] ? this.edges :
539 (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
540new org.apache.gora.persistency.impl.DirtyMapWrapper(
541 (java.util.Map) defaultValue(fields()[2]));
542return record;
543 } catch (Exception e) {
544thrownew org.apache.avro.AvroRuntimeException(e);
545 }
546 }
547// CHECKSTYLE: resume IllegalCatch548 }
549550/**551 * Gets tombstone552 * @return GVertex.Tombstone553 */554public GVertexResult.Tombstone getTombstone() {
555return TOMBSTONE;
556 }
557558/**559 * Gets a new instance560 * @return GVertexResult.561 */562publicGVertexResult newInstance() {
563return newBuilder().build();
564 }
565566/**567 * Tombstone class.568 */569publicstaticfinalclassTombstoneextendsGVertexResultimplements570 org.apache.gora.persistency.Tombstone {
571572/**573 * Default constructor.574 */575privateTombstone() {
576 }
577578/**579 * Gets the value of the 'vertexId' field.580 * @return java.lang.CharSequence581 */582public java.lang.CharSequence getVertexId() {
583thrownew java.lang.UnsupportedOperationException(
584"Get is not supported on tombstones");
585 }
586587/**588 * Sets the value of the 'vertexId' field.589 * @param value the value to set.590 */591publicvoid setVertexId(java.lang.CharSequence value) {
592thrownew java.lang.UnsupportedOperationException(
593"Set is not supported on tombstones");
594 }
595596/**597 * Checks the dirty status of the 'vertexId' field. A field is dirty if it598 * represents a change that has not yet been written to the database.599 * @param value the value to set.600 * @return boolean601 */602publicboolean isVertexIdDirty(java.lang.CharSequence value) {
603thrownew java.lang.UnsupportedOperationException(
604"IsDirty is not supported on tombstones");
605 }
606607/**608 * Gets the value of the 'vertexValue' field.609 * @return Float610 */611public java.lang.Float getVertexValue() {
612thrownew java.lang.UnsupportedOperationException(
613"Get is not supported on tombstones");
614 }
615616/**617 * Sets the value of the 'vertexValue' field.618 * @param value the value to set.619 */620publicvoid setVertexValue(java.lang.Float value) {
621thrownew java.lang.UnsupportedOperationException(
622"Set is not supported on tombstones");
623 }
624625/**626 * Checks the dirty status of the 'vertexValue' field. A field is dirty if627 * it represents a change that has not yet been written to the database.628 * @param value the value to set.629 * @return boolean630 */631publicboolean isVertexValueDirty(java.lang.Float value) {
632thrownew java.lang.UnsupportedOperationException(
633"IsDirty is not supported on tombstones");
634 }
635636/**637 * Gets the value of the 'edges' field.638 * @return java.util.Map639 */640public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
641 getEdges() {
642thrownew java.lang.UnsupportedOperationException(
643"Get is not supported on tombstones");
644 }
645646/**647 * Sets the value of the 'edges' field.648 * @param value the value to set.649 */650publicvoid setEdges(
651 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
652thrownew java.lang.UnsupportedOperationException(
653"Set is not supported on tombstones");
654 }
655656/**657 * Checks the dirty status of the 'edges' field. A field is dirty if it658 * represents a change that has not yet been written to the database.659 * @param value the value to set.660 * @return boolean661 */662publicboolean isEdgesDirty(
663 java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
664thrownew java.lang.UnsupportedOperationException(
665"IsDirty is not supported on tombstones");
666 }
667 }
668 }