122122
123123-define (SKIP_SEARCH_JUMP , 2048 ).
124124-define (DEFAULT_READ_AHEAD_LIMIT , 4096 ).
125- % % Block size for index scan in fold_index_files_closest (records per read)
126- -define (INDEX_READ_BLOCK_RECORDS , 1024 ).
127- -define (INDEX_READ_BLOCK_BYTES , (? INDEX_READ_BLOCK_RECORDS * ? INDEX_RECORD_SIZE_B )).
128125
129126% % Specification of the Log format.
130127% %
@@ -3522,7 +3519,8 @@ write_in_chunks(_, _, _, W) ->
35223519% % Fractions is a list of floats in [0.0, 1.0]: 0.0 = first, 1.0 = last;
35233520% % values in between are linear (e.g. 0.5 = midpoint by chunk id).
35243521% % Returns {ok, [ {float(), offset(), timestamp()} ]} (one 3-tuple per requested fraction),
3525- % % or {error, empty}. Fractions are clamped to [0.0, 1.0].
3522+ % % or {error, empty}.
3523+ % % Fractions below 0.0 are normalized to 0.0; fractions above 1.0 are normalized to 1.0.
35263524-spec stream_offset_samples (file :filename_all () | config (), [float ()]) ->
35273525 {ok , [{float (), offset (), osiris :timestamp ()}]} | {error , empty }.
35283526stream_offset_samples (_DirOrConfig , []) ->
@@ -3539,7 +3537,7 @@ stream_offset_samples(DirOrConfig, Fractions0) ->
35393537
35403538-spec stream_offset_samples_with_index (Fractions :: [float ()], IdxFiles :: list ()) ->
35413539 {ok , [{float (), offset (), osiris :timestamp ()}]} | {error , empty }.
3542- % % Pre: IdxFiles is non-empty.
3540+
35433541stream_offset_samples_with_index (Fractions , IdxFiles ) ->
35443542 case first_and_last_seginfos0 (IdxFiles ) of
35453543 none ->
@@ -3575,7 +3573,6 @@ normalize_fraction(F) when F =< 0.0 -> 0.0;
35753573normalize_fraction (F ) when F >= 1.0 -> 1.0 ;
35763574normalize_fraction (F ) -> F .
35773575
3578- % % Returns [{float(), offset(), timestamp()}]. Order: first (if requested), middle samples, last (if requested).
35793576assemble_offset_samples (Fractions , First , Last , MiddleSamples ) ->
35803577 FirstPart = case lists :member (0.0 , Fractions ) of
35813578 true -> [First ];
@@ -3592,7 +3589,8 @@ target_chunk_id(FirstChId, Range, 1.0) -> FirstChId + Range;
35923589target_chunk_id (FirstChId , Range , F ) ->
35933590 FirstChId + round ((Range * F )).
35943591
3595- % % Multi-target version: one idx_skip_search pass over the index.
3592+ % % multi_offset_sample_search_fun: one idx_skip_search pass over the index to gather
3593+ % % as many offset samples in Pending list as exists in one index file.
35963594% % Acc = {Pending, Results, LastChunk}.
35973595% % Pending = [{float(), offset()}] remaining targets.
35983596% % Results = [{float(), offset(), timestamp()}]. LastChunk = undefined | {ChunkId, Ts}.
@@ -3682,8 +3680,6 @@ find_offsets_on_index_file(TargetOffsets, IdxFile, AccResults) ->
36823680 end .
36833681
36843682
3685-
3686-
36873683-ifdef (TEST ).
36883684-include_lib (" eunit/include/eunit.hrl" ).
36893685
0 commit comments