Skip to main content

cut

Function cut 

Source
pub fn cut(
    arena: &mut MorselArena,
    cut: StrCut,
    s: &ValueVector,
    n: &ValueVector,
    sel: Option<&SelVector>,
) -> Result<ValueVector>
Expand description

Evaluate cut(s, n) into a new flat string vector.

This is the trim’s trick a second time. What a cut answers is a part of what it was handed, so a flat or a constant argument’s answers are views back into the argument’s own bytes and the answer vector holds the same buffers rather than a copy of them. What is new is that the part is decided by a second column rather than by something the statement wrote, so the two encodings multiply: a count that is the same for the whole chunk lets a dictionary cut its table once, and a count that varies makes a coded column write a row at a time, since two rows over one entry no longer answer the same thing.

A dictionary is the one shape that has to write at all, an entry of a table not being bytes a view can name. Everything else copies nothing.