lujiajing1126 commented on a change in pull request #45:
URL: https://github.com/apache/skywalking-banyandb/pull/45#discussion_r704173979



##########
File path: banyand/kv/kv.go
##########
@@ -206,9 +229,8 @@ func OpenIndexStore(shardID int, path string, options 
...IndexOptions) (IndexSto
        for _, opt := range options {
                opt(bdb)
        }
-       bdb.dbOpts = bdb.dbOpts.WithMaxLevels(1)
-       // Put all values into LSM
-       bdb.dbOpts = bdb.dbOpts.WithVLogPercentile(1.0)
+       bdb.dbOpts = bdb.dbOpts.WithMaxLevels(2)

Review comment:
       why we have to modify the default level?

##########
File path: banyand/stream/stream_query_test.go
##########
@@ -0,0 +1,532 @@
+// 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.
+
+package stream
+
+import (
+       "bytes"
+       "embed"
+       _ "embed"
+       "encoding/base64"
+       "encoding/json"
+       "fmt"
+       "io"
+       "sort"
+       "strconv"
+       "testing"
+       "time"
+
+       "github.com/golang/protobuf/jsonpb"
+       "github.com/pkg/errors"
+       "github.com/stretchr/testify/assert"
+       "google.golang.org/protobuf/types/known/timestamppb"
+
+       "github.com/apache/skywalking-banyandb/api/common"
+       commonv2 
"github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v2"
+       databasev2 
"github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v2"
+       modelv2 
"github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v2"
+       streamv2 
"github.com/apache/skywalking-banyandb/api/proto/banyandb/stream/v2"
+       "github.com/apache/skywalking-banyandb/banyand/tsdb"
+       "github.com/apache/skywalking-banyandb/pkg/convert"
+       "github.com/apache/skywalking-banyandb/pkg/index"
+       "github.com/apache/skywalking-banyandb/pkg/partition"
+)
+
+type shardStruct struct {
+       id       common.ShardID
+       location []string
+       elements []string
+}
+
+type shardsForTest []shardStruct
+
+func Test_Stream_SelectShard(t *testing.T) {
+       tester := assert.New(t)
+       s, deferFunc := setup(tester)
+       defer deferFunc()
+       _ = setupQueryData(tester, "multiple_shards.json", s)
+       tests := []struct {
+               name         string
+               entity       tsdb.Entity
+               wantShardNum int
+               wantErr      bool
+       }{
+               {
+                       name:         "all shards",
+                       wantShardNum: 2,
+               },
+               {
+                       name:         "select a shard",
+                       entity:       tsdb.Entity{tsdb.Entry("webapp_id"), 
tsdb.Entry("10.0.0.1_id"), convert.Int64ToBytes(0)},
+                       wantShardNum: 1,
+               },
+               {
+                       name:         "select shards",
+                       entity:       tsdb.Entity{tsdb.Entry("webapp_id"), 
tsdb.AnyEntry, convert.Int64ToBytes(0)},
+                       wantShardNum: 2,
+               },
+       }
+
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       shards, err := s.Shards(tt.entity)
+                       if tt.wantErr {
+                               tester.Error(err)
+                               return
+                       }
+                       tester.NoError(err)
+                       tester.Equal(tt.wantShardNum, len(shards))
+               })
+       }
+
+}
+
+func Test_Stream_Series(t *testing.T) {
+       tester := assert.New(t)
+       s, deferFunc := setup(tester)
+       defer deferFunc()
+       baseTime := setupQueryData(tester, "multiple_shards.json", s)
+       tests := []struct {
+               name    string
+               args    queryOpts
+               want    shardsForTest
+               wantErr bool
+       }{
+               {
+                       name: "all",
+                       args: queryOpts{
+                               entity:    tsdb.Entity{tsdb.AnyEntry, 
tsdb.AnyEntry, tsdb.AnyEntry},
+                               timeRange: tsdb.NewTimeRangeDuration(baseTime, 
1*time.Hour),
+                       },
+                       want: shardsForTest{
+                               {
+                                       id:       0,
+                                       location: 
[]string{"series_12243341348514563931", "data_flow_0"},
+                                       elements: []string{"1"},
+                               },
+                               {
+                                       id:       0,
+                                       location: 
[]string{"series_1671844747554927007", "data_flow_0"},
+                                       elements: []string{"2"},
+                               },
+                               {
+                                       id:       1,
+                                       location: 
[]string{"series_2374367181827824198", "data_flow_0"},
+                                       elements: []string{"5", "3"},
+                               },
+                               {
+                                       id:       1,
+                                       location: 
[]string{"series_8429137420168685297", "data_flow_0"},
+                                       elements: []string{"4"},
+                               },
+                       },
+               },
+
+               {
+                       name: "time range",
+                       args: queryOpts{
+                               entity:    tsdb.Entity{tsdb.AnyEntry, 
tsdb.AnyEntry, tsdb.AnyEntry},
+                               timeRange: 
tsdb.NewTimeRangeDuration(baseTime.Add(1500*time.Millisecond), 1*time.Hour),
+                       },
+                       want: shardsForTest{
+                               {
+                                       id:       0,
+                                       location: 
[]string{"series_12243341348514563931", "data_flow_0"},
+                               },
+                               {
+                                       id:       0,
+                                       location: 
[]string{"series_1671844747554927007", "data_flow_0"},
+                               },
+                               {
+                                       id:       1,
+                                       location: 
[]string{"series_2374367181827824198", "data_flow_0"},
+                                       elements: []string{"5"},
+                               },
+                               {
+                                       id:       1,
+                                       location: 
[]string{"series_8429137420168685297", "data_flow_0"},
+                                       elements: []string{"4"},
+                               },
+                       },
+               },
+               {
+                       name: "find series by service_id and instance_id",
+                       args: queryOpts{
+                               entity:    tsdb.Entity{tsdb.Entry("webapp_id"), 
tsdb.Entry("10.0.0.1_id"), tsdb.AnyEntry},
+                               timeRange: tsdb.NewTimeRangeDuration(baseTime, 
1*time.Hour),
+                       },
+                       want: shardsForTest{
+                               {
+                                       id:       0,
+                                       location: 
[]string{"series_12243341348514563931", "data_flow_0"},
+                                       elements: []string{"1"},
+                               },
+                               {
+                                       id:       1,
+                                       location: 
[]string{"series_2374367181827824198", "data_flow_0"},
+                                       elements: []string{"5", "3"},
+                               },
+                       },
+               },
+               {
+                       name: "find a series",
+                       args: queryOpts{
+                               entity:    tsdb.Entity{tsdb.Entry("webapp_id"), 
tsdb.Entry("10.0.0.1_id"), convert.Uint64ToBytes(1)},
+                               timeRange: tsdb.NewTimeRangeDuration(baseTime, 
1*time.Hour),
+                       },
+                       want: shardsForTest{
+                               {
+                                       id:       1,
+                                       location: 
[]string{"series_2374367181827824198", "data_flow_0"},
+                                       elements: []string{"5", "3"},
+                               },
+                       },
+               },
+               {
+                       name: "filter",
+                       args: queryOpts{
+                               entity:    tsdb.Entity{tsdb.AnyEntry, 
tsdb.AnyEntry, tsdb.AnyEntry},
+                               timeRange: tsdb.NewTimeRangeDuration(baseTime, 
1*time.Hour),
+                               buildFn: func(builder tsdb.SeekerBuilder) {

Review comment:
       So the searchable tags (local indexes) can be directly processed by the 
storage layer now?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to