#include "components/segmentation_platform/internal/execution/processing/feature_aggregator_impl.h"
#include <cstdint>
#include <optional>
#include <vector>
#include "base/notreached.h"
#include "base/numerics/clamped_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/time/time.h"
#include "components/segmentation_platform/internal/database/signal_database.h"
#include "components/segmentation_platform/internal/database/signal_sample_view.h"
#include "components/segmentation_platform/public/proto/aggregation.pb.h"
#include "components/segmentation_platform/public/proto/types.pb.h"
namespace segmentation_platform::processing {
namespace {
Sample;
std::vector<SignalSampleView::Entries> Bucketize(
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
int64_t SumValues(proto::SignalType signal_type,
const SignalSampleView& samples) { … }
std::vector<float> CountAggregation(const SignalSampleView& samples) { … }
std::vector<float> CountBooleanAggregation(const SignalSampleView& samples) { … }
std::vector<float> BucketedCountAggregation(
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> BucketedCountBooleanAggregation(
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> BucketedCountBooleanTrueCountAggregation(
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> BucketedCumulativeCountAggregation(
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> SumAggregation(proto::SignalType signal_type,
const SignalSampleView& samples) { … }
std::vector<float> SumBooleanAggregation(proto::SignalType signal_type,
const SignalSampleView& samples) { … }
std::vector<float> BucketedSumAggregation(
proto::SignalType signal_type,
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> BucketedSumBooleanAggregation(
proto::SignalType signal_type,
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> BucketedSumBooleanTrueCountAggregation(
proto::SignalType signal_type,
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
std::vector<float> BucketedCumulativeSumAggregation(
proto::SignalType signal_type,
uint64_t bucket_count,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const SignalSampleView& samples) { … }
}
FeatureAggregatorImpl::FeatureAggregatorImpl() = default;
FeatureAggregatorImpl::~FeatureAggregatorImpl() = default;
std::optional<std::vector<float>> FeatureAggregatorImpl::Process(
proto::SignalType signal_type,
uint64_t name_hash,
proto::Aggregation aggregation,
uint64_t bucket_count,
const base::Time& start_time,
const base::Time& end_time,
const base::TimeDelta& bucket_duration,
const std::vector<int32_t>& accepted_enum_ids,
const std::vector<SignalDatabase::DbEntry>& all_samples) const { … }
}