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 2021/08/04 03:05:55 UTC

[GitHub] [skywalking-banyandb] hanahmily commented on a change in pull request #26: Introduce index module with memtable only

hanahmily commented on a change in pull request #26:
URL: https://github.com/apache/skywalking-banyandb/pull/26#discussion_r682251799



##########
File path: banyand/index/search.go
##########
@@ -0,0 +1,359 @@
+// 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 index
+
+import (
+	"encoding/base64"
+	"encoding/json"
+	"strings"
+
+	"github.com/pkg/errors"
+	"github.com/rs/zerolog"
+
+	"github.com/apache/skywalking-banyandb/api/common"
+	apiv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/v1"
+	"github.com/apache/skywalking-banyandb/banyand/index/tsdb"
+	"github.com/apache/skywalking-banyandb/pkg/bytes"
+	"github.com/apache/skywalking-banyandb/pkg/posting"
+	"github.com/apache/skywalking-banyandb/pkg/posting/roaring"
+)
+
+var ErrNotRangeOperation = errors.New("this is not an range operation")
+
+type executable interface {
+	execute() (posting.List, error)
+}
+
+type searchTree interface {
+	executable
+}
+
+func (s *service) Search(series common.Metadata, shardID uint, startTime, endTime uint64, indexObjectName string, conditions []Condition) (posting.List, error) {
+	sd, err := s.getShard(series, shardID)
+	if err != nil {
+		return nil, err
+	}
+	store := sd.store
+	searcher, hasData := store.Window(startTime, endTime)
+	if !hasData {
+		return roaring.EmptyPostingList, nil
+	}
+	tree, errBuild := buildSearchTree(searcher, indexObjectName, conditions)
+	if errBuild != nil {
+		return nil, err
+	}
+	if s.log.Should(zerolog.DebugLevel) {

Review comment:
       will remove it. I have found `Event.Interface` to print `tree` instead of marshaling explicitly, so we don't need the `should` method to reduce the overhead of JSON marshaling.




-- 
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