Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peb iterator #34

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

peb iterator #34

wants to merge 8 commits into from

Conversation

frairon
Copy link
Contributor

@frairon frairon commented May 31, 2024

This PR creates a disk-based ringbuffer updated by a kafka topic

disktail/disktail.go Show resolved Hide resolved
disktail/disktail.go Outdated Show resolved Hide resolved
itemHandler := handler

if skipDuplicates {
keys := make(map[string]struct{})
Copy link
Contributor

Choose a reason for hiding this comment

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

This map could grow really big, but our main use case is iterating over a couple thousand users with a key size of 24, so this should not be a problem.

time.Sleep(100 * time.Millisecond)
}
t.Fatalf("operation timed out")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

would also add a test for the cleaner

disktail/disktail.go Show resolved Hide resolved
disktail/disktail.go Outdated Show resolved Hide resolved
disktail/disktail.go Outdated Show resolved Hide resolved
disktail/disktail.go Show resolved Hide resolved

func (r *DiskTail[T]) Iterate(ctx context.Context, skipDuplicates bool, stats *IterStats, handler func(item *Item[T]) HandleResult) error {
if stats == nil {
stats = &IterStats{}

Choose a reason for hiding this comment

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

Locking on these stats doesn't make much sense? They're not visible to the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what would you suggest? Hide the stats behind an interface so in case it's not needed it won'T do anything? I don't want to have ifs everywhere just to check if the stats were provided..

disktail/disktail.go Outdated Show resolved Hide resolved
disktail/disktail.go Outdated Show resolved Hide resolved
disktail/disktail.go Outdated Show resolved Hide resolved
@frairon frairon force-pushed the peb-iterator branch 6 times, most recently from 785a995 to fcfb727 Compare January 15, 2025 10:45
Copy link
Contributor

Choose a reason for hiding this comment

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

Would not call it example_test.go since its not run via go test. Maybe either move that to an examples folder or create a runnable example and put into cmd/disktail_example/main.go.

if err != nil {
return fmt.Errorf("error creating iterator: %w", err)
}
r.store.NewBatch()
Copy link
Contributor

Choose a reason for hiding this comment

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

we ignore the returned Batch, can be removed probably

@frairon frairon force-pushed the peb-iterator branch 6 times, most recently from cb75a33 to 7992213 Compare January 21, 2025 08:56
@frairon frairon force-pushed the peb-iterator branch 2 times, most recently from 3f28190 to 929e3a2 Compare January 30, 2025 09:55
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.

3 participants