Skip to content

Commit 54db16a

Browse files
moflotaseguguchkin
andauthored
chore: remove unused code (#159)
Co-authored-by: Che <[email protected]>
1 parent fc6291d commit 54db16a

File tree

16 files changed

+22
-188
lines changed

16 files changed

+22
-188
lines changed

cmd/stress-search/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"time"
2121

2222
"google.golang.org/grpc"
23+
"google.golang.org/grpc/credentials/insecure"
2324

2425
"github.com/alecthomas/units"
2526

@@ -59,10 +60,9 @@ func main() {
5960
cancel()
6061
}()
6162

62-
conn, err := grpc.DialContext(
63-
ctx,
63+
conn, err := grpc.NewClient(
6464
*endpoint,
65-
grpc.WithInsecure(),
65+
grpc.WithTransportCredentials(insecure.NewCredentials()),
6666
grpc.WithStatsHandler(&tracing.ClientHandler{}),
6767
)
6868

frac/active_index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (si *activeTokenIndex) GetValByTID(tid uint32) []byte {
182182
}
183183

184184
func (si *activeTokenIndex) GetTIDsByTokenExpr(t parser.Token) ([]uint32, error) {
185-
return si.tokenList.FindPattern(si.ctx, t, nil)
185+
return si.tokenList.FindPattern(si.ctx, t)
186186
}
187187

188188
func (si *activeTokenIndex) GetLIDsFromTIDs(tids []uint32, _ lids.Counter, minLID, maxLID uint32, order seq.DocsOrder) []node.Node {

frac/active_token_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (tl *TokenList) getTokenProvider(field string) *activeTokenProvider {
184184
}
185185
}
186186

187-
func (tl *TokenList) FindPattern(ctx context.Context, t parser.Token, tids []uint32) ([]uint32, error) {
187+
func (tl *TokenList) FindPattern(ctx context.Context, t parser.Token) ([]uint32, error) {
188188
field := parser.GetField(t)
189189
tp := tl.getTokenProvider(field)
190190
tids, err := pattern.Search(ctx, t, tp)

logger/util.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

prepare/prepare.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
_ "net/http/pprof"
98
"os"
109
"path/filepath"
@@ -94,7 +93,7 @@ func main() {
9493
logger.Fatal("can't create dir for batches", zap.Error(err))
9594
}
9695
for i, batch := range batches {
97-
err := ioutil.WriteFile(fmt.Sprintf("%s/%d.json", batchesDir, i), batch.Bytes(), 0o777)
96+
err := os.WriteFile(fmt.Sprintf("%s/%d.json", batchesDir, i), batch.Bytes(), 0o777)
9897
if err != nil {
9998
logger.Fatal("can't write batch",
10099
zap.Int("i", i),

proxyapi/grpc_fetch_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ func TestGrpcV1_FetchLive(t *testing.T) {
218218
}
219219

220220
for _, tt := range tests {
221-
tt := tt
222221
t.Run(tt.name, func(t *testing.T) {
223222
t.Parallel()
224223
r := require.New(t)

proxyapi/grpc_main_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func TestMain(m *testing.M) {
103103
}
104104

105105
func runGRPCServerWithClient(apiServer seqproxyapi.SeqProxyApiServer) (seqproxyapi.SeqProxyApiClient, func()) {
106-
ctx := context.Background()
107106
lis := bufconn.Listen(10 * 1024 * 1024)
108107
server := grpc.NewServer(
109108
grpc.StatsHandler(&tracing.ServerHandler{}),
@@ -121,9 +120,8 @@ func runGRPCServerWithClient(apiServer seqproxyapi.SeqProxyApiServer) (seqproxya
121120
}
122121
server.Stop()
123122
}
124-
conn, err := grpc.DialContext(
125-
ctx,
126-
"",
123+
conn, err := grpc.NewClient(
124+
"localhost",
127125
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
128126
return lis.Dial()
129127
}),

proxyapi/http_bulk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func (r *esBulkDocReader) readDoc() ([]byte, bool, error) {
256256

257257
// If this is a line that exceeds maxDocumentSize, skip it.
258258
for isPrefix {
259-
doc, isPrefix, err = r.r.ReadLine()
259+
_, isPrefix, err = r.r.ReadLine()
260260
if err != nil {
261261
return nil, true, err
262262
}

proxyapi/ingestor.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,38 +47,37 @@ type Ingestor struct {
4747
isStopped atomic.Bool
4848
}
4949

50-
func clientsFromConfig(ctx context.Context, config search.Config) (map[string]storeapi.StoreApiClient, error) {
50+
func clientsFromConfig(config search.Config) (map[string]storeapi.StoreApiClient, error) {
5151
clients := map[string]storeapi.StoreApiClient{}
52-
if err := appendClients(ctx, clients, config.HotStores.Shards); err != nil {
52+
if err := appendClients(clients, config.HotStores.Shards); err != nil {
5353
return nil, err
5454
}
5555
if config.HotReadStores != nil {
56-
if err := appendClients(ctx, clients, config.HotReadStores.Shards); err != nil {
56+
if err := appendClients(clients, config.HotReadStores.Shards); err != nil {
5757
return nil, err
5858
}
5959
}
6060
if config.WriteStores != nil {
61-
if err := appendClients(ctx, clients, config.WriteStores.Shards); err != nil {
61+
if err := appendClients(clients, config.WriteStores.Shards); err != nil {
6262
return nil, err
6363
}
6464
}
6565
if config.ReadStores != nil {
66-
if err := appendClients(ctx, clients, config.ReadStores.Shards); err != nil {
66+
if err := appendClients(clients, config.ReadStores.Shards); err != nil {
6767
return nil, err
6868
}
6969
}
7070
return clients, nil
7171
}
7272

73-
func appendClients(ctx context.Context, clients map[string]storeapi.StoreApiClient, shards [][]string) error {
73+
func appendClients(clients map[string]storeapi.StoreApiClient, shards [][]string) error {
7474
for _, shard := range shards {
7575
for _, replica := range shard {
7676
if _, has := clients[replica]; has {
7777
continue
7878
}
7979
// this doesn't block, and if store is down, it will try to reconnect in background
80-
conn, err := grpc.DialContext(
81-
ctx,
80+
conn, err := grpc.NewClient(
8281
replica,
8382
grpc.WithTransportCredentials(insecure.NewCredentials()),
8483
grpc.WithStatsHandler(&tracing.ClientHandler{}),
@@ -132,7 +131,7 @@ func NewIngestor(config IngestorConfig, store *storeapiclient.Store) (*Ingestor,
132131
config.Bulk.HotStores = stores.NewStoresFromString("memory", 1)
133132
config.Search.HotStores = stores.NewStoresFromString("memory", 1)
134133
} else {
135-
clients, err = clientsFromConfig(ctx, config.Search)
134+
clients, err = clientsFromConfig(config.Search)
136135
if err != nil {
137136
cancel()
138137
return nil, fmt.Errorf("initialize clients: %s", err)

tests/common/byte_string.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
package common
22

3-
func ToBytesSlice(s []string) [][]byte {
4-
if s == nil {
5-
return nil
6-
}
7-
res := make([][]byte, 0, len(s))
8-
for _, v := range s {
9-
res = append(res, []byte(v))
10-
}
11-
return res
12-
}
13-
143
func ToStringSlice(s [][]byte) []string {
154
if s == nil {
165
return nil
@@ -21,25 +10,3 @@ func ToStringSlice(s [][]byte) []string {
2110
}
2211
return res
2312
}
24-
25-
func ToBytesSlice2d(s [][]string) [][][]byte {
26-
if s == nil {
27-
return nil
28-
}
29-
res := make([][][]byte, 0, len(s))
30-
for _, v := range s {
31-
res = append(res, ToBytesSlice(v))
32-
}
33-
return res
34-
}
35-
36-
func ToStringSlice2d(s [][][]byte) [][]string {
37-
if s == nil {
38-
return nil
39-
}
40-
res := make([][]string, 0, len(s))
41-
for _, v := range s {
42-
res = append(res, ToStringSlice(v))
43-
}
44-
return res
45-
}

0 commit comments

Comments
 (0)