Skip to content

Comments

Improve docs for sending flight dictionaries#1

Merged
alexwilcoxson-rel merged 1 commit intorelativityone:flight-send-dictionaryfrom
alamb:flight-send-dictionary
Oct 12, 2023
Merged

Improve docs for sending flight dictionaries#1
alexwilcoxson-rel merged 1 commit intorelativityone:flight-send-dictionaryfrom
alamb:flight-send-dictionary

Conversation

@alamb
Copy link

@alamb alamb commented Oct 11, 2023

Here is a proposal to improve the documentation and fix the doc test errors in apache#4896 from @alexwilcoxson-rel

Merging this PR will update apache#4896

@alexwilcoxson-rel alexwilcoxson-rel merged commit f275a3b into relativityone:flight-send-dictionary Oct 12, 2023
@alamb alamb deleted the flight-send-dictionary branch October 12, 2023 10:34
mandrush pushed a commit that referenced this pull request Feb 23, 2026
# Which issue does this PR close?

small optimization

# Rationale for this change
key insight is the byte clone is cheap just a ref count compare to vec
clone is a alloc + memcopy.

before
```
let mut result = Vec::new();          // alloc #1
result.extend_from_slice(prefix);
result.extend_from_slice(suffix);

let data = Bytes::from(result.clone()); // alloc #2 + memcpy
item.set_from_bytes(data);
self.previous_value = result;          // keep Vec
```

after
```
let mut result = Vec::with_capacity(prefix_len + suffix.len()); // alloc #1
result.extend_from_slice(&self.previous_value[..prefix_len]);
result.extend_from_slice(suffix);

let data = Bytes::from(result);       // no alloc, takes Vec buffer
item.set_from_bytes(data.clone());    // cheap refcount bump
self.previous_value = data;           // move, no alloc
```

# What changes are included in this PR?
previous_value type changed to Bytes
preallocate result vec capacity.

# Are these changes tested?

the existing test should pass

# Are there any user-facing changes?

no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants