@@ -57,7 +57,6 @@ static class Node {
57
57
public Map <Long , Node > children ;
58
58
public long tagOffset ;
59
59
public long childOffset ;
60
- public long myOffset ;
61
60
62
61
Node (long hash , String tag ) {
63
62
this .hash = hash ;
@@ -87,7 +86,7 @@ public static long myHash(String name) {
87
86
n = 100 ;
88
87
}
89
88
for (int i = 0 ; i < n ; i ++) {
90
- hash = (hash * 641 + name .charAt (i ) * 2969 + hash << 6 ) % 9322397 ;
89
+ hash = (hash * 641L + name .charAt (i ) * 2969 + hash << 6 ) % 9322397 ;
91
90
}
92
91
return hash ;
93
92
}
@@ -97,28 +96,28 @@ private void write(Node n, DataOutputStream out) throws IOException {
97
96
out .write (n .tag .getBytes ());
98
97
offset += n .tag .length ();
99
98
}
100
- for (Node childnode : n .children .values ()) {
101
- out .writeLong (childnode .hash );
102
- if (childnode .children .size () > 0 ) {
103
- out .writeShort ((short ) (childnode .childOffset - offset ));
104
- out .writeShort ((short ) childnode .children .size ());
99
+ for (Node childNode : n .children .values ()) {
100
+ out .writeLong (childNode .hash );
101
+ if (childNode .children .size () > 0 ) {
102
+ out .writeShort ((short ) (childNode .childOffset - offset ));
103
+ out .writeShort ((short ) childNode .children .size ());
105
104
} else {
106
105
out .writeShort (0 );
107
- if (childnode .tag == null ) {
106
+ if (childNode .tag == null ) {
108
107
out .writeShort ((short ) 0 );
109
108
} else {
110
- out .writeShort ((short ) childnode .tag .length ());
109
+ out .writeShort ((short ) childNode .tag .length ());
111
110
}
112
111
}
113
- if (childnode .tag == null ) {
112
+ if (childNode .tag == null ) {
114
113
out .writeShort (0 );
115
114
} else {
116
- out .writeShort ((short ) (childnode .tagOffset - offset ));
115
+ out .writeShort ((short ) (childNode .tagOffset - offset ));
117
116
}
118
117
offset += RECORD_LENGTH ;
119
118
}
120
- for (Node childnode : n .children .values ()) {
121
- write (childnode , out );
119
+ for (Node childNode : n .children .values ()) {
120
+ write (childNode , out );
122
121
}
123
122
}
124
123
@@ -131,7 +130,7 @@ private void traverse(Node n) {
131
130
}
132
131
if (n .children .size () > 0 ) {
133
132
n .childOffset = offset ;
134
- offset += (RECORD_LENGTH * n .children .size ());
133
+ offset += (( long ) RECORD_LENGTH * n .children .size ());
135
134
} else {
136
135
n .childOffset = 0 ;
137
136
}
@@ -143,9 +142,8 @@ private void traverse(Node n) {
143
142
/**
144
143
* Reads the input into interim representation. Can be called multiple times.
145
144
* @param descriptions set of PathDescription
146
- * @throws IOException
147
145
*/
148
- private void readInput (Set <PathDescription > descriptions ) throws IOException {
146
+ private void readInput (Set <PathDescription > descriptions ) {
149
147
if (root == null ) {
150
148
root = new Node (1 , null );
151
149
}
@@ -163,8 +161,7 @@ private void readInput(Set<PathDescription> descriptions) throws IOException {
163
161
public void write (String outPath ) throws IOException {
164
162
offset = RECORD_LENGTH ;
165
163
traverse (root );
166
- try (DataOutputStream out = new DataOutputStream (
167
- new BufferedOutputStream (new FileOutputStream (outPath )))) {
164
+ try (DataOutputStream out = new DataOutputStream (new BufferedOutputStream (new FileOutputStream (outPath )))) {
168
165
out .writeLong (0x5e33 );
169
166
out .writeShort (RECORD_LENGTH );
170
167
out .writeShort (root .children .size ());
0 commit comments