You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "ButterBright (via GitHub)" <gi...@apache.org> on 2025/07/05 13:50:27 UTC
[PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
ButterBright opened a new pull request, #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695
<!--
⚠️ Please make sure to read this template first, pull requests that don't accord with this template
maybe closed without notice.
Texts surrounded by `<` and `>` are meant to be replaced by you, e.g. <framework name>, <issue number>.
Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]`
-->
<!-- ==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👇 ====
### Fix <bug description or the bug issue number or bug issue link>
- [ ] Add a unit test to verify that the fix works.
- [ ] Explain briefly why the bug exists and how to fix it.
==== 🐛 Remove this line WHEN AND ONLY WHEN you're fixing a bug, follow the checklist 👆 ==== -->
<!-- ==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👇 ====
### <Feature description>
- [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
- [ ] Update the documentation to include this new feature.
- [ ] Tests(including UT, IT, E2E) are added to verify the new feature.
- [ ] If it's UI related, attach the screenshots below.
==== 🆕 Remove this line WHEN AND ONLY WHEN you're adding a new feature, follow the checklist 👆 ==== -->
- [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Fixes apache/skywalking#13272.
- [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-banyandb/blob/main/CHANGES.md).
--
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
Re: [PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695#discussion_r2187297334
##########
pkg/encoding/dictionary.go:
##########
@@ -73,24 +73,30 @@ func (d *Dictionary) Encode(dst []byte, tmp []uint32) []byte {
}
// Decode decodes the dictionary.
-func (d *Dictionary) Decode(src []byte, tmp []uint32) error {
+func (d *Dictionary) Decode(dst [][]byte, src []byte, tmp []uint32, itemsCount uint64) ([][]byte, error) {
src, count := BytesToVarUint64(src)
if count == 0 {
- return nil
+ return nil, nil
Review Comment:
[nitpick] When `count == 0`, consider returning the provided `dst` slice instead of `nil` to avoid mixing `nil` and empty slice semantics for callers.
```suggestion
return dst, nil
```
##########
banyand/stream/tag.go:
##########
@@ -220,8 +221,17 @@ func (t *tag) encodeFloat64Tag(bb *bytes.Buffer) {
)
}
-func (t *tag) encodeDefault(bb *bytes.Buffer) {
- bb.Buf = encoding.EncodeBytesBlock(bb.Buf[:0], t.values)
+func (t *tag) encodeDefault(bb *bytes.Buffer, tmp []uint32) {
Review Comment:
[nitpick] The `encodeDefault` implementation is duplicated in both `tag.go` and `column.go`; consider extracting a shared helper for dictionary-based encoding to reduce code duplication.
--
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
Re: [PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily commented on code in PR #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695#discussion_r2199352882
##########
pkg/encoding/dictionary_test.go:
##########
@@ -114,13 +114,12 @@ func BenchmarkDecodeDictionary(b *testing.B) {
dict.Add(value)
}
encoded := make([]byte, 0)
- tmp := make([]uint32, 0)
- encoded = dict.Encode(encoded, tmp)
+ encoded = dict.Encode(encoded)
b.ResetTimer()
for i := 0; i < b.N; i++ {
decoded := NewDictionary()
Review Comment:
Could you move this line outside the loop? Instead, you should reset inside the loop to verify the Decoder pool scenario.
--
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
Re: [PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily commented on code in PR #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695#discussion_r2187927787
##########
pkg/encoding/dictionary.go:
##########
@@ -73,24 +73,30 @@ func (d *Dictionary) Encode(dst []byte, tmp []uint32) []byte {
}
// Decode decodes the dictionary.
-func (d *Dictionary) Decode(src []byte, tmp []uint32) error {
+func (d *Dictionary) Decode(dst [][]byte, src []byte, tmp []uint32, itemsCount uint64) ([][]byte, error) {
Review Comment:
Could you move the `tmp` to a field of the Dictionary?
##########
banyand/measure/column.go:
##########
@@ -205,8 +206,17 @@ func (c *column) encodeFloat64Column(bb *bytes.Buffer) {
)
}
-func (c *column) encodeDefault(bb *bytes.Buffer) {
- bb.Buf = encoding.EncodeBytesBlock(bb.Buf[:0], c.values)
+func (c *column) encodeDefault(bb *bytes.Buffer, tmp []uint32) {
+ dict := encoding.NewDictionary()
Review Comment:
Reuse it by the pool.
##########
banyand/measure/column.go:
##########
@@ -104,15 +104,16 @@ func (c *column) mustWriteTo(cm *columnMetadata, columnWriter *writer) {
bb := bigValuePool.Generate()
defer bigValuePool.Release(bb)
+ tmp := make([]uint32, 0)
Review Comment:
Could you move the `tmp` to a field of `Dictionary`?
--
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
Re: [PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily merged PR #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695
--
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
Re: [PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily commented on PR #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695#issuecomment-3060108753
> > Add a benchmark as https://github.com/apache/skywalking-banyandb/blob/main/banyand/measure/benchmark_encode_test.go did.
>
> The benchmark was added in pkg/encoding/dictionary_test.go.
I see.
--
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
Re: [PR] Support dictionary encoding for low cardinality columns [skywalking-banyandb]
Posted by "ButterBright (via GitHub)" <gi...@apache.org>.
ButterBright commented on PR #695:
URL: https://github.com/apache/skywalking-banyandb/pull/695#issuecomment-3057323960
> Add a benchmark as https://github.com/apache/skywalking-banyandb/blob/main/banyand/measure/benchmark_encode_test.go did.
The benchmark was added in pkg/encoding/dictionary_test.go.
--
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