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 2025/12/27 10:18:58 UTC

(skywalking-banyandb) branch main updated: Remove redundant filterTagProjection and filterFieldProjection operations (#917)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new ff23851d Remove redundant filterTagProjection and filterFieldProjection operations (#917)
ff23851d is described below

commit ff23851da193345b803492a9d5ed1575cd0e2c40
Author: Huang Youliang <bu...@gmail.com>
AuthorDate: Sat Dec 27 18:18:52 2025 +0800

    Remove redundant filterTagProjection and filterFieldProjection operations (#917)
---
 banyand/measure/query.go | 66 ------------------------------------------------
 banyand/stream/query.go  | 45 ---------------------------------
 banyand/trace/query.go   | 36 --------------------------
 3 files changed, 147 deletions(-)

diff --git a/banyand/measure/query.go b/banyand/measure/query.go
index ef3ef64d..426c5963 100644
--- a/banyand/measure/query.go
+++ b/banyand/measure/query.go
@@ -75,8 +75,6 @@ func (m *measure) Query(ctx context.Context, mqo model.MeasureQueryOptions) (mqr
 	if mqo.TimeRange == nil {
 		return nil, errors.New("invalid query options: timeRange are required")
 	}
-	mqo.TagProjection = m.filterTagProjection(mqo.TagProjection)
-	mqo.FieldProjection = m.filterFieldProjection(mqo.FieldProjection)
 	if len(mqo.TagProjection) == 0 && len(mqo.FieldProjection) == 0 {
 		return nil, errors.New("invalid query options: tagProjection or fieldProjection is required")
 	}
@@ -195,70 +193,6 @@ func (m *measure) Query(ctx context.Context, mqo model.MeasureQueryOptions) (mqr
 	return &result, nil
 }
 
-func (m *measure) filterTagProjection(tagProjection []model.TagProjection) []model.TagProjection {
-	is := m.indexSchema.Load()
-	if is == nil {
-		return tagProjection
-	}
-	tagMap := is.(indexSchema).indexTagMap
-	if len(tagMap) == 0 {
-		return tagProjection
-	}
-
-	schemaTagFamilies := make(map[string]map[string]struct{})
-	for _, tf := range m.schema.GetTagFamilies() {
-		tagNames := make(map[string]struct{})
-		for _, tag := range tf.GetTags() {
-			tagNames[tag.GetName()] = struct{}{}
-		}
-		schemaTagFamilies[tf.GetName()] = tagNames
-	}
-
-	result := make([]model.TagProjection, 0, len(tagProjection))
-	for _, tp := range tagProjection {
-		schemaTags, familyExists := schemaTagFamilies[tp.Family]
-		if !familyExists {
-			continue
-		}
-
-		filteredNames := make([]string, 0, len(tp.Names))
-		for _, name := range tp.Names {
-			if _, tagExists := schemaTags[name]; tagExists {
-				filteredNames = append(filteredNames, name)
-			}
-		}
-
-		if len(filteredNames) > 0 {
-			result = append(result, model.TagProjection{
-				Family: tp.Family,
-				Names:  filteredNames,
-			})
-		}
-	}
-
-	return result
-}
-
-func (m *measure) filterFieldProjection(fieldProjection []string) []string {
-	if len(fieldProjection) == 0 {
-		return fieldProjection
-	}
-
-	schemaFields := make(map[string]struct{})
-	for _, field := range m.schema.GetFields() {
-		schemaFields[field.GetName()] = struct{}{}
-	}
-
-	result := make([]string, 0, len(fieldProjection))
-	for _, name := range fieldProjection {
-		if _, exists := schemaFields[name]; exists {
-			result = append(result, name)
-		}
-	}
-
-	return result
-}
-
 type tagNameWithType struct {
 	fieldName string
 	typ       pbv1.ValueType
diff --git a/banyand/stream/query.go b/banyand/stream/query.go
index 5359fc7f..b42e2c2b 100644
--- a/banyand/stream/query.go
+++ b/banyand/stream/query.go
@@ -43,7 +43,6 @@ import (
 const checkDoneEvery = 128
 
 func (s *stream) Query(ctx context.Context, sqo model.StreamQueryOptions) (sqr model.StreamQueryResult, err error) {
-	sqo.TagProjection = s.filterTagProjection(sqo.TagProjection)
 	if err = validateQueryInput(sqo); err != nil {
 		return nil, err
 	}
@@ -99,50 +98,6 @@ func validateQueryInput(sqo model.StreamQueryOptions) error {
 	return nil
 }
 
-func (s *stream) filterTagProjection(tagProjection []model.TagProjection) []model.TagProjection {
-	is := s.indexSchema.Load()
-	if is == nil {
-		return tagProjection
-	}
-	tagMap := is.(indexSchema).tagMap
-	if len(tagMap) == 0 {
-		return tagProjection
-	}
-
-	schemaTagFamilies := make(map[string]map[string]struct{})
-	for _, tf := range s.schema.GetTagFamilies() {
-		tagNames := make(map[string]struct{})
-		for _, tag := range tf.GetTags() {
-			tagNames[tag.GetName()] = struct{}{}
-		}
-		schemaTagFamilies[tf.GetName()] = tagNames
-	}
-
-	result := make([]model.TagProjection, 0, len(tagProjection))
-	for _, tp := range tagProjection {
-		schemaTags, familyExists := schemaTagFamilies[tp.Family]
-		if !familyExists {
-			continue
-		}
-
-		filteredNames := make([]string, 0, len(tp.Names))
-		for _, name := range tp.Names {
-			if _, tagExists := schemaTags[name]; tagExists {
-				filteredNames = append(filteredNames, name)
-			}
-		}
-
-		if len(filteredNames) > 0 {
-			result = append(result, model.TagProjection{
-				Family: tp.Family,
-				Names:  filteredNames,
-			})
-		}
-	}
-
-	return result
-}
-
 func (s *stream) getTSDB() (storage.TSDB[*tsTable, option], error) {
 	var tsdb storage.TSDB[*tsTable, option]
 	db := s.tsdb.Load()
diff --git a/banyand/trace/query.go b/banyand/trace/query.go
index c9237350..a675f1f0 100644
--- a/banyand/trace/query.go
+++ b/banyand/trace/query.go
@@ -52,7 +52,6 @@ type queryOptions struct {
 }
 
 func (t *trace) Query(ctx context.Context, tqo model.TraceQueryOptions) (model.TraceQueryResult, error) {
-	tqo.TagProjection = t.filterTagProjection(tqo.TagProjection)
 	if err := validateTraceQueryOptions(tqo); err != nil {
 		return nil, err
 	}
@@ -147,41 +146,6 @@ func validateTraceQueryOptions(tqo model.TraceQueryOptions) error {
 	return nil
 }
 
-func (t *trace) filterTagProjection(tagProjection *model.TagProjection) *model.TagProjection {
-	if tagProjection == nil || len(tagProjection.Names) == 0 {
-		return tagProjection
-	}
-
-	is := t.indexSchema.Load()
-	if is == nil {
-		return tagProjection
-	}
-	tagMap := is.(indexSchema).tagMap
-	if len(tagMap) == 0 {
-		return tagProjection
-	}
-
-	filteredNames := make([]string, 0, len(tagProjection.Names))
-	for _, name := range tagProjection.Names {
-		if _, exists := tagMap[name]; exists {
-			filteredNames = append(filteredNames, name)
-		}
-	}
-
-	if len(filteredNames) == len(tagProjection.Names) {
-		return tagProjection
-	}
-
-	if len(filteredNames) == 0 {
-		return nil
-	}
-
-	return &model.TagProjection{
-		Family: tagProjection.Family,
-		Names:  filteredNames,
-	}
-}
-
 func (t *trace) GetTagValueDecoder() model.TagValueDecoder {
 	return mustDecodeTagValueAndArray
 }