From a62b0ab12b3afe1251cf8970c25c57132f50d54f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 29 Apr 2024 07:44:23 +0200 Subject: [PATCH] wip --- lib/logstorage/filter.go | 24 ------------------------ lib/logstorage/stringbucket.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 lib/logstorage/stringbucket.go diff --git a/lib/logstorage/filter.go b/lib/logstorage/filter.go index b8f0ba4c6..950223b75 100644 --- a/lib/logstorage/filter.go +++ b/lib/logstorage/filter.go @@ -67,30 +67,6 @@ func (fs *streamFilter) apply(bs *blockSearch, bm *bitmap) { } } -type stringBucket struct { - a []string -} - -func (sb *stringBucket) reset() { - clear(sb.a) - sb.a = sb.a[:0] -} - -func getStringBucket() *stringBucket { - v := stringBucketPool.Get() - if v == nil { - return &stringBucket{} - } - return v.(*stringBucket) -} - -func putStringBucket(sb *stringBucket) { - sb.reset() - stringBucketPool.Put(sb) -} - -var stringBucketPool sync.Pool - func getTokensSkipLast(s string) []string { for { r, runeSize := utf8.DecodeLastRuneInString(s) diff --git a/lib/logstorage/stringbucket.go b/lib/logstorage/stringbucket.go new file mode 100644 index 000000000..fd1fc60f1 --- /dev/null +++ b/lib/logstorage/stringbucket.go @@ -0,0 +1,29 @@ +package logstorage + +import ( + "sync" +) + +type stringBucket struct { + a []string +} + +func (sb *stringBucket) reset() { + clear(sb.a) + sb.a = sb.a[:0] +} + +func getStringBucket() *stringBucket { + v := stringBucketPool.Get() + if v == nil { + return &stringBucket{} + } + return v.(*stringBucket) +} + +func putStringBucket(sb *stringBucket) { + sb.reset() + stringBucketPool.Put(sb) +} + +var stringBucketPool sync.Pool