[#254] object: Support new values of search match type

Support STRING_NOT_EQUAL and NOT_PRESENT match types
of object search filters.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-01 20:57:18 +03:00 committed by Alex Vanin
parent e9ae408c3a
commit ebff07aaf2
5 changed files with 38 additions and 9 deletions

View file

@ -15,12 +15,18 @@ type SearchMatchType uint32
const ( const (
MatchUnknown SearchMatchType = iota MatchUnknown SearchMatchType = iota
MatchStringEqual MatchStringEqual
MatchStringNotEqual
MatchNotPresent
) )
func (m SearchMatchType) ToV2() v2object.MatchType { func (m SearchMatchType) ToV2() v2object.MatchType {
switch m { switch m {
case MatchStringEqual: case MatchStringEqual:
return v2object.MatchStringEqual return v2object.MatchStringEqual
case MatchStringNotEqual:
return v2object.MatchStringNotEqual
case MatchNotPresent:
return v2object.MatchNotPresent
default: default:
return v2object.MatchUnknown return v2object.MatchUnknown
} }
@ -30,6 +36,10 @@ func SearchMatchFromV2(t v2object.MatchType) (m SearchMatchType) {
switch t { switch t {
case v2object.MatchStringEqual: case v2object.MatchStringEqual:
m = MatchStringEqual m = MatchStringEqual
case v2object.MatchStringNotEqual:
m = MatchStringNotEqual
case v2object.MatchNotPresent:
m = MatchNotPresent
default: default:
m = MatchUnknown m = MatchUnknown
} }

View file

@ -12,8 +12,10 @@ import (
var ( var (
eqV2Matches = map[object.SearchMatchType]v2object.MatchType{ eqV2Matches = map[object.SearchMatchType]v2object.MatchType{
object.MatchUnknown: v2object.MatchUnknown, object.MatchUnknown: v2object.MatchUnknown,
object.MatchStringEqual: v2object.MatchStringEqual, object.MatchStringEqual: v2object.MatchStringEqual,
object.MatchStringNotEqual: v2object.MatchStringNotEqual,
object.MatchNotPresent: v2object.MatchNotPresent,
} }
) )

View file

@ -1952,6 +1952,10 @@ func (x *SearchRequest_Body) GetFilters() []*SearchRequest_Body_Filter {
// * $Object:PHY \ // * $Object:PHY \
// Returns only objects physically stored in the system. This filter is // Returns only objects physically stored in the system. This filter is
// activated if the `key` exists, disregarding the value and matcher type. // activated if the `key` exists, disregarding the value and matcher type.
//
// Note: using filters with a key with prefix `$Object:` and match type
// `NOT_PRESENT `is not recommended since this is not a cross-version approach.
// Behavior when processing this kind of filters is undefined.
type SearchRequest_Body_Filter struct { type SearchRequest_Body_Filter struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache

View file

@ -96,6 +96,10 @@ const (
MatchType_MATCH_TYPE_UNSPECIFIED MatchType = 0 MatchType_MATCH_TYPE_UNSPECIFIED MatchType = 0
// Full string match // Full string match
MatchType_STRING_EQUAL MatchType = 1 MatchType_STRING_EQUAL MatchType = 1
// Full string mismatch
MatchType_STRING_NOT_EQUAL MatchType = 2
// Lack of key
MatchType_NOT_PRESENT MatchType = 3
) )
// Enum value maps for MatchType. // Enum value maps for MatchType.
@ -103,10 +107,14 @@ var (
MatchType_name = map[int32]string{ MatchType_name = map[int32]string{
0: "MATCH_TYPE_UNSPECIFIED", 0: "MATCH_TYPE_UNSPECIFIED",
1: "STRING_EQUAL", 1: "STRING_EQUAL",
2: "STRING_NOT_EQUAL",
3: "NOT_PRESENT",
} }
MatchType_value = map[string]int32{ MatchType_value = map[string]int32{
"MATCH_TYPE_UNSPECIFIED": 0, "MATCH_TYPE_UNSPECIFIED": 0,
"STRING_EQUAL": 1, "STRING_EQUAL": 1,
"STRING_NOT_EQUAL": 2,
"NOT_PRESENT": 3,
} }
) )
@ -839,16 +847,19 @@ var file_v2_object_grpc_types_proto_rawDesc = []byte{
0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07,
0x52, 0x45, 0x47, 0x55, 0x4c, 0x41, 0x52, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x4f, 0x4d, 0x52, 0x45, 0x47, 0x55, 0x4c, 0x41, 0x52, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x4f, 0x4d,
0x42, 0x53, 0x54, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x4f, 0x52, 0x42, 0x53, 0x54, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x4f, 0x52,
0x41, 0x47, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x02, 0x2a, 0x39, 0x0a, 0x09, 0x4d, 0x41, 0x47, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x02, 0x2a, 0x60, 0x0a, 0x09, 0x4d,
0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x4d, 0x41, 0x54, 0x43, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x4d, 0x41, 0x54, 0x43,
0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49,
0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x45, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x45,
0x51, 0x55, 0x41, 0x4c, 0x10, 0x01, 0x42, 0x4f, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x51, 0x55, 0x41, 0x4c, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x45, 0x51, 0x55, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b,
0x65, 0x6f, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x6f, 0x4e, 0x4f, 0x54, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x42, 0x4f, 0x5a,
0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63,
0x74, 0xaa, 0x02, 0x13, 0x4e, 0x65, 0x6f, 0x46, 0x53, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x76, 0x32, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d,
0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x67, 0x72, 0x70,
0x63, 0x3b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0xaa, 0x02, 0x13, 0x4e, 0x65, 0x6f, 0x46, 0x53,
0x2e, 0x41, 0x50, 0x49, 0x2e, 0x76, 0x32, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View file

@ -226,6 +226,8 @@ const (
const ( const (
MatchUnknown MatchType = iota MatchUnknown MatchType = iota
MatchStringEqual MatchStringEqual
MatchStringNotEqual
MatchNotPresent
) )
func (h *ShortHeader) GetVersion() *refs.Version { func (h *ShortHeader) GetVersion() *refs.Version {