Skip to content
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

object: Support numerical search queries #285

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

### Added
- Numeric operands for object search queries (#265)

### Changed

Expand Down
3 changes: 3 additions & 0 deletions object/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ message SearchRequest {
// objects. Most human users expect to get only object they can directly
// work with. In that case, `$Object:ROOT` filter should be used.
//
// If `match_type` field is numerical, both `value` field and object
// attribute MUST be base-10 integers.
//
// By default `key` field refers to the corresponding object's `Attribute`.
// Some Object's header fields can also be accessed by adding `$Object:`
// prefix to the name. Here is the list of fields available via this prefix:
Expand Down
12 changes: 12 additions & 0 deletions object/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ enum MatchType {

// String prefix match
COMMON_PREFIX = 4;

// Numerical 'greater than'
NUM_GT = 5;

// Numerical 'greater or equal than'
NUM_GE = 6;

// Numerical 'less than'
NUM_LT = 7;

// Numerical 'less or equal than'
NUM_LE = 8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUM_EQUAL?

the previously added STRING_EQUAL / STRING_NOT_EQUAL matchers are suitable for numerical == / !=.

While it is true for now, it looks strange to me. Users should use STRING_EQUAL for numbers in their interfaces. Also, it is possible not to have strings-only values in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new values will be added when the existing ones are no longer sufficient

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this question as well, but as we're not supporting different notations ("1e8", for example) now, current set is sufficient for the purpose.

Copy link
Member

@carpawell carpawell Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my main point, i would say, in the naming of this message: MatchType (it is not bound to Filter), no info about what it relates to. i can imagine reusing this for a number representation of smth, then we will have to add NUM_EQUAL but we will already have had some users that will be using STRING_EQUAL, strange

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this enum is not intended to be reused. Imaginary importer will have to use it as it is, or will define it's own enum. Anyway, these are just numbers. Protocol inflation for the indefinite future is bad thing to do imo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this enum is not intended to be reused

but there are no words about what it is used for

}

// Short header fields
Expand Down
7 changes: 7 additions & 0 deletions proto-docs/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ container, including Regular object, Tombstones and Storage Group
objects. Most human users expect to get only object they can directly
work with. In that case, `$Object:ROOT` filter should be used.

If `match_type` field is numerical, both `value` field and object
attribute MUST be base-10 integers.

By default `key` field refers to the corresponding object's `Attribute`.
Some Object's header fields can also be accessed by adding `$Object:`
prefix to the name. Here is the list of fields available via this prefix:
Expand Down Expand Up @@ -1021,6 +1024,10 @@ Type of match expression
| STRING_NOT_EQUAL | 2 | Full string mismatch |
| NOT_PRESENT | 3 | Lack of key |
| COMMON_PREFIX | 4 | String prefix match |
| NUM_GT | 5 | Numerical 'greater than' |
| NUM_GE | 6 | Numerical 'greater or equal than' |
| NUM_LT | 7 | Numerical 'less than' |
| NUM_LE | 8 | Numerical 'less or equal than' |



Expand Down
Loading