1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.utils;
20
21 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
22 import org.apache.hadoop.io.WritableComparable;
23
24
25
26
27
28
29
30 public abstract class ByteStructVertexIdIterator<I extends WritableComparable>
31 implements VertexIdIterator<I> {
32
33 protected final ExtendedDataInput extendedDataInput;
34
35
36 protected I vertexId;
37
38
39
40
41
42
43
44 public ByteStructVertexIdIterator(
45 ExtendedDataOutput extendedDataOutput,
46 ImmutableClassesGiraphConfiguration<I, ?, ?> conf) {
47 if (extendedDataOutput != null && conf != null) {
48 extendedDataInput = conf.createExtendedDataInput(extendedDataOutput);
49 } else {
50 throw new IllegalStateException("Cannot instantiate vertexIdIterator " +
51 "with null arguments");
52 }
53 }
54
55 @Override
56 public boolean hasNext() {
57 return !extendedDataInput.endOfInput();
58 }
59
60 @Override
61 public I getCurrentVertexId() {
62 return vertexId;
63 }
64
65 @Override
66 public I releaseCurrentVertexId() {
67 I releasedVertexId = vertexId;
68 vertexId = null;
69 return releasedVertexId;
70 }
71 }