You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2024/05/19 00:31:01 UTC

(skywalking-banyandb) branch patch-metadata created (now 7857b4a7)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a change to branch patch-metadata
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


      at 7857b4a7 Add more test

This branch includes the following new commits:

     new 7857b4a7 Add more test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(skywalking-banyandb) 01/01: Add more test

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch patch-metadata
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit 7857b4a7be90327f16283b3cd6897453eca1d742
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Sun May 19 00:30:45 2024 +0000

    Add more test
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 banyand/measure/metadata.go                        |   4 +-
 banyand/measure/service.go                         |   4 +-
 pkg/query/logical/index_filter.go                  |   3 +
 .../stream/data/input/filter_no_indexed_or.yaml    |  53 ++++++++++
 .../stream/data/want/filter_no_indexed_or.yaml     | 115 +++++++++++++++++++++
 test/cases/stream/stream.go                        |   1 +
 6 files changed, 176 insertions(+), 4 deletions(-)

diff --git a/banyand/measure/metadata.go b/banyand/measure/metadata.go
index c940844a..04de7686 100644
--- a/banyand/measure/metadata.go
+++ b/banyand/measure/metadata.go
@@ -49,8 +49,8 @@ type schemaRepo struct {
 	metadata metadata.Repo
 }
 
-func newSchemaRepo(path string, svc *service) schemaRepo {
-	sr := schemaRepo{
+func newSchemaRepo(path string, svc *service) *schemaRepo {
+	sr := &schemaRepo{
 		l:        svc.l,
 		metadata: svc.metadata,
 		Repository: resourceSchema.NewRepository(
diff --git a/banyand/measure/service.go b/banyand/measure/service.go
index f04bd197..7b7ab71c 100644
--- a/banyand/measure/service.go
+++ b/banyand/measure/service.go
@@ -53,7 +53,7 @@ type Service interface {
 var _ Service = (*service)(nil)
 
 type service struct {
-	schemaRepo    schemaRepo
+	schemaRepo    *schemaRepo
 	writeListener bus.MessageListener
 	metadata      metadata.Repo
 	pipeline      queue.Server
@@ -107,7 +107,7 @@ func (s *service) PreRun(_ context.Context) error {
 	s.schemaRepo = newSchemaRepo(path, s)
 	// run a serial watcher
 
-	s.writeListener = setUpWriteCallback(s.l, &s.schemaRepo)
+	s.writeListener = setUpWriteCallback(s.l, s.schemaRepo)
 	err := s.pipeline.Subscribe(data.TopicMeasureWrite, s.writeListener)
 	if err != nil {
 		return err
diff --git a/pkg/query/logical/index_filter.go b/pkg/query/logical/index_filter.go
index f9d0608c..ceafa695 100644
--- a/pkg/query/logical/index_filter.go
+++ b/pkg/query/logical/index_filter.go
@@ -102,6 +102,9 @@ func BuildLocalFilter(criteria *modelv1.Criteria, schema Schema, entityDict map[
 			and.append(left).append(right)
 			return and, entities, nil
 		case modelv1.LogicalExpression_LOGICAL_OP_OR:
+			if left == ENode || right == ENode {
+				return ENode, entities, nil
+			}
 			or := newOr(2)
 			or.append(left).append(right)
 			return or, entities, nil
diff --git a/test/cases/stream/data/input/filter_no_indexed_or.yaml b/test/cases/stream/data/input/filter_no_indexed_or.yaml
new file mode 100644
index 00000000..3a638f58
--- /dev/null
+++ b/test/cases/stream/data/input/filter_no_indexed_or.yaml
@@ -0,0 +1,53 @@
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you under
+# the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: "sw"
+groups: ["default"]
+projection:
+  tagFamilies:
+  - name: "searchable"
+    tags: ["state", "trace_id", "span_id", "start_time"]
+criteria:
+  le:
+    op: "LOGICAL_OP_OR"
+    left:
+      condition:
+        name: "span_id"
+        op: "BINARY_OP_EQ"
+        value:
+          str:
+            value: "1"
+    right:
+      le:
+        op: "LOGICAL_OP_AND"
+        left:
+          condition:
+            name: "start_time"
+            op: "BINARY_OP_EQ"
+            value:
+              int:
+                value: 1622933202000000000
+        right:
+          le:
+            op: "LOGICAL_OP_AND"
+            left:
+              condition:
+                name: "state"
+                op: "BINARY_OP_EQ"
+                value:
+                  int:
+                    value: "0"
diff --git a/test/cases/stream/data/want/filter_no_indexed_or.yaml b/test/cases/stream/data/want/filter_no_indexed_or.yaml
new file mode 100644
index 00000000..e560f7de
--- /dev/null
+++ b/test/cases/stream/data/want/filter_no_indexed_or.yaml
@@ -0,0 +1,115 @@
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you under
+# the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+elements:
+  - elementId: "0"
+    tagFamilies:
+    - name: searchable
+      tags:
+      - key: state
+        value:
+          int:
+            value: "1"
+      - key: trace_id
+        value:
+          str:
+            value: "1"
+      - key: span_id
+        value:
+          str:
+            value: "1"
+      - key: start_time
+        value:
+          int:
+            value: "1622933202000000000"
+  - elementId: "1"
+    tagFamilies:
+    - name: searchable
+      tags:
+      - key: state
+        value:
+          int:
+            value: "1"
+      - key: trace_id
+        value:
+          str:
+            value: "2"
+      - key: span_id
+        value:
+          str:
+            value: "1"
+      - key: start_time
+        value:
+          int:
+            value: "1622933202000000000"
+  - elementId: "2"
+    tagFamilies:
+    - name: searchable
+      tags:
+      - key: state
+        value:
+          int: {}
+      - key: trace_id
+        value:
+          str:
+            value: "3"
+      - key: span_id
+        value:
+          str:
+            value: "2"
+      - key: start_time
+        value:
+          int:
+            value: "1622933202000000000"
+  - elementId: "3"
+    tagFamilies:
+    - name: searchable
+      tags:
+      - key: state
+        value:
+          int: {}
+      - key: trace_id
+        value:
+          str:
+            value: "4"
+      - key: span_id
+        value:
+          str:
+            value: "2"
+      - key: start_time
+        value:
+          int:
+            value: "1622933202000000000"
+  - elementId: "4"
+    tagFamilies:
+    - name: searchable
+      tags:
+      - key: state
+        value:
+          int: {}
+      - key: trace_id
+        value:
+          str:
+            value: "5"
+      - key: span_id
+        value:
+          str:
+            value: "3"
+      - key: start_time
+        value:
+          int:
+            value: "1622933202000000000"
\ No newline at end of file
diff --git a/test/cases/stream/stream.go b/test/cases/stream/stream.go
index b9b5e518..66408bdd 100644
--- a/test/cases/stream/stream.go
+++ b/test/cases/stream/stream.go
@@ -75,4 +75,5 @@ var _ = g.DescribeTable("Scanning Streams", func(args helpers.Args) {
 	g.Entry("having non indexed array", helpers.Args{Input: "having_non_indexed_arr", Duration: 1 * time.Hour}),
 	g.Entry("full text searching", helpers.Args{Input: "search", Duration: 1 * time.Hour}),
 	g.Entry("indexed only tags", helpers.Args{Input: "indexed_only", Duration: 1 * time.Hour}),
+	g.Entry("filter by non-indexed tag with or", helpers.Args{Input: "filter_no_indexed_or", Duration: 1 * time.Hour}),
 )