Skip to content

Use Record's public API in a bunch of places#10927

Merged
sholderbach merged 16 commits intonushell:mainfrom
sholderbach:boring-record-api
Nov 8, 2023
Merged

Use Record's public API in a bunch of places#10927
sholderbach merged 16 commits intonushell:mainfrom
sholderbach:boring-record-api

Conversation

@sholderbach
Copy link
Copy Markdown
Member

Description

Since #10841 the goal is to remove the implementation details of Record outside of core operations.

To this end use Record iterators and map-like accessors in a bunch of places. In this PR I try to collect the boring cases where I don't expect any dramatic performance impacts or don't have doubts about the correctness afterwards

  • Use checked record construction in nu_plugin_example
  • Use Record::into_iter in columns
  • Use Record iterators in headers cmd
  • Use explicit record iterators in split-by
  • Use Record::into_iter in variable completions
  • Use Record::values iterator in into sqlite
  • Use Record::iter_mut for-loop in default
  • Change nu_engine::nonexistent_column to use iterator
  • Use Record::columns iter in nu-cmd-base
  • Use Record::get_index in nu-command/network/http
  • Use Record.insert() in merge
  • Refactor move to use encapsulated record API
  • Use Record.insert() in explore
  • Use proper Record API in explore
  • Remove defensiveness around record in explore
  • Use encapsulated record API in more nu-commands

User-Facing Changes

None intentional

Tests + Formatting

(-)

This could be a use case for a specific `.into_columns` consuming
iterator, but else rarely used.
Could be another usecase for an explicit `IntoColumns` consuming
iterator. (see `columns` implementation).
We should also check if we clone/create unnecessary values here, when we
only care about the columns.
Drastically simplifies the code

TODO: rewrite the helper to mutate the data directly
Manually running `.index_of` and then using `.get_index` feels a bit
pedestrian but should work.
Touches:
- `flatten`
- `sort`
- `uniq`
- `to md`
- `to nuon`
- `str trim`

Nothing extraordinary so squashed commit.
sholderbach added a commit that referenced this pull request Nov 8, 2023
# Description
Rewrite `find` internals with the same principles as in #10927.

Here we can remove an unnecessary lookup accross all columns when not
narrowing find to particular columns

- Change `find` internal fns to use iterators
- Remove unnecessary quadratic lookup in `find`
- Refactor `find` record highlight logic
# User-Facing Changes
Should provide a small speedup when not providing `find --columns`

# Tests + Formatting
(-)
@sholderbach sholderbach merged commit edbf3aa into nushell:main Nov 8, 2023
@sholderbach sholderbach deleted the boring-record-api branch November 8, 2023 13:24
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
# Description
Rewrite `find` internals with the same principles as in nushell#10927.

Here we can remove an unnecessary lookup accross all columns when not
narrowing find to particular columns

- Change `find` internal fns to use iterators
- Remove unnecessary quadratic lookup in `find`
- Refactor `find` record highlight logic
# User-Facing Changes
Should provide a small speedup when not providing `find --columns`

# Tests + Formatting
(-)
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
# Description
Since nushell#10841 the goal is to remove the implementation details of
`Record` outside of core operations.

To this end use Record iterators and map-like accessors in a bunch of
places. In this PR I try to collect the boring cases where I don't
expect any dramatic performance impacts or don't have doubts about the
correctness afterwards

- Use checked record construction in `nu_plugin_example`
- Use `Record::into_iter` in `columns`
- Use `Record` iterators in `headers` cmd
- Use explicit record iterators in `split-by`
- Use `Record::into_iter` in variable completions
- Use `Record::values` iterator in `into sqlite`
- Use `Record::iter_mut` for-loop in `default`
- Change `nu_engine::nonexistent_column` to use iterator
- Use `Record::columns` iter in `nu-cmd-base`
- Use `Record::get_index` in `nu-command/network/http`
- Use `Record.insert()` in `merge`
- Refactor `move` to use encapsulated record API
- Use `Record.insert()` in `explore`
- Use proper `Record` API in `explore`
- Remove defensiveness around record in `explore`
- Use encapsulated record API in more `nu-command`s

# User-Facing Changes
None intentional

# Tests + Formatting
(-)
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
# Description
Rewrite `find` internals with the same principles as in nushell#10927.

Here we can remove an unnecessary lookup accross all columns when not
narrowing find to particular columns

- Change `find` internal fns to use iterators
- Remove unnecessary quadratic lookup in `find`
- Refactor `find` record highlight logic
# User-Facing Changes
Should provide a small speedup when not providing `find --columns`

# Tests + Formatting
(-)
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
# Description
Since nushell#10841 the goal is to remove the implementation details of
`Record` outside of core operations.

To this end use Record iterators and map-like accessors in a bunch of
places. In this PR I try to collect the boring cases where I don't
expect any dramatic performance impacts or don't have doubts about the
correctness afterwards

- Use checked record construction in `nu_plugin_example`
- Use `Record::into_iter` in `columns`
- Use `Record` iterators in `headers` cmd
- Use explicit record iterators in `split-by`
- Use `Record::into_iter` in variable completions
- Use `Record::values` iterator in `into sqlite`
- Use `Record::iter_mut` for-loop in `default`
- Change `nu_engine::nonexistent_column` to use iterator
- Use `Record::columns` iter in `nu-cmd-base`
- Use `Record::get_index` in `nu-command/network/http`
- Use `Record.insert()` in `merge`
- Refactor `move` to use encapsulated record API
- Use `Record.insert()` in `explore`
- Use proper `Record` API in `explore`
- Remove defensiveness around record in `explore`
- Use encapsulated record API in more `nu-command`s

# User-Facing Changes
None intentional

# Tests + Formatting
(-)
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.

1 participant