This project has retired. For details please refer to its Attic page.
GVertexResult xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.giraph.io.gora.generated;
19  
20  /**
21   * Example class for defining a Giraph-vertex result.
22   */
23  @SuppressWarnings("all")
24  public class GVertexResult extends
25      org.apache.gora.persistency.impl.PersistentBase implements
26      org.apache.avro.specific.SpecificRecord,
27      org.apache.gora.persistency.Persistent {
28  
29    /**
30     * Schema used for the class.
31     */
32    public static final org.apache.avro.Schema SCHEMAS =
33        new 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\"}}]}");
40  
41    /** Enum containing all data bean's fields. */
42    public static enum Field {
43      /**
44       * Vertex id.
45       */
46      VERTEX_ID(0, "vertexId"),
47  
48      /**
49       * Vertex value.
50       */
51      VERTEX_VALUE(1, "vertexValue"),
52  
53      /**
54       * Vertex edges.
55       */
56      EDGES(2, "edges");
57  
58      /**
59       * Field's index.
60       */
61      private int index;
62  
63      /**
64       * Field's name.
65       */
66      private String name;
67  
68      /**
69       * Field's constructor
70       * @param index field's index.
71       * @param name field's name.
72       */
73      Field(int index, String name) {
74        this.index = index;
75        this.name = name;
76      }
77  
78      /**
79       * Gets field's index.
80       * @return int field's index.
81       */
82      public int getIndex() {
83        return index;
84      }
85  
86      /**
87       * Gets field's name.
88       * @return String field's name.
89       */
90      public String getName() {
91        return name;
92      }
93  
94      /**
95       * Gets field's attributes to string.
96       * @return String field's attributes to string.
97       */
98      public String toString() {
99        return name;
100     }
101   };
102 
103   /**
104    * Array containing all fields/
105    */
106   private static final String[] ALL_FIELDS = {
107     "vertexId", "vertexValue", "edges", };
108 
109   /**
110    * Tombstone.
111    */
112   private static final Tombstone TOMBSTONE = new Tombstone();
113 
114   /**
115    * vertexId.
116    */
117   private java.lang.CharSequence vertexId;
118 
119   /**
120    * vertexValue.
121    */
122   private float vertexValue;
123 
124   /**
125    * edges.
126    */
127   private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges;
128 
129   /**
130    * Gets the total field count.
131    * @return int field count
132    */
133   public int getFieldsCount() {
134     return GVertexResult.ALL_FIELDS.length;
135   }
136 
137   /**
138    * Gets the schema
139    * @return Schema
140    */
141   public org.apache.avro.Schema getSchema() {
142     return SCHEMAS;
143   }
144 
145   /**
146    * Gets field
147    * @param field index field.
148    * @return Object from an index.
149    */
150   public java.lang.Object get(int field) {
151     switch (field) {
152     case 0:
153       return vertexId;
154     case 1:
155       return vertexValue;
156     case 2:
157       return edges;
158     default:
159       throw new org.apache.avro.AvroRuntimeException("Bad index");
160     }
161   }
162 
163   /**
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")
169   public void put(int field, java.lang.Object value) {
170     switch (field) {
171     case 0:
172       vertexId = (java.lang.CharSequence) value;
173       break;
174     case 1:
175       vertexValue = (java.lang.Float) value;
176       break;
177     case 2:
178       edges = (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>)
179         ((value instanceof org.apache.gora.persistency.Dirtyable) ? value :
180         new org.apache.gora.persistency.impl.DirtyMapWrapper((java.util.Map)
181             value));
182       break;
183     default:
184       throw new org.apache.avro.AvroRuntimeException("Bad index");
185     }
186   }
187 
188   /**
189    * Gets the value of the 'vertexId' field.
190    * @return CharSequence
191    */
192   public java.lang.CharSequence getVertexId() {
193     return vertexId;
194   }
195 
196   /**
197    * Sets the value of the 'vertexId' field.
198    * @param value the value to set.
199    */
200   public void setVertexId(java.lang.CharSequence value) {
201     this.vertexId = value;
202     setDirty(0);
203   }
204 
205   /**
206    * Checks the dirty status of the 'vertexId' field. A field is dirty if it
207    * represents a change that has not yet been written to the database.
208    * @param value the value to set.
209    * @return boolean
210    */
211   public boolean isVertexIdDirty(java.lang.CharSequence value) {
212     return isDirty(0);
213   }
214 
215   /**
216    * Gets the value of the 'vertexValue' field.
217    * @return Float
218    */
219   public java.lang.Float getVertexValue() {
220     return vertexValue;
221   }
222 
223   /**
224    * Sets the value of the 'vertexValue' field.
225      * @param value the value to set.
226    */
227   public void setVertexValue(java.lang.Float value) {
228     this.vertexValue = value;
229     setDirty(1);
230   }
231 
232   /**
233    * Checks the dirty status of the 'vertexValue' field. A field is dirty if it
234    * represents a change that has not yet been written to the database.
235    * @param value the value to set.
236    * @return boolean
237    */
238   public boolean isVertexValueDirty(java.lang.Float value) {
239     return isDirty(1);
240   }
241 
242   /**
243    * Gets the value of the 'edges' field.
244    * @return Edges
245    */
246   public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
247   getEdges() {
248     return edges;
249   }
250 
251   /**
252    * Sets the value of the 'edges' field.
253    * @param value the value to set.
254    */
255   public void setEdges(
256       java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
257     this.edges = (value instanceof org.apache.gora.persistency.Dirtyable) ?
258         value : new org.apache.gora.persistency.impl.DirtyMapWrapper(value);
259     setDirty(2);
260   }
261 
262   /**
263    * Checks the dirty status of the 'edges' field. A field is dirty if it
264    * represents a change that has not yet been written to the database.
265    * @param value the value to set.
266    * @return boolean
267    */
268   public boolean isEdgesDirty(
269       java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
270     return isDirty(2);
271   }
272 
273   /**
274    * Creates a new GVertexResult RecordBuilder
275    * @return GVertexResult.Builder
276    */
277   public static org.apache.giraph.io.gora.generated.GVertexResult.Builder
278   newBuilder() {
279     return new org.apache.giraph.io.gora.generated.GVertexResult.Builder();
280   }
281 
282   /**
283    * Creates a new GVertexResult RecordBuilder by copying an existing Builder.
284    * @param other GVertexResult.Builder
285    * @return GVertexResult.Builder
286    */
287   public static org.apache.giraph.io.gora.generated.GVertexResult.Builder
288   newBuilder(org.apache.giraph.io.gora.generated.GVertexResult.Builder other) {
289     return new org.apache.giraph.io.gora.generated.GVertexResult.Builder(other);
290   }
291 
292   /**
293    * Creates a new GVertexResult RecordBuilder by copying an existing
294    * GVertexResult instance
295    * @param other GVertexResult
296    * @return GVertexResult.Builder
297    */
298   public static org.apache.giraph.io.gora.generated.GVertexResult.Builder
299   newBuilder(org.apache.giraph.io.gora.generated.GVertexResult other) {
300     return new org.apache.giraph.io.gora.generated.GVertexResult.Builder(other);
301   }
302 
303   /**
304    * Makes a deep copy from a bytebuffer.
305    * @param input ByteBuffer
306    * @return ByteBuffer
307    */
308   private static java.nio.ByteBuffer deepCopyToReadOnlyBuffer(
309       java.nio.ByteBuffer input) {
310     java.nio.ByteBuffer copy = java.nio.ByteBuffer.allocate(input.capacity());
311     int position = input.position();
312     input.reset();
313     int mark = input.position();
314     int 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);
328     return copy.asReadOnlyBuffer();
329   }
330 
331   /**
332    * RecordBuilder for GVertexResult instances.
333    */
334   public static class Builder extends
335       org.apache.avro.specific.SpecificRecordBuilderBase<GVertexResult>
336       implements org.apache.avro.data.RecordBuilder<GVertexResult> {
337 
338     /**
339      * vertexId
340      */
341     private java.lang.CharSequence vertexId;
342 
343     /**
344      * vertexValue
345      */
346     private float vertexValue;
347 
348     /**
349      * edges
350      */
351     private java.util.Map<java.lang.CharSequence, java.lang.CharSequence> edges;
352 
353     /** Creates a new Builder */
354     private Builder() {
355       super(org.apache.giraph.io.gora.generated.GVertexResult.SCHEMAS);
356     }
357 
358     /**
359      * Creates a Builder by copying an existing Builder.
360      * @param other GVertexResult.Builder
361      */
362     private Builder(
363         org.apache.giraph.io.gora.generated.GVertexResult.Builder other) {
364       super(other);
365     }
366 
367     /**
368      * Creates a Builder by copying an existing GVertexResult instance.
369      * @param other GVertexResult
370      */
371     // CHECKSTYLE: stop Indentation
372     private Builder(org.apache.giraph.io.gora.generated.GVertexResult other) {
373       super(org.apache.giraph.io.gora.generated.GVertexResult.SCHEMAS);
374       if (isValidValue(fields()[0], other.vertexId)) {
375         this.vertexId = (java.lang.CharSequence) data().deepCopy(
376             fields()[0].schema(), other.vertexId);
377         fieldSetFlags()[0] = true;
378       }
379       if (isValidValue(fields()[1], other.vertexValue)) {
380         this.vertexValue = (java.lang.Float) data().deepCopy(
381             fields()[1].schema(), other.vertexValue);
382         fieldSetFlags()[1] = true;
383       }
384       if (isValidValue(fields()[2], other.edges)) {
385         this.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 Indentation
392 
393     /**
394      * Gets the value of the 'vertexId' field.
395      * @return CharSequence
396      */
397     public java.lang.CharSequence getVertexId() {
398       return vertexId;
399     }
400 
401     /**
402      * Sets the value of the 'vertexId' field.
403      * @param value CharSequence
404      * @return GVertexResult.Builder
405      */
406     // CHECKSTYLE: stop Indentation
407     public org.apache.giraph.io.gora.generated.GVertexResult.Builder
408     setVertexId(java.lang.CharSequence value) {
409       validate(fields()[0], value);
410       this.vertexId = value;
411       fieldSetFlags()[0] = true;
412       return this;
413     }
414     // CHECKSTYLE: resume Indentation
415 
416     /**
417      * Checks whether the 'vertexId' field has been set.
418      * @return boolean
419      */
420     public boolean hasVertexId() {
421       return fieldSetFlags()[0];
422     }
423 
424     /**
425      * Clears the value of the 'vertexId' field
426      * @return GVertexResult.Builder
427      */
428     // CHECKSTYLE: stop Indentation
429     public org.apache.giraph.io.gora.generated.GVertexResult.Builder
430     clearVertexId() {
431       vertexId = null;
432       fieldSetFlags()[0] = false;
433       return this;
434     }
435     // CHECKSTYLE: resume Indentation
436 
437     /**
438      * Gets the value of the 'vertexValue' field.
439      * @return Float
440      */
441     public java.lang.Float getVertexValue() {
442       return vertexValue;
443     }
444 
445     /**
446      * Sets the value of the 'vertexValue' field.
447      * @param value float
448      * @return GVertexResult.Builder
449      */
450     // CHECKSTYLE: stop Indentation
451     public org.apache.giraph.io.gora.generated.GVertexResult.Builder
452     setVertexValue(float value) {
453       validate(fields()[1], value);
454       this.vertexValue = value;
455       fieldSetFlags()[1] = true;
456       return this;
457     }
458     // CHECKSTYLE: resume Indentation
459 
460     /**
461      * Checks whether the 'vertexValue' field has been set.
462      * @return boolean
463      */
464     public boolean hasVertexValue() {
465       return fieldSetFlags()[1];
466     }
467 
468     /**
469      * Clears the value of the 'vertexValue' field.
470      * @return GVertexResult.Builder
471      */
472     // CHECKSTYLE: stop Indentation
473     public org.apache.giraph.io.gora.generated.GVertexResult.Builder
474     clearVertexValue() {
475       fieldSetFlags()[1] = false;
476       return this;
477     }
478     // CHECKSTYLE: resume Indentation
479 
480     /**
481      * Gets the value of the 'edges' field.
482      * @return java.util.Map
483      */
484     public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
485     getEdges() {
486       return edges;
487     }
488 
489     /**
490      * Sets the value of the 'edges' field
491      * @param value java.util.Map
492      * @return GVertexResult.Builder
493      */
494     // CHECKSTYLE: stop Indentation
495     public 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);
498       this.edges = value;
499       fieldSetFlags()[2] = true;
500       return this;
501     }
502     // CHECKSTYLE: resume Indentation
503 
504     /**
505      * Checks whether the 'edges' field has been set.
506      * @return boolean
507      */
508     public boolean hasEdges() {
509       return fieldSetFlags()[2];
510     }
511 
512     /**
513      * Clears the value of the 'edges' field.
514      * @return org.apache.giraph.io.gora.generated.GVertexResult.Builder
515      */
516     // CHECKSTYLE: stop Indentation
517     public org.apache.giraph.io.gora.generated.GVertexResult.Builder
518     clearEdges() {
519       edges = null;
520       fieldSetFlags()[2] = false;
521       return this;
522     }
523     // CHECKSTYLE: resume Indentation
524 
525     @Override
526     /**
527      * Builds a GVertexResult.
528      * @return GVertexResult
529      */
530     // CHECKSTYLE: stop IllegalCatch
531     public GVertexResult build() {
532       try {
533         GVertexResult record = new GVertexResult();
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>)
540           new org.apache.gora.persistency.impl.DirtyMapWrapper(
541             (java.util.Map) defaultValue(fields()[2]));
542         return record;
543       } catch (Exception e) {
544         throw new org.apache.avro.AvroRuntimeException(e);
545       }
546     }
547     // CHECKSTYLE: resume IllegalCatch
548   }
549 
550   /**
551    * Gets tombstone
552    * @return GVertex.Tombstone
553    */
554   public GVertexResult.Tombstone getTombstone() {
555     return TOMBSTONE;
556   }
557 
558   /**
559    * Gets a new instance
560    * @return GVertexResult.
561    */
562   public GVertexResult newInstance() {
563     return newBuilder().build();
564   }
565 
566   /**
567    * Tombstone class.
568    */
569   public static final class Tombstone extends GVertexResult implements
570       org.apache.gora.persistency.Tombstone {
571 
572     /**
573      * Default constructor.
574      */
575     private Tombstone() {
576     }
577 
578     /**
579      * Gets the value of the 'vertexId' field.
580      * @return java.lang.CharSequence
581      */
582     public java.lang.CharSequence getVertexId() {
583       throw new java.lang.UnsupportedOperationException(
584           "Get is not supported on tombstones");
585     }
586 
587     /**
588      * Sets the value of the 'vertexId' field.
589      * @param value the value to set.
590      */
591     public void setVertexId(java.lang.CharSequence value) {
592       throw new java.lang.UnsupportedOperationException(
593           "Set is not supported on tombstones");
594     }
595 
596     /**
597      * Checks the dirty status of the 'vertexId' field. A field is dirty if it
598      * represents a change that has not yet been written to the database.
599      * @param value the value to set.
600      * @return boolean
601      */
602     public boolean isVertexIdDirty(java.lang.CharSequence value) {
603       throw new java.lang.UnsupportedOperationException(
604           "IsDirty is not supported on tombstones");
605     }
606 
607     /**
608      * Gets the value of the 'vertexValue' field.
609      * @return Float
610      */
611     public java.lang.Float getVertexValue() {
612       throw new java.lang.UnsupportedOperationException(
613           "Get is not supported on tombstones");
614     }
615 
616     /**
617      * Sets the value of the 'vertexValue' field.
618      * @param value the value to set.
619      */
620     public void setVertexValue(java.lang.Float value) {
621       throw new java.lang.UnsupportedOperationException(
622           "Set is not supported on tombstones");
623     }
624 
625     /**
626      * Checks the dirty status of the 'vertexValue' field. A field is dirty if
627      * it represents a change that has not yet been written to the database.
628      * @param value the value to set.
629      * @return boolean
630      */
631     public boolean isVertexValueDirty(java.lang.Float value) {
632       throw new java.lang.UnsupportedOperationException(
633           "IsDirty is not supported on tombstones");
634     }
635 
636     /**
637      * Gets the value of the 'edges' field.
638      * @return java.util.Map
639      */
640     public java.util.Map<java.lang.CharSequence, java.lang.CharSequence>
641     getEdges() {
642       throw new java.lang.UnsupportedOperationException(
643           "Get is not supported on tombstones");
644     }
645 
646     /**
647      * Sets the value of the 'edges' field.
648      * @param value the value to set.
649      */
650     public void setEdges(
651         java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
652       throw new java.lang.UnsupportedOperationException(
653           "Set is not supported on tombstones");
654     }
655 
656     /**
657      * Checks the dirty status of the 'edges' field. A field is dirty if it
658      * represents a change that has not yet been written to the database.
659      * @param value the value to set.
660      * @return boolean
661      */
662     public boolean isEdgesDirty(
663         java.util.Map<java.lang.CharSequence, java.lang.CharSequence> value) {
664       throw new java.lang.UnsupportedOperationException(
665           "IsDirty is not supported on tombstones");
666     }
667   }
668 }