423423 filter_size = ? DEFAULT_FILTER_SIZE :: osiris_bloom :filter_size ()
424424 }).
425425-record (ra ,
426- {on = true :: boolean (),
427- size = ? HEADER_SIZE_B + ? DEFAULT_FILTER_SIZE :: non_neg_integer (),
426+ {size = ? HEADER_SIZE_B + ? DEFAULT_FILTER_SIZE :: non_neg_integer (),
428427 buf :: undefined | {Pos :: non_neg_integer (), binary ()},
429- limit = ? DEFAULT_READ_AHEAD_LIMIT :: pos_integer ()
428+ % % Max number of bytes that can be read ahead. Set to zero to
429+ % % turn off read-ahead.
430+ limit = ? DEFAULT_READ_AHEAD_LIMIT :: non_neg_integer ()
430431 }).
431432-record (read ,
432433 {type :: data | offset ,
@@ -3312,7 +3313,7 @@ iter_guess_size(Credit0, NumEntries, DataSize) ->
33123313 (DataSize div NumEntries * Credit ).
33133314
33143315iter_read_ahead (Fd , Pos , MinReqSize , Credit0 , DataSize , NumEntries ,
3315- # ra {limit = ReadAheadLimit } = Ra0 )
3316+ # ra {limit = ReadAheadLimit0 } = Ra0 )
33163317 when is_integer (Credit0 ) andalso
33173318 MinReqSize =< DataSize ->
33183319 % % if the minimum request size can be served from read ahead then we
@@ -3335,6 +3336,8 @@ iter_read_ahead(Fd, Pos, MinReqSize, Credit0, DataSize, NumEntries,
33353336 % % needed to serve that, else we read up to the readahead
33363337 % % limit but not beyond the end of the chunk and not less
33373338 % % that the minimum request size
3339+ ReadAheadLimit = max (ReadAheadLimit0 ,
3340+ ? DEFAULT_READ_AHEAD_LIMIT ),
33383341 MinSize = max (MinReqSize , min (ReadAheadLimit , DataSize )),
33393342 Size = max (MinSize , iter_guess_size (Credit0 , NumEntries ,
33403343 DataSize )),
@@ -3364,15 +3367,17 @@ ra_read(_Pos, _Len, _Ra) ->
33643367 undefined .
33653368
33663369ra_update_size (undefined , FilterSize , LastDataSize ,
3367- # ra {on = true , size = Sz , limit = Limit } = Ra )
3368- when Sz < Limit andalso
3370+ # ra {size = Sz , limit = Limit } = Ra )
3371+ when Limit =/= 0 andalso
3372+ Sz < Limit andalso
33693373 LastDataSize =< (Limit - ? HEADER_SIZE_B -
33703374 FilterSize - ? REC_HDR_SZ_SUBBATCH_B ) ->
33713375 % % no filter and last data size was small so enable data read ahead
33723376 Ra # ra {size = Limit };
33733377ra_update_size (undefined , FilterSize , LastDataSize ,
3374- # ra {on = true , size = Limit , limit = Limit } = Ra )
3375- when LastDataSize =< (Limit - ? HEADER_SIZE_B -
3378+ # ra {size = Limit , limit = Limit } = Ra )
3379+ when Limit =/= 0 andalso
3380+ LastDataSize =< (Limit - ? HEADER_SIZE_B -
33763381 FilterSize - ? REC_HDR_SZ_SUBBATCH_B ) ->
33773382 Ra ;
33783383ra_update_size (_Filter , FilterSize , _LastDataSize , # ra {size = Sz } = Ra ) ->
@@ -3399,11 +3404,11 @@ ra_fill(Fd, Pos, #ra{size = Sz} = Ra) ->
33993404
34003405-spec ra (config ()) -> # ra {}.
34013406ra (#{options := #{read_ahead := false }}) ->
3402- # ra {on = false };
3403- ra (#{options := #{read_ahead_limit := Limit }}) when is_integer (Limit ) ->
3407+ # ra {limit = 0 };
3408+ ra (#{options := #{read_ahead := Limit }}) when is_integer (Limit ) ->
34043409 # ra {limit = Limit };
34053410ra (_ ) ->
3406- # ra {on = true }.
3411+ # ra {}.
34073412
34083413generate_log (Msg , MsgsPerChunk , NumMessages , Directory ) ->
34093414 Name = filename :basename (Directory ),
0 commit comments