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 java.io.DataOutput;
22 import java.io.IOException;
23
24 import org.apache.hadoop.io.Writable;
25 import org.apache.hadoop.io.WritableComparable;
26
27
28 public class VerboseByteStructMessageWrite {
29
30
31
32 private VerboseByteStructMessageWrite() {
33 }
34
35
36
37
38
39
40
41
42
43
44
45
46 public static <I extends WritableComparable, M extends Writable>
47 void verboseWriteCurrentMessage(
48 VertexIdMessageIterator<I, M> iterator,
49 DataOutput out
50 ) throws IOException {
51 verboseWriteCurrentMessage(
52 iterator.getCurrentVertexId(), iterator.getCurrentMessage(), out);
53 }
54
55
56
57
58
59
60
61
62
63
64
65
66
67 public static <I extends WritableComparable, M extends Writable>
68 void verboseWriteCurrentMessage(
69 I vertexId,
70 M message,
71 DataOutput out
72 ) throws IOException {
73 try {
74 message.write(out);
75 } catch (NegativeArraySizeException e) {
76 handleNegativeArraySize(vertexId);
77 }
78 }
79
80
81
82
83
84
85
86 public static <I extends WritableComparable>
87 void handleNegativeArraySize(I vertexId) {
88 throw new RuntimeException("The number of bytes sent to vertex " +
89 vertexId + " exceeded the max capacity of its buffer. Please consider" +
90 " setting giraph.useBigDataIOForMessages to true. You can do" +
91 " this by adding the following option to your command line:" +
92 " -Dgiraph.useBigDataIOForMessages=true." +
93 " If there are super-vertices in the graph that receive many messages," +
94 " setting this option will remove that limit");
95 }
96 }