Поделиться через


CSFInitPipeline

Use the CSFInitPipeline pipeline component at the beginning of a Content Selection pipeline (CSP) to initialize the values needed in the rest of the pipeline.

Intended use: Content Selection pipeline, Load Context stage.

Values Read

The CSFInitPipeline pipeline component reads the following values from the indicated dictionaries.

Key

Dictionary

Description

CacheName

Context

The name of the cache. Used to retrieve the cache from the CacheManager object.

CacheManager

Context

A reference to the CacheManager object.

ContextProfile

Context

A reference to the ContentSelector object (CSO). This object can be assigned arbitrary properties and can be used to pass additional information into the pipeline. Two entries are required. For more information, see the Remarks section.

ContextProfile.Trace

Context

Optional. A Boolean providing the Trace setting for the entire pipeline. Set in the ContentSelector object. Use tracing only when debugging a pipeline — tracing degrades pipeline performance.

ContextProfile.PageGroup

Context

Optional. If present, this key causes the Cache.PageGroup property to be copied into the Context dictionary. This key is also used as a key in the FilterRequire dictionary. For more information, see the Remarks section.

ContextProfile.Size

Context

Optional. If present, this key is created as a key in the FilterRequire dictionary. For more information, see the Remarks section.

ContextProfile.NumRequested

Context

Optional. The NumRequested property of the ContentSelector object: the number of content items requested. This key is copied to the Context dictionary if it is set.

ContextProfile.UserProfile

Context

Optional. This key is a reference to a user profile object. This key is copied to the Context dictionary if it is set.

ContextProfile.FilterRequire

Context

Optional. This key is copied to the Context dictionary if it is set. For more information, see the Remarks section.

ContextProfile.FilterExclude

Context

Optional. This key is copied the to Context dictionary if it is set. For more information, see the Remarks section.

Values Written

The CSFInitPipeline pipeline component writes the following values to the indicated dictionaries.

Key

Dictionary

Description

_content

Order

A reference to a newly created and initialized ContentList object.

FilterRequire

Order

This key is copied from the ContextProfile.FilterRequire object if present. When present, this key causes the FilterContent component to invoke the Filter method of the ContentList object for each entry in the dictionary. The FilterAction parameter will be set to FILTER_REQUIRE for these invocations. The dictionary has keys that are the names of content fields to search and values that are the values to match.

_Performance

Order

A reference to the Performance dictionary, retrieved from the content cache. This key is used by the CSFAdvertisingNeedOfDelivery component later in a pipeline to select content items. See CSFRecordEvent for information about this dictionary.

_cache

Context

A reference to the Dictionary object containing the items retrieved from the cache.

Templates

Context

The templates property of the cache. A Dictionary object.

PageGroups

Context

The PageGroups entry from the cache.

RedirectUrl

Context

The Uniform Resource Locator (URL) to which to redirect users.

PageGroupID

Context

The current page group.

NumRequested

Order

Optional. This entry is created only if the ContextProfile object has a NumRequested property set. This key indicates the number of content items being requested. The pipeline returns only one content item when this key is not present.

FilterExclude

Order

Optional. This key is copied from the ContextProfile.FilterExclude object if present. When present, this key will cause the FilterContent component to invoke the Filter method of the ContentList object for each entry in the dictionary. The FilterAction parameter is set to FILTER_EXCLUDE for these invocations. The dictionary has keys that are the names of content fields to search and values that are the values to match.

Trace

Context

Optional. The trace setting from the ContextProfile object, if any. This value is used as the value for the TraceMode property in the ContentList object, turning tracing either on or off.

UserProfile

Context

Optional. A reference to the user profile copied from the ContentSelector object (CSO).

Remarks

The CSFInitPipeline pipeline component is responsible for setting up numerous values in the Order and Context dictionaries for use by subsequent components in a Content Selection pipeline. In addition, the component automatically generates some content filters and allows you to use FilterInclude, FilterExclude, and PageGroups dictionaries to customize filtering without writing new pipeline components.

In general, the values the CSFInitPipeline pipeline component sets up in the Order and Context dictionaries are derived from the ContextProfile entry in the Context dictionary, or from the Cache dictionary retrieved from the CacheManager object. The ContextProfile entry in the Order dictionary contains a reference to the ContentSelector object, which provides much of the information required by the pipeline.

Also, by moving the various values from the ContextProfile to the Order and Context dictionary objects, the pipeline components farther down the pipeline have much more efficient access to this data.

Perhaps the most important task performed by the CSFInitPipeline pipeline component is the creation and initialization of the ContentList object. It is within this object that content scoring is tracked during execution of the pipeline.

The CSFInitPipeline pipeline component creates the ContentList object by following these steps:

  1. Retrieve the name of the cache from ContextProfile.

  2. Retrieve the CacheManager object from ContextProfile.CacheManager property.

  3. Get the cache from the CacheManager object.

  4. Obtain the ContentListFactory object from the cache.

  5. Call the CreateNewContentList method of the ContentListFactory object and assign the new content list to the _content key in the Order dictionary.

The FilterRequire and FilterExclude dictionaries allow custom filters to be set up without writing new pipeline components. For ease of use, the CSFInitPipeline pipeline component automatically sets up some commonly used filters for page group, ad size, and (for Discount Content Selection pipelines) NoDisplay templates. If no FilterRequire or FilterExclude dictionary is explicitly passed and one of these filters is applicable, the filter dictionary will automatically be created. If the CSFInitPipeline pipeline component detects existing filters for these keys already in a filter dictionary, it will not modify the filter.

The CSFInitPipeline pipeline component creates a filter for PageGroup (unless one already exists). This filter contains the special PageGroup "All" (Run of Site), which allows any content marked to run on the whole site to pass, and it also contains the value of the PageGroup property set on the ContentSelector object making the GetContent call (if set).

This component breaks the rule of never writing data to the Context dictionary. Nevertheless, the convention should be observed as it is by the vast majority of pipeline components.

See Also

Other Resources

IContentList::Filter Method

Pipeline Component Reference