Skip to main content

Shaper Pitfalls

This section refers to situations where the partitioning behaviour isn't obvious. The aim of this section is to clarify the algorithm used by Assetlib Shaper in choosing the partitioning rule to apply to a particular asset object.

Let's take for example the following partitioning configuration:

<?xml version="1.0" encoding="utf-8"?>
<shaper-configuration xmlns="http://tempuri.org/ConfigSchema.xsd">
    <partitions directory="C:/temp">
        <compression>
             <lib type="Font"/>
        </compression>
        <partition name="Master" master="true">
        </partition>
        <partition name="Fonts">
             <rule type="Font" item="*"></rule>
             <rule type="VertexBuffer" item="abc*"/>
             <rule type="Font" item="*" compress="false"/>
        </partition>
    </partitions>
</shaper-configuration>

By using this configuration two partitions are produced; Master and Fonts. The question is how Font entries are kept in the Fonts partition, compressed or uncompressed. There are two rules in the configuration for the Fonts partition referring to all Font entries (type="Font" and item="*"): 1. Doesn't overwrite the compression rule defined globally for the Font entries (it will compress all the Font entries) 2. Has the compress flag set to false, overwriting the globally defined compression rule (it won't compress the Font entries)

Note: from all the rules for a partition in a configuration file that regards a partition there's only one selected to be used for a particular entry. If there are more rules targeting the same entry (in our example, all the Font entries), the first criteria used in selecting the rule to apply is specificity. If one rule has type="Font" and item="*" and some other rule type="Font" and item="a*", the second rule is more specific than the first one, applying to a subset of all the entries (the entries that have a name that start with "a"). So the more specific rule wins.

Both rules in the provided sample configuration file, referring to Font entries, have the same specificity. Both apply to all Font entries (item="*"). In such a situation, the AssetLib Shaper always selects the first rule.

Summarizing criteria:

  • more specific rule wins;
  • equal specificity; the first rule defined in the configuration file wins.

Using the given rule selection criteria and considering the sample configuration file, the Font entries are compressed in the Fonts partition.