#include "components/segmentation_platform/internal/execution/processing/uma_feature_processor.h"
#include <inttypes.h>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/timer/elapsed_timer.h"
#include "components/segmentation_platform/internal/database/signal_database.h"
#include "components/segmentation_platform/internal/database/storage_service.h"
#include "components/segmentation_platform/internal/database/ukm_database.h"
#include "components/segmentation_platform/internal/execution/processing/feature_aggregator.h"
#include "components/segmentation_platform/internal/execution/processing/feature_processor_state.h"
#include "components/segmentation_platform/internal/metadata/metadata_utils.h"
#include "components/segmentation_platform/internal/stats.h"
#include "components/segmentation_platform/public/features.h"
#include "components/segmentation_platform/public/proto/aggregation.pb.h"
#include "components/segmentation_platform/public/proto/model_metadata.pb.h"
#include "components/segmentation_platform/public/proto/types.pb.h"
namespace segmentation_platform::processing {
namespace {
proto::UMAFeature* GetAsUMA(Data& data) { … }
UkmDatabase::CustomSqlQuery MakeSqlQuery(
proto::SignalType signal_type,
const std::string& profile_id,
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<std::string>& accepted_enum_ids,
const float default_value) { … }
}
UmaFeatureProcessor::UmaFeatureProcessor(
base::flat_map<FeatureIndex, Data>&& uma_features,
StorageService* storage_service,
const std::string& profile_id,
FeatureAggregator* feature_aggregator,
const base::Time prediction_time,
const base::Time observation_time,
const base::TimeDelta bucket_duration,
const SegmentId segment_id,
bool is_output)
: … { … }
UmaFeatureProcessor::~UmaFeatureProcessor() = default;
void UmaFeatureProcessor::Process(
FeatureProcessorState& feature_processor_state,
QueryProcessorCallback callback) { … }
void UmaFeatureProcessor::ProcessNextFeature() { … }
void UmaFeatureProcessor::OnGetSamplesForUmaFeature(
FeatureIndex index,
const proto::UMAFeature& feature,
const base::Time end_time,
std::vector<SignalDatabase::DbEntry> samples) { … }
void UmaFeatureProcessor::GetStartAndEndTime(size_t bucket_count,
base::Time& start_time,
base::Time& end_time) const { … }
void UmaFeatureProcessor::ProcessOnGotAllSamples(
FeatureProcessorState& feature_processor_state,
const std::vector<SignalDatabase::DbEntry>& samples) { … }
void UmaFeatureProcessor::ProcessUsingSqlDatabase(
FeatureProcessorState& feature_processor_state) { … }
void UmaFeatureProcessor::OnSqlQueriesRun(bool success,
processing::IndexedTensors tensor) { … }
void UmaFeatureProcessor::ProcessSingleUmaFeature(
const std::vector<SignalDatabase::DbEntry>& samples,
FeatureIndex index,
const proto::UMAFeature& feature) { … }
SignalDatabase* UmaFeatureProcessor::GetSignalDatabase() { … }
UkmDatabase* UmaFeatureProcessor::GetUkmDatabase() { … }
}