New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDB Command to Add Array Values #1610

Open
sanssecours opened this Issue Sep 22, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@sanssecours
Contributor

sanssecours commented Sep 22, 2017

Description

Currently we have to set array keys using the syntax array/#number_of_entry:

kdb set user/array
kdb set user/array/#0 "first element"
kdb set user/array/#1 "second element"

kdb ls user/array
#> user/array
#> user/array/#0
#> user/array/#1

. This works, but if we want to add something at the last place of the array we have to know the last index. It might make sense to add a new command to kdb that adds a value at the last position of an array. The syntax of the command could look something like this:

kdb add user/array "third element"
kdb ls user/array
#> user/array
#> user/array/#0
#> user/array/#1
#> user/array/#2

kdb add user/newarray "No 1"
kdb ls user/newarray
#> user/newarray
#> user/newarray/#0
kdb get user/newarray/#0
#> No 1

. If we add such an command, then we should probably address issue #182 first.

@markus2330

This comment has been minimized.

Show comment
Hide comment
@markus2330

markus2330 Sep 22, 2017

Contributor

Thank you for the feature request! I agree it would be very handy. It is already implemented in Ruby (for Puppet integration), but it is missing in the command-line interface.

I think there is no problem in using a higher-level languages or scripts for such convenience commands.

Btw. in doc/todo/TOOLS Line 88 such a tool is already proposed, but your examples are much clearer. I think, however, we should consider to use less generic names ("add" could be anything, see also #265).

Contributor

markus2330 commented Sep 22, 2017

Thank you for the feature request! I agree it would be very handy. It is already implemented in Ruby (for Puppet integration), but it is missing in the command-line interface.

I think there is no problem in using a higher-level languages or scripts for such convenience commands.

Btw. in doc/todo/TOOLS Line 88 such a tool is already proposed, but your examples are much clearer. I think, however, we should consider to use less generic names ("add" could be anything, see also #265).

@sanssecours

This comment has been minimized.

Show comment
Hide comment
@sanssecours

sanssecours Sep 22, 2017

Contributor

I think, however, we should consider to use less generic names ("add" could be anything, see also #265).

How about kdb append then? Another option might be kdb list add, but unfortunately kdb list is already taken. We could rename the current command list to list-plugins though.

Contributor

sanssecours commented Sep 22, 2017

I think, however, we should consider to use less generic names ("add" could be anything, see also #265).

How about kdb append then? Another option might be kdb list add, but unfortunately kdb list is already taken. We could rename the current command list to list-plugins though.

@markus2330

This comment has been minimized.

Show comment
Hide comment
@markus2330

markus2330 Sep 22, 2017

Contributor

What about setarray? (or array-set conforming to #265) array-add or array-append, array is okay, too. "list" is as generic as "add", we should rather avoid it.

Shouldn't we provide a full set of array commands? (array-rm, array-ls, array-...)

Contributor

markus2330 commented Sep 22, 2017

What about setarray? (or array-set conforming to #265) array-add or array-append, array is okay, too. "list" is as generic as "add", we should rather avoid it.

Shouldn't we provide a full set of array commands? (array-rm, array-ls, array-...)

@sanssecours

This comment has been minimized.

Show comment
Hide comment
@sanssecours

sanssecours Sep 22, 2017

Contributor

What about setarray? (or array-set conforming to #265) array-add or array-append, array is okay, too.

Command Rating
setarray ★★⭐︎⭐︎⭐︎
array-set ★★⭐︎⭐︎⭐︎
array-add ★★★⭐︎⭐︎
array-append ★★★⭐︎⭐︎

"list" is as generic as "add", we should rather avoid it.

Great, then let us rename kdb list to kdb list-plugins 😊.

Shouldn't we provide a full set of array commands? (array-rm, array-ls, array-...)

Yes, that would be great and also why I suggested kdb list. We could then add multiple commands like:

  • kdb list length: Return the number of elements of an array
  • kdb list append: Add an element at the end of an array
  • kdb list set: Replace an array element at a certain position

. Replacing list with array in the commands above would be okay with me too.

Contributor

sanssecours commented Sep 22, 2017

What about setarray? (or array-set conforming to #265) array-add or array-append, array is okay, too.

Command Rating
setarray ★★⭐︎⭐︎⭐︎
array-set ★★⭐︎⭐︎⭐︎
array-add ★★★⭐︎⭐︎
array-append ★★★⭐︎⭐︎

"list" is as generic as "add", we should rather avoid it.

Great, then let us rename kdb list to kdb list-plugins 😊.

Shouldn't we provide a full set of array commands? (array-rm, array-ls, array-...)

Yes, that would be great and also why I suggested kdb list. We could then add multiple commands like:

  • kdb list length: Return the number of elements of an array
  • kdb list append: Add an element at the end of an array
  • kdb list set: Replace an array element at a certain position

. Replacing list with array in the commands above would be okay with me too.

@markus2330

This comment has been minimized.

Show comment
Hide comment
@markus2330

markus2330 Oct 5, 2017

Contributor

We could then add multiple commands like kdb list length

Currently we use "-" to form an hierarchy. This makes it easier to implement subcommands in different programming languages (e.g. scripts).

Contributor

markus2330 commented Oct 5, 2017

We could then add multiple commands like kdb list length

Currently we use "-" to form an hierarchy. This makes it easier to implement subcommands in different programming languages (e.g. scripts).

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