Package com.yahoo.search.query.profile
Class QueryProfileVariants
- java.lang.Object
-
- com.yahoo.search.query.profile.QueryProfileVariants
-
- All Implemented Interfaces:
com.yahoo.component.provider.Freezable
,Cloneable
public class QueryProfileVariants extends Object implements com.yahoo.component.provider.Freezable, Cloneable
This class represent a set of query profiles virtually - rather than storing and instantiating each profile this structure represents explicitly only the values set in the various virtual profiles. The set of virtual profiles are defined by a set of dimensions. Values may be set for any point in this multi-dimensional space, and may also be set for any regular hyper-region by setting values for any point in certain of these dimensions. The set of virtual profiles defined by this consists of all the combinations of dimension points for which one or more values is set in this, as well as any possible less specified regions.A set of virtual profiles are always owned by a single profile, which is also their parent in the inheritance hierarchy.
- Author:
- bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueryProfileVariants.FieldValue
static class
QueryProfileVariants.FieldValues
-
Constructor Summary
Constructors Constructor Description QueryProfileVariants(String[] dimensions, QueryProfile owner)
Creates a set of virtual query profiles which may return varying values over the set of dimensions given.QueryProfileVariants(List<String> dimensions, QueryProfile owner)
Creates a set of virtual query profiles which may return varying values over the set of dimensions given.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryProfileVariants
clone()
protected void
ensureNotFrozen()
Throws an IllegalStateException if this is frozenvoid
freeze()
Irreversibly prevents any further modifications to thisObject
get(String name, QueryProfileType type, boolean allowQueryProfileResult, DimensionBinding dimensionBinding)
Returns the most specific matching value of a name for a given set of canonical dimension values.List<String>
getDimensions()
Returns the dimensions over which the virtual profiles in this may return different values.Map<String,QueryProfileVariants.FieldValues>
getFieldValues()
Returns the map of field values of this indexed by field name.QueryProfileVariants.FieldValues
getInherited()
Returns the profiles inherited from various variants of thisQueryProfileVariant
getVariant(DimensionValues dimensionValues, boolean create)
Returns the query profile variant having exactly the given dimensions, and creates it if create is set and it is missingList<QueryProfileVariant>
getVariants()
Returns all the variants of this, sorted by specificity.void
inherit(QueryProfile profile, DimensionValues dimensionValues)
Inherits a particular profile in a variant of thisboolean
isFrozen()
Boolean
isOverridable(String fieldName, DimensionValues dimensionValues)
void
set(String fieldName, DimensionValues dimensionValues, Object value)
Sets a value to thisvoid
setOverridable(String fieldName, boolean overridable, DimensionValues dimensionValues)
Makes a value unoverridable in a given context.String
toString()
-
-
-
Constructor Detail
-
QueryProfileVariants
public QueryProfileVariants(String[] dimensions, QueryProfile owner)
Creates a set of virtual query profiles which may return varying values over the set of dimensions given. Each dimension is a name for which a key-value may be supplied in the context properties on lookup time to influence the value returned.
-
QueryProfileVariants
public QueryProfileVariants(List<String> dimensions, QueryProfile owner)
Creates a set of virtual query profiles which may return varying values over the set of dimensions given. Each dimension is a name for which a key-value may be supplied in the context properties on lookup time to influence the value returned.- Parameters:
dimensions
- the dimension names this may vary over. The list gets owned by this, so it must not be further modified from outside). This will not modify the list.
-
-
Method Detail
-
freeze
public void freeze()
Irreversibly prevents any further modifications to this- Specified by:
freeze
in interfacecom.yahoo.component.provider.Freezable
-
isFrozen
public boolean isFrozen()
- Specified by:
isFrozen
in interfacecom.yahoo.component.provider.Freezable
-
get
public Object get(String name, QueryProfileType type, boolean allowQueryProfileResult, DimensionBinding dimensionBinding)
Returns the most specific matching value of a name for a given set of canonical dimension values.- Parameters:
name
- the name to return the best matching value ofdimensionBinding
- the dimension bindings to use in this
-
inherit
public void inherit(QueryProfile profile, DimensionValues dimensionValues)
Inherits a particular profile in a variant of this
-
set
public void set(String fieldName, DimensionValues dimensionValues, Object value)
Sets a value to this- Parameters:
fieldName
- the name of the field to set. This cannot be a compound (dotted) namedimensionValues
- the dimension values for which this value appliesvalue
- the value to set
-
setOverridable
public void setOverridable(String fieldName, boolean overridable, DimensionValues dimensionValues)
Makes a value unoverridable in a given context.
-
isOverridable
public Boolean isOverridable(String fieldName, DimensionValues dimensionValues)
-
getDimensions
public List<String> getDimensions()
Returns the dimensions over which the virtual profiles in this may return different values. Each dimension is a name for which a key-value may be supplied in the context properties on lookup time to influence the value returned. The dimensions may not be modified - the returned list is always read only.
-
getFieldValues
public Map<String,QueryProfileVariants.FieldValues> getFieldValues()
Returns the map of field values of this indexed by field name.
-
getInherited
public QueryProfileVariants.FieldValues getInherited()
Returns the profiles inherited from various variants of this
-
getVariants
public List<QueryProfileVariant> getVariants()
Returns all the variants of this, sorted by specificity. This is content as declared. The returned list is always unmodifiable.
-
clone
public QueryProfileVariants clone()
-
ensureNotFrozen
protected void ensureNotFrozen()
Throws an IllegalStateException if this is frozen
-
getVariant
public QueryProfileVariant getVariant(DimensionValues dimensionValues, boolean create)
Returns the query profile variant having exactly the given dimensions, and creates it if create is set and it is missing- Parameters:
dimensionValues
- the dimension valuescreate
- whether or not to create the variant if missing- Returns:
- the profile variant, or null if not found and create is false
-
-