Skip to content

Commit 2e0df78

Browse files
joseph-isaacsclaude
andcommitted
refactor(array): pass the execution context into search_index_chunked
Take the context as a parameter instead of building one from the legacy session inside the method. `search_index` builds it once for the chunked path. Signed-off-by: "Joe Isaacs" <joe.isaacs@live.co.uk> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ACe1mztjw9vNFUYwzVhGwz
1 parent 0ea6472 commit 2e0df78

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎vortex-array/src/patches.rs‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,11 @@ impl Patches {
470470
///
471471
/// [`SearchResult::Found(patch_idx)`]: SearchResult::Found
472472
/// [`SearchResult::NotFound(insertion_point)`]: SearchResult::NotFound
473+
#[allow(clippy::disallowed_methods)]
473474
pub fn search_index(&self, index: usize) -> VortexResult<SearchResult> {
474475
if self.chunk_offsets.is_some() {
475-
return self.search_index_chunked(index);
476+
let mut ctx = legacy_session().create_execution_ctx();
477+
return self.search_index_chunked(index, &mut ctx);
476478
}
477479

478480
search_index_binary_search(&self.indices, index + self.offset)
@@ -487,8 +489,11 @@ impl Patches {
487489
/// or the insertion point if not found.
488490
///
489491
/// Returns an error if `chunk_offsets` or `offset_within_chunk` are not set.
490-
#[allow(clippy::disallowed_methods)]
491-
fn search_index_chunked(&self, index: usize) -> VortexResult<SearchResult> {
492+
fn search_index_chunked(
493+
&self,
494+
index: usize,
495+
ctx: &mut ExecutionCtx,
496+
) -> VortexResult<SearchResult> {
492497
let Some(chunk_offsets) = &self.chunk_offsets else {
493498
vortex_bail!("chunk_offsets is required to be set")
494499
};
@@ -503,13 +508,12 @@ impl Patches {
503508

504509
let chunk_idx = (index + self.offset % PATCH_CHUNK_SIZE) / PATCH_CHUNK_SIZE;
505510

506-
// The three reads below are of the same array, so they share one probe and one context
507-
// rather than building a pair per read as `Self::chunk_offset_at` does.
511+
// The three reads below are of the same array, so they share one probe rather than
512+
// building one per read as `Self::chunk_offset_at` does.
508513
let mut probe = chunk_offsets.repeated_probe();
509-
let mut ctx = legacy_session().create_execution_ctx();
510514
let mut chunk_offset_at = |idx: usize| -> VortexResult<usize> {
511515
probe
512-
.execute_scalar(idx, &mut ctx)?
516+
.execute_scalar(idx, ctx)?
513517
.as_primitive()
514518
.as_::<usize>()
515519
.ok_or_else(|| vortex_err!("chunk offset does not fit in usize"))

0 commit comments

Comments
 (0)