File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 82
82
"""
83
83
84
84
import os .path
85
- import sys
86
85
from bisect import (
87
86
insort ,
88
87
insort_right ,
124
123
BIN_OFFSETS_MAX .insert (0 , (BIN_OFFSETS_MAX [0 ] << BIN_NEXT_SHIFT ))
125
124
# The maximum size for the top bin is actually bigger than the signed integers
126
125
# we use to store positions in the file, so we'll change it to prevent confusion
127
- BIN_OFFSETS_MAX [0 ] = sys . maxsize
126
+ BIN_OFFSETS_MAX [0 ] = 2 ** 63
128
127
129
128
# Constants for the minimum and maximum size of the overall interval
130
129
MIN = 0
@@ -137,12 +136,14 @@ def offsets_for_max_size(max_size):
137
136
"""
138
137
Return the subset of offsets needed to contain intervals over (0,max_size)
139
138
"""
140
- for i , max in enumerate (reversed (BIN_OFFSETS_MAX )):
141
- if max_size < max :
139
+ offset_index = None
140
+ for i , off_max in enumerate (reversed (BIN_OFFSETS_MAX )):
141
+ if max_size <= off_max :
142
+ offset_index = i
142
143
break
143
- else :
144
+ if offset_index is None :
144
145
raise Exception ("%d is larger than the maximum possible size (%d)" % (max_size , BIN_OFFSETS_MAX [0 ]))
145
- return BIN_OFFSETS [(len (BIN_OFFSETS ) - i - 1 ) :]
146
+ return BIN_OFFSETS [(len (BIN_OFFSETS ) - offset_index - 1 ):]
146
147
147
148
148
149
def bin_for_range (start , end , offsets = None ):
You can’t perform that action at this time.
0 commit comments