@@ -142,7 +142,7 @@ long saveArcs(Node node, IndexOutput index, long startFP) throws IOException {
142
142
| (output .hasTerms ? (1 << 5 ) : 0 )
143
143
| (output .floorData != null ? (1 << 6 ) : 0 );
144
144
index .writeByte (((byte ) header ));
145
- writeLongNBytes (output .fp , outputFpBytes , index );
145
+ writeFpNBytes (output .fp , outputFpBytes , index );
146
146
if (output .floorData != null ) {
147
147
index .writeBytes (output .floorData .bytes , output .floorData .offset , output .floorData .length );
148
148
}
@@ -173,14 +173,14 @@ long saveArcs(Node node, IndexOutput index, long startFP) throws IOException {
173
173
int header = SIGN_SINGLE_CHILDREN | (childFpBytes << 2 ) | (encodedOutputFpBytes << 5 );
174
174
index .writeByte ((byte ) header );
175
175
index .writeByte ((byte ) node .children .getFirst ().label );
176
- writeLongNBytes (fpBuffer [0 ], childFpBytes , index );
176
+ writeFpNBytes (fpBuffer [0 ], childFpBytes , index );
177
177
if (node .output != null ) {
178
178
Output output = node .output ;
179
179
long encodedFp =
180
180
(output .floorData != null ? 0x01L : 0 )
181
181
| (output .hasTerms ? 0x02L : 0 )
182
182
| (output .fp << 2 );
183
- writeLongNBytes (encodedFp , encodedOutputFpBytes , index );
183
+ writeFpNBytes (encodedFp , encodedOutputFpBytes , index );
184
184
if (output .floorData != null ) {
185
185
index .writeBytes (
186
186
output .floorData .bytes , output .floorData .offset , output .floorData .length );
@@ -231,7 +231,7 @@ long saveArcs(Node node, IndexOutput index, long startFP) throws IOException {
231
231
Output output = node .output ;
232
232
long encodedFp =
233
233
(output .floorData != null ? 0x01L : 0 ) | (output .hasTerms ? 0x02L : 0 ) | (output .fp << 2 );
234
- writeLongNBytes (encodedFp , encodedOutputFpBytes , index );
234
+ writeFpNBytes (encodedFp , encodedOutputFpBytes , index );
235
235
}
236
236
237
237
long positionStartFp = index .getFilePointer ();
@@ -244,7 +244,7 @@ long saveArcs(Node node, IndexOutput index, long startFP) throws IOException {
244
244
+ (index .getFilePointer () - positionStartFp );
245
245
246
246
for (int i = 0 ; i < childrenNum ; i ++) {
247
- writeLongNBytes (fpBuffer [i ], childrenFpBytes , index );
247
+ writeFpNBytes (fpBuffer [i ], childrenFpBytes , index );
248
248
}
249
249
250
250
if (node .output != null && node .output .floorData != null ) {
@@ -259,7 +259,11 @@ private static int bytesRequired(long v) {
259
259
return Math .max (1 , Long .BYTES - (Long .numberOfLeadingZeros (v ) >>> 3 ));
260
260
}
261
261
262
- private static void writeLongNBytes (long v , int n , DataOutput out ) throws IOException {
262
+ private static void writeFpNBytes (long v , int n , DataOutput out ) throws IOException {
263
+ if (n > 7 ) {
264
+ throw new IllegalArgumentException (
265
+ "term dictionary can not have file pointers bigger than 2^56, got: " + v );
266
+ }
263
267
for (int i = 0 ; i < n ; i ++) {
264
268
out .writeByte ((byte ) v );
265
269
v >>= 8 ;
0 commit comments