Skip to content

Conversation

@Fengzdadi
Copy link
Contributor

Summary

  • add VarOptItemsSketch implementation (variance-optimal weighted sampling)
  • add VarOpt serialization/deserialization support
  • add VarOpt unit tests

Changes

  • core sketch implementation and update logic
  • serde preamble/flags encoding and decoding
  • tests covering warmup/estimation, invalid weights, and cumulative weight property

ref: #98 PR2

Copy link
Member

@proost proost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you include c++ compatibility test cases too?

}

// NewVarOptItemsSketchEncoder creates an encoder with the provided writer and serde.
func NewVarOptItemsSketchEncoder[T any](w io.Writer, serde ItemsSerDe[T]) *VarOptItemsSketchEncoder[T] {
Copy link
Member

@proost proost Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you return value not pointer? returning pointer can be allocated in heap. Encoder is used once to encoding. I don't think it has long life cycle. So avoiding allocated in heap is good.

sampling/varopt_items_sketch.go:541:9: &VarOptItemsSketchEncoder[go.shape.string]{...} escapes to heap in NewVarOptItemsSketchEncoder[go.shape.string]:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thank you!

}

// NewVarOptItemsSketchDecoder creates a decoder with the provided reader and serde.
func NewVarOptItemsSketchDecoder[T any](r io.Reader, serde ItemsSerDe[T]) *VarOptItemsSketchDecoder[T] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you return value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants