Vali-Bucket
1.0.0
dotnet add package Vali-Bucket --version 1.0.0
NuGet\Install-Package Vali-Bucket -Version 1.0.0
<PackageReference Include="Vali-Bucket" Version="1.0.0" />
<PackageVersion Include="Vali-Bucket" Version="1.0.0" />
<PackageReference Include="Vali-Bucket" />
paket add Vali-Bucket --version 1.0.0
#r "nuget: Vali-Bucket, 1.0.0"
#:package Vali-Bucket@1.0.0
#addin nuget:?package=Vali-Bucket&version=1.0.0
#tool nuget:?package=Vali-Bucket&version=1.0.0
Vali-Bucket
Groups timestamps into fixed-size, aligned time buckets for reporting and analytics.
Features
Bucketize— group raw timestamps into fixed-size buckets, counting how many fall in eachAggregate<T>— group (timestamp, value) pairs into buckets, combining values per bucket withSum/Average/Count/Min/MaxGetBucketFor— O(1) lookup of the bucket a single timestamp belongs to, without bucketizing a whole collection — useful in a streaming hot path- Alignment anchor — buckets from separate calls with the same size and anchor are always comparable, because bucket boundaries are computed from the anchor, not from the data
- Reuses
Vali-Range'sDateRangefor each bucket's time span - Compiled targets:
net8.0·net9.0·net10.0— compatible with .NET 6+ via NuGet backward compatibility
Installation
dotnet add package Vali-Bucket
Compatible with .NET 6, 7, 8, and 9. For new projects, .NET 8 (LTS) or .NET 9 is recommended.
Quick Start
using Vali_Bucket.Core;
using Vali_Bucket.Models;
using Vali_Time.Enums;
IValiBucket bucket = new ValiBucket();
var timestamps = new[]
{
new DateTime(2025, 1, 1, 9, 2, 0),
new DateTime(2025, 1, 1, 9, 7, 0),
new DateTime(2025, 1, 1, 9, 16, 0),
};
var buckets = bucket.Bucketize(timestamps, new BucketSize(15, TimeUnit.Minutes));
// Two 15-minute buckets: [09:00-09:14:59.9999999] with Count=2, [09:15-09:29:59.9999999] with Count=1
Aggregating numeric values
var points = new[]
{
(new DateTime(2025, 1, 1, 9, 2, 0), 100m),
(new DateTime(2025, 1, 1, 9, 7, 0), 50m),
(new DateTime(2025, 1, 1, 9, 16, 0), 30m),
};
var totals = bucket.Aggregate(points, new BucketSize(15, TimeUnit.Minutes), BucketAggregation.Sum);
// [09:00 bucket].Value == 150m, [09:15 bucket].Value == 30m
Single lookup
TimeBucket slot = bucket.GetBucketFor(DateTime.UtcNow, new BucketSize(1, TimeUnit.Hours));
API Reference
| Member | Signature |
|---|---|
Bucketize |
IReadOnlyList<TimeBucket> Bucketize(IEnumerable<DateTime> timestamps, BucketSize size, DateTime? anchor = null) |
Aggregate<T> |
IReadOnlyList<TimeBucket<T>> Aggregate<T>(IEnumerable<(DateTime, T)> points, BucketSize size, BucketAggregation aggregation, DateTime? anchor = null) where T : INumber<T> |
GetBucketFor |
TimeBucket GetBucketFor(DateTime timestamp, BucketSize size, DateTime? anchor = null) |
BucketSize(decimal Amount, TimeUnit Unit) only supports fixed-length units —
Milliseconds, Seconds, Minutes, Hours, Days, Weeks. Months/Years have no
constant tick length and throw ArgumentOutOfRangeException.
Buckets with zero matching timestamps/points are omitted from Bucketize/Aggregate results
(no empty-bucket padding).
v1 Scope
- No timezone/DST awareness — bucket boundaries are pure tick arithmetic over whatever
DateTime.Kindthe caller passes in. Convert to a consistent kind/zone before bucketizing if that matters for your data. - No windowed/rolling aggregation (sliding windows, overlapping buckets) — buckets are always disjoint and grid-aligned.
Dependency Injection
// Program.cs
using Vali_Bucket.Extensions;
builder.Services.AddValiBucket();
License
Licensed under the MIT License. Copyright © 2025 Felipe Rafael Montenegro Morriberon. All rights reserved.
Donations
If this package is useful to you, consider supporting its development:
- Latin America — MercadoPago
- International — PayPal
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Vali-Range (>= 1.0.0)
- Vali-Time (>= 1.0.1)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Vali-Range (>= 1.0.0)
- Vali-Time (>= 1.0.1)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Vali-Range (>= 1.0.0)
- Vali-Time (>= 1.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Vali-Bucket:
| Package | Downloads |
|---|---|
|
Vali-Tempo
Vali-Tempo is the all-in-one meta-package for the Vali-Tempo ecosystem. Installing it gives you every module — Vali-Time, Vali-Range, Vali-Calendar, Vali-CountDown, Vali-Age, Vali-Holiday, Vali-TimeZone, Vali-Schedule, Vali-Duration, Vali-BusinessHours, and Vali-Bucket — with a single NuGet reference and a single DI registration call. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 128 | 10/14/2026 |
Vali-Bucket v1.0.0 — initial release: Bucketize, Aggregate<T>, GetBucketFor.