[#xx] Add support for select-filter expressions in policy playground #527

Merged
fyrchik merged 1 commit from ale64bit/frostfs-node:feature/eval-select-filter-expr into master 2023-07-18 13:16:00 +00:00
Member

This allows the evaluation of fragments of a policy so that it can be understood and developed incrementally.

Usage:

Setup a test netmap:

> add 01 Char:A Shape:Circle  Color:Blue
> add 02 Char:B Shape:Circle  Color:Green
> add 03 Char:C Shape:Circle  Color:Red
> add 04 Char:D Shape:Square  Color:Blue
> add 05 Char:E Shape:Square  Color:Green
> add 06 Char:F Shape:Square  Color:Red
> add 07 Char:G Shape:Diamond Color:Blue
> add 08 Char:H Shape:Diamond Color:Green
> add 09 Char:I Shape:Diamond Color:Red

Evaluate filters:

> eval FILTER Color EQ 'Blue' AS BlueNodes
	 1: [01 07 04]
> eval FILTER Color EQ 'Red' AS RedNodes
	 1: [03 09 06]
> eval FILTER Color EQ 'Blue' AS BlueNodes FILTER Color EQ 'Red' AS RedNodes FILTER @RedNodes OR @BlueNodes AS RedOrBlueNodes
	 1: [06 07 04 03 09 01]

Evaluate selectors:

> eval SELECT 1 FROM *
	 1: [06 05 02]
> eval CBF 1 SELECT 1 FROM *
	 1: [06]
> eval SELECT 3 FROM *
	 1: [06 03 04]
	 2: [05 01 07]
	 3: [02 09 08]

Evaluate combined filters and selectors:

> eval CBF 2 SELECT 2 FROM RedOrBlueNodes FILTER Color EQ 'Blue' AS BlueNodes FILTER Color EQ 'Red' AS RedNodes FILTER @RedNodes OR @BlueNodes AS RedOrBlueNodes
	 1: [06 01]
	 2: [03 09]

Signed-off-by: Alejandro Lopez a.lopez@yadro.com

This allows the evaluation of fragments of a policy so that it can be understood and developed incrementally. Usage: Setup a test netmap: ``` > add 01 Char:A Shape:Circle Color:Blue > add 02 Char:B Shape:Circle Color:Green > add 03 Char:C Shape:Circle Color:Red > add 04 Char:D Shape:Square Color:Blue > add 05 Char:E Shape:Square Color:Green > add 06 Char:F Shape:Square Color:Red > add 07 Char:G Shape:Diamond Color:Blue > add 08 Char:H Shape:Diamond Color:Green > add 09 Char:I Shape:Diamond Color:Red ``` Evaluate filters: ```sql > eval FILTER Color EQ 'Blue' AS BlueNodes 1: [01 07 04] > eval FILTER Color EQ 'Red' AS RedNodes 1: [03 09 06] > eval FILTER Color EQ 'Blue' AS BlueNodes FILTER Color EQ 'Red' AS RedNodes FILTER @RedNodes OR @BlueNodes AS RedOrBlueNodes 1: [06 07 04 03 09 01] ``` Evaluate selectors: ```sql > eval SELECT 1 FROM * 1: [06 05 02] > eval CBF 1 SELECT 1 FROM * 1: [06] > eval SELECT 3 FROM * 1: [06 03 04] 2: [05 01 07] 3: [02 09 08] ``` Evaluate combined filters and selectors: ```sql > eval CBF 2 SELECT 2 FROM RedOrBlueNodes FILTER Color EQ 'Blue' AS BlueNodes FILTER Color EQ 'Red' AS RedNodes FILTER @RedNodes OR @BlueNodes AS RedOrBlueNodes 1: [06 01] 2: [03 09] ``` Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
ale64bit requested review from storage-core-committers 2023-07-17 11:07:15 +00:00
ale64bit requested review from storage-core-developers 2023-07-17 11:07:15 +00:00
ale64bit force-pushed feature/eval-select-filter-expr from 6371b286c1 to 62efde94f2 2023-07-17 11:07:53 +00:00 Compare
dstepanov-yadro approved these changes 2023-07-18 06:59:26 +00:00
fyrchik approved these changes 2023-07-18 10:48:52 +00:00
@ -92,2 +88,2 @@
if err != nil {
return fmt.Errorf("building container nodes: %v", err)
if strings.HasPrefix(policyStr, "CBF") || strings.HasPrefix(policyStr, "SELECT") || strings.HasPrefix(policyStr, "FILTER") {
Owner

Could you mention why it is valid in comments? (any policy starts with REP)

Could you mention why it is valid in comments? (any policy starts with `REP`)
Author
Member

done

done
fyrchik marked this conversation as resolved
ale64bit force-pushed feature/eval-select-filter-expr from 62efde94f2 to 8eddc99868 2023-07-18 12:02:01 +00:00 Compare
fyrchik approved these changes 2023-07-18 13:15:51 +00:00
fyrchik merged commit 4680087711 into master 2023-07-18 13:16:00 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#527
No description provided.