Interface ICachedStorageBackend
- Namespace
- OptunaSharp.Storages
- Assembly
- OptunaSharp.dll
The backend contract CachedStorage wraps — the internal RDBStorage surface
it drives in Python (_create_new_trial, _set_trial_param,
_get_best_trial_id, _get_trials). The Tier X
OptunaSharp.Storage.Sqlite/EFCore RDB storages implement this
(PORTING_PLAN 4.1/4.2); the wrapper itself is Tier N because the read-through cache logic
is reused there unchanged.
public interface ICachedStorageBackend : IBaseHeartbeat
- Inherited Members
Methods
CreateNewTrialFull(int, FrozenTrial?)
Python RDBStorage._create_new_trial: create and return the full frozen trial.
FrozenTrial CreateNewTrialFull(int studyId, FrozenTrial? templateTrial = null)
Parameters
studyIdintStorage identifier of the study; distinct from its name.
templateTrialFrozenTrialOptional record to copy; null creates a new running trial with empty observations.
Returns
- FrozenTrial
The created trial including assigned storage identifier and per-study number.
Exceptions
- KeyError
The study does not exist.
GetBestTrialId(int, StudyDirection)
Python RDBStorage._get_best_trial_id.
int GetBestTrialId(int studyId, StudyDirection direction)
Parameters
studyIdintStorage identifier of the study; distinct from its name.
directionStudyDirectionDirection used to order completed objective values.
Returns
- int
Identifier of the best completed trial according to the supplied direction.
Exceptions
- ValueError
The study has no completed trials.
GetTrialsPartial(int, IReadOnlyCollection<TrialState>?, IReadOnlyCollection<int>, int)
Python RDBStorage._get_trials(study_id, states, included_trial_ids, trial_id_greater_than):
trials whose ID is in includedTrialIds or greater than
trialIdGreaterThan.
List<FrozenTrial> GetTrialsPartial(int studyId, IReadOnlyCollection<TrialState>? states, IReadOnlyCollection<int> includedTrialIds, int trialIdGreaterThan)
Parameters
studyIdintStorage identifier of the study; distinct from its name.
statesIReadOnlyCollection<TrialState>States to include; null includes every state.
includedTrialIdsIReadOnlyCollection<int>Identifiers to fetch even when at or below the high-water mark.
trialIdGreaterThanintExclusive identifier threshold for fetching trials created since the previous refresh.
Returns
- List<FrozenTrial>
Trials satisfying the state filter and either identifier selection condition.
SetTrialParamWithCachedDistribution(int, string, double, BaseDistribution, BaseDistribution?)
Python RDBStorage._set_trial_param with the cached distribution shortcut.
void SetTrialParamWithCachedDistribution(int trialId, string paramName, double paramValueInternal, BaseDistribution distribution, BaseDistribution? cachedDistribution)
Parameters
trialIdintStorage identifier of the trial; distinct from its per-study trial number.
paramNamestringParameter name used as the storage and distribution lookup key.
paramValueInternaldoubleParameter value in the distribution's internal numeric representation.
distributionBaseDistributionDistribution defining the parameter representation and allowed values.
cachedDistributionBaseDistributionPreviously cached distribution, or null when the backend must load it.
Exceptions
- KeyError
The trial does not exist.
- UpdateFinishedTrialError
The trial has finished.
- ValueError
The proposed and stored distributions are incompatible.