Class DefaultRuleKeyFactory
- java.lang.Object
-
- com.facebook.buck.rules.keys.DefaultRuleKeyFactory
-
- All Implemented Interfaces:
RuleKeyFactory<RuleKey>
,RuleKeyFactoryWithDiagnostics<RuleKey>
public class DefaultRuleKeyFactory extends Object implements RuleKeyFactoryWithDiagnostics<RuleKey>
ARuleKeyFactory
which adds some default settings toRuleKey
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DefaultRuleKeyFactory.Builder<RULE_KEY>
-
Constructor Summary
Constructors Constructor Description DefaultRuleKeyFactory(RuleKeyFieldLoader ruleKeyFieldLoader, FileHashLoader hashLoader, SourcePathRuleFinder ruleFinder)
DefaultRuleKeyFactory(RuleKeyFieldLoader ruleKeyFieldLoader, FileHashLoader hashLoader, SourcePathRuleFinder ruleFinder, RuleKeyCache<RuleKey> ruleKeyCache, Optional<ThriftRuleKeyLogger> ruleKeyLogger)
DefaultRuleKeyFactory(RuleKeyFieldLoader ruleKeyFieldLoader, FileHashLoader hashLoader, SourcePathRuleFinder ruleFinder, Optional<ThriftRuleKeyLogger> ruleKeyLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RuleKey
build(BuildEngineAction action)
Creates a newRULE_KEY
for the givenBuildEngineAction
.<DIAG_KEY> RuleKeyDiagnostics.Result<RuleKey,DIAG_KEY>
buildForDiagnostics(BuildEngineAction action, RuleKeyHasher<DIAG_KEY> hasher)
Builds a diagnostic result for the given rule or appendable.<DIAG_KEY> RuleKeyDiagnostics.Result<RuleKey,DIAG_KEY>
buildForDiagnostics(AddsToRuleKey appendable, RuleKeyHasher<DIAG_KEY> hasher)
RuleKey
getFromCache(BuildEngineAction action)
Returns aRULE_KEY
from an internal cache, if possible.DefaultRuleKeyFactory.Builder<com.google.common.hash.HashCode>
newBuilderForTesting(BuildRule buildRule)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.facebook.buck.rules.keys.RuleKeyFactory
getInputSizeLimit
-
-
-
-
Constructor Detail
-
DefaultRuleKeyFactory
public DefaultRuleKeyFactory(RuleKeyFieldLoader ruleKeyFieldLoader, FileHashLoader hashLoader, SourcePathRuleFinder ruleFinder, RuleKeyCache<RuleKey> ruleKeyCache, Optional<ThriftRuleKeyLogger> ruleKeyLogger)
-
DefaultRuleKeyFactory
public DefaultRuleKeyFactory(RuleKeyFieldLoader ruleKeyFieldLoader, FileHashLoader hashLoader, SourcePathRuleFinder ruleFinder)
-
DefaultRuleKeyFactory
public DefaultRuleKeyFactory(RuleKeyFieldLoader ruleKeyFieldLoader, FileHashLoader hashLoader, SourcePathRuleFinder ruleFinder, Optional<ThriftRuleKeyLogger> ruleKeyLogger)
-
-
Method Detail
-
newBuilderForTesting
public DefaultRuleKeyFactory.Builder<com.google.common.hash.HashCode> newBuilderForTesting(BuildRule buildRule)
-
getFromCache
@Nullable public RuleKey getFromCache(BuildEngineAction action)
Description copied from interface:RuleKeyFactory
Returns aRULE_KEY
from an internal cache, if possible. If a non-null value is returned, it is guaranteed to be he same as ifRuleKeyFactory.build(com.facebook.buck.core.build.action.BuildEngineAction)
were called instead.- Specified by:
getFromCache
in interfaceRuleKeyFactory<RuleKey>
-
build
public RuleKey build(BuildEngineAction action)
Description copied from interface:RuleKeyFactory
Creates a newRULE_KEY
for the givenBuildEngineAction
. In most casesRULE_KEY
is going to beRuleKey
, but it can be anything really.- Specified by:
build
in interfaceRuleKeyFactory<RuleKey>
- Parameters:
action
- The build rule to create the key for.- Returns:
- A rule key.
-
buildForDiagnostics
public <DIAG_KEY> RuleKeyDiagnostics.Result<RuleKey,DIAG_KEY> buildForDiagnostics(BuildEngineAction action, RuleKeyHasher<DIAG_KEY> hasher)
Description copied from interface:RuleKeyFactoryWithDiagnostics
Builds a diagnostic result for the given rule or appendable.This method is intended to be used exclusively for diagnostic purposes and not for computing rule keys used for build process in any other way.
The provided custom hasher is used for all the elements hashed under this rule or appendable.
Note however that if the factory chooses to hash nested build rules and appendables separately, and only include their final hash for the computation of this hash, this choice applies both to real rule keys and the diagnostic keys. The client may need to perform a separate call for each build rule or appendable of interest. Moreover, the hash for the nested build rules and appendables is obtained by using the default hasher and not the provided custom hasher. This is the natural choice as it allows the custom hasher to see precisely those elements that the default hasher sees. It is also more efficient because factories usually cache rule keys computed with the default hasher, whereas using the custom hasher prevents that and would require hashing all of its transitive dependencies.
- Specified by:
buildForDiagnostics
in interfaceRuleKeyFactoryWithDiagnostics<RuleKey>
-
buildForDiagnostics
public <DIAG_KEY> RuleKeyDiagnostics.Result<RuleKey,DIAG_KEY> buildForDiagnostics(AddsToRuleKey appendable, RuleKeyHasher<DIAG_KEY> hasher)
- Specified by:
buildForDiagnostics
in interfaceRuleKeyFactoryWithDiagnostics<RuleKey>
-
-