You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/10/14 10:26:47 UTC

[GitHub] [skywalking] hanahmily commented on issue #9759: [BanyanDB] Support "IN" and "NOT IN" binary operation in criteria

hanahmily commented on issue #9759:
URL: https://github.com/apache/skywalking/issues/9759#issuecomment-1278813379

   @DevPJ9 You could split this task into several parts:
   
   ## Add operations to API specification
   
   Add `IN` and `NOT_IN` at https://github.com/apache/skywalking-banyandb/blob/main/api/proto/banyandb/model/v1/query.proto#L54
   
   ## Parse added operations in index_filter
   
   If the tag referred to by the binary expression is indexed, the index_filter will handle it.
   
   Parse them at https://github.com/apache/skywalking-banyandb/blob/main/pkg/query/logical/index_filter.go#L102. You might notice that `HAVING` uses `and` nodes to construct the filter. Correspondingly, `IN` could leverage `or` node like 
   
   ```go
   case model_v1.Condition_BINARY_OP_OR:
   		bb := expr.Bytes()
   		and := newOr(len(bb))
   		for _, b := range bb {
   			and.append(newEq(indexRule, newBytesLiteral(b)))
   		}
   		return and, []tsdb.Entity{entity}, nil
   ```
   
   ## Parse operations in tag_filter
   
   We also need to parse them at https://github.com/apache/skywalking-banyandb/blob/main/pkg/query/logical/tag_filter.go#L86. You should create a new `orTag` struct with `Match` like 
   
   ```
   func (h *orTag) Match(tagFamilies []*model_v1.TagFamily) (bool, error) {
   	expr, err := tagExpr(tagFamilies, h.Name)
   	if err != nil {
   		return false, err
   	}
   	return expr.BelongTo(h.Expr), nil
   }
   
   ## Add test cases
   
   Add integration test cases to https://github.com/apache/skywalking-banyandb/blob/main/test/cases/measure/measure.go and https://github.com/apache/skywalking-banyandb/blob/main/test/cases/stream/stream.go to verify the behaviors.
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org