#ifndef COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_METADATA_METADATA_UTILS_H_
#define COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_METADATA_METADATA_UTILS_H_
#include "base/time/time.h"
#include "components/segmentation_platform/internal/database/signal_key.h"
#include "components/segmentation_platform/internal/execution/processing/query_processor.h"
#include "components/segmentation_platform/internal/proto/client_results.pb.h"
#include "components/segmentation_platform/internal/proto/model_prediction.pb.h"
#include "components/segmentation_platform/public/config.h"
#include "components/segmentation_platform/public/proto/model_metadata.pb.h"
#include "components/segmentation_platform/public/proto/output_config.pb.h"
#include "components/segmentation_platform/public/proto/segmentation_platform.pb.h"
#include "components/segmentation_platform/public/proto/types.pb.h"
namespace segmentation_platform {
SegmentId;
namespace metadata_utils {
enum class ValidationResult { … };
ValidationResult ValidateSegmentInfo(const proto::SegmentInfo& segment_info);
ValidationResult ValidateMetadata(
const proto::SegmentationModelMetadata& model_metadata);
ValidationResult ValidateMetadataUmaFeature(const proto::UMAFeature& feature);
ValidationResult ValidateMetadataSqlFeature(const proto::SqlFeature& feature);
ValidationResult ValidateMetadataCustomInput(
const proto::CustomInput& custom_input);
ValidationResult ValidateMetadataAndFeatures(
const proto::SegmentationModelMetadata& model_metadata);
ValidationResult ValidateIndexedTensors(
const processing::IndexedTensors& tensor,
size_t expected_size);
ValidationResult ValidateSegmentInfoMetadataAndFeatures(
const proto::SegmentInfo& segment_info);
ValidationResult ValidateOutputConfig(const proto::OutputConfig& output_config);
ValidationResult ValidateMultiClassClassifier(
const proto::Predictor_MultiClassClassifier& multi_class_classifier);
void SetFeatureNameHashesFromName(
proto::SegmentationModelMetadata* model_metadata);
bool HasExpiredOrUnavailableResult(const proto::SegmentInfo& segment_info,
const base::Time& now);
bool HasFreshResults(const proto::SegmentInfo& segment_info,
const base::Time& now);
base::TimeDelta GetTimeUnit(
const proto::SegmentationModelMetadata& model_metadata);
base::TimeDelta ConvertToTimeDelta(proto::TimeUnit time_unit);
SignalKey::Kind SignalTypeToSignalKind(proto::SignalType signal_type);
proto::SignalType SignalKindToSignalType(SignalKey::Kind kind);
float ConvertToDiscreteScore(const std::string& mapping_key,
float input_score,
const proto::SegmentationModelMetadata& metadata);
std::string SegmetationModelMetadataToString(
const proto::SegmentationModelMetadata& model_metadata);
VisitUmaFeature;
void VisitAllUmaFeatures(const proto::SegmentationModelMetadata& model_metadata,
bool include_outputs,
VisitUmaFeature visit);
std::vector<proto::UMAFeature> GetAllUmaFeatures(
const proto::SegmentationModelMetadata& model_metadata,
bool include_outputs);
proto::PredictionResult CreatePredictionResult(
const std::vector<float>& model_scores,
const proto::OutputConfig& output_config,
base::Time timestamp,
int64_t model_version);
proto::ClientResult CreateClientResultFromPredResult(
proto::PredictionResult pred_result,
base::Time timestamp);
bool ConfigUsesLegacyOutput(const Config* config);
bool SegmentUsesLegacyOutput(proto::SegmentId segment_id);
}
}
#endif