Open a ranged byte stream from `store` and return a ready-to-poll `AlignedBoundaryStream`. Issues a single bounded `get_opts` call covering `[fetch_start, raw_end + END_SCAN_LOOKAHEAD)`. If the terminating newline is not found within that window, `ScanningLastTerminator` automatically issues additional `END_SCAN_LOOKAHEAD`-sized GETs via `store` until the newline is found or EOF is reached.
(
store: Arc<dyn ObjectStore>,
location: object_store::path::Path,
raw_start: u64,
raw_end: u64,
file_size: u64,
terminator: u8,
)
| 149 | /// automatically issues additional `END_SCAN_LOOKAHEAD`-sized GETs |
| 150 | /// via `store` until the newline is found or EOF is reached. |
| 151 | pub async fn new( |
| 152 | store: Arc<dyn ObjectStore>, |
| 153 | location: object_store::path::Path, |
| 154 | raw_start: u64, |
| 155 | raw_end: u64, |
| 156 | file_size: u64, |
| 157 | terminator: u8, |
| 158 | ) -> object_store::Result<Self> { |
| 159 | if raw_start >= raw_end || raw_start >= file_size { |
| 160 | return Ok(Self { |
| 161 | inner: futures::stream::empty().boxed(), |
| 162 | terminator, |
| 163 | end: 0, |
| 164 | bytes_consumed: 0, |
| 165 | fetch_start: 0, |
| 166 | phase: Phase::Done, |
| 167 | pending: None, |
| 168 | store, |
| 169 | location, |
| 170 | file_size, |
| 171 | }); |
| 172 | } |
| 173 | |
| 174 | let (fetch_start, phase) = if raw_start == 0 { |
| 175 | (0, Phase::FetchingChunks) |
| 176 | } else { |
| 177 | (raw_start - 1, Phase::ScanningFirstTerminator) |
| 178 | }; |
| 179 | |
| 180 | let initial_fetch_end = raw_end.saturating_add(END_SCAN_LOOKAHEAD).min(file_size); |
| 181 | |
| 182 | let inner = get_stream( |
| 183 | Arc::clone(&store), |
| 184 | location.clone(), |
| 185 | fetch_start..initial_fetch_end, |
| 186 | ) |
| 187 | .await?; |
| 188 | |
| 189 | // Last partition reads until EOF is reached — no end-boundary scanning needed. |
| 190 | let end = if raw_end >= file_size { |
| 191 | u64::MAX |
| 192 | } else { |
| 193 | raw_end |
| 194 | }; |
| 195 | |
| 196 | Ok(Self { |
| 197 | inner, |
| 198 | terminator, |
| 199 | end, |
| 200 | bytes_consumed: 0, |
| 201 | fetch_start, |
| 202 | phase, |
| 203 | pending: None, |
| 204 | store, |
| 205 | location, |
| 206 | file_size, |
| 207 | }) |
| 208 | } |
nothing calls this directly
no test coverage detected