/**
  * Indicates whether an output with the given specification should be included in the results.
  *
  * @param outputSpecification the specification of the output value, not null
  * @param dependencyGraph the dependency graph to which the output value belongs, not null
  * @return true if the output value should be included in the results
  */
 public boolean shouldOutputResult(
     ValueSpecification outputSpecification, DependencyGraph dependencyGraph) {
   ArgumentChecker.notNull(outputSpecification, "outputSpecification");
   ArgumentChecker.notNull(dependencyGraph, "dependencyGraph");
   ComputationTargetType targetType = outputSpecification.getTargetSpecification().getType();
   return getOutputMode(targetType).shouldOutputResult(outputSpecification, dependencyGraph);
 }
 protected ValueSpecification getOutputSpec(ValueSpecification inputSpec) {
   ValueProperties outputProperties =
       inputSpec
           .getProperties()
           .copy()
           .withoutAny(ValuePropertyNames.FUNCTION)
           .with(ValuePropertyNames.FUNCTION, getUniqueId())
           .get();
   return new ValueSpecification(
       ValueRequirementNames.TARGET, inputSpec.getTargetSpecification(), outputProperties);
 }
 @Override
 public Set<ValueSpecification> getResults(
     final FunctionCompilationContext context,
     final ComputationTarget target,
     final Map<ValueSpecification, ValueRequirement> inputs) {
   ValueSpecification inputValue = null;
   ValueSpecification inputParent = null;
   final UniqueId value = target.getUniqueId();
   for (ValueSpecification input : inputs.keySet()) {
     if (value.equals(input.getTargetSpecification().getUniqueId())) {
       assert inputValue == null;
       inputValue = input;
     } else {
       assert inputParent == null;
       inputParent = input;
     }
   }
   final ValueProperties rawResultProperties =
       inputValue.getProperties().intersect(inputParent.getProperties());
   final ValueProperties.Builder resultPropertiesBuilder = rawResultProperties.copy();
   for (String unit : UnitProperties.unitPropertyNames()) {
     final Set<String> valueUnits = inputValue.getProperties().getValues(unit);
     final Set<String> parentUnits = inputParent.getProperties().getValues(unit);
     if (valueUnits != null) {
       if (parentUnits != null) {
         if (rawResultProperties.getValues(unit) != null) {
           // The operation is a division, so there are no units on the result
           resultPropertiesBuilder.withoutAny(unit);
         } else {
           // No common intersection between parent and value properties for this unit
           return null;
         }
       } else {
         // Parent did not include the same units as the value
         return null;
       }
     } else {
       if (parentUnits != null) {
         // Value did not include the same units as the parent
         return null;
       }
     }
   }
   resultPropertiesBuilder
       .withoutAny(VALUE_PROPERTY_NAME)
       .with(VALUE_PROPERTY_NAME, inputValue.getValueName());
   resultPropertiesBuilder
       .withoutAny(ValuePropertyNames.FUNCTION)
       .with(ValuePropertyNames.FUNCTION, getUniqueId());
   return Collections.singleton(
       new ValueSpecification(
           ValueRequirementNames.WEIGHT, target.toSpecification(), resultPropertiesBuilder.get()));
 }
 /**
  * Simplifies the type based on the associated {@link ComputationTargetResolver}.
  *
  * @param valueSpec the specification to process, not null
  * @return the possibly simplified specification, not null
  */
 public ValueSpecification simplifyType(final ValueSpecification valueSpec) {
   final ComputationTargetSpecification oldTargetSpec = valueSpec.getTargetSpecification();
   final ComputationTargetSpecification newTargetSpec =
       ComputationTargetResolverUtils.simplifyType(
           oldTargetSpec, getCompilationContext().getComputationTargetResolver());
   if (newTargetSpec == oldTargetSpec) {
     return MemoryUtils.instance(valueSpec);
   } else {
     return MemoryUtils.instance(
         new ValueSpecification(
             valueSpec.getValueName(), newTargetSpec, valueSpec.getProperties()));
   }
 }
 private static VolatilitySurfaceKey createKey(ValueSpecification valueSpecification) {
   UniqueId uniqueId = valueSpecification.getTargetSpecification().getUniqueId();
   String surface = valueSpecification.getProperties().getStrictValue(ValuePropertyNames.SURFACE);
   String instrumentType = valueSpecification.getProperties().getStrictValue("InstrumentType");
   String quoteType =
       valueSpecification
           .getProperties()
           .getStrictValue(SurfaceAndCubePropertyNames.PROPERTY_SURFACE_QUOTE_TYPE);
   String quoteUnits =
       valueSpecification
           .getProperties()
           .getStrictValue(SurfaceAndCubePropertyNames.PROPERTY_SURFACE_UNITS);
   return VolatilitySurfaceKey.of(uniqueId, surface, instrumentType, quoteType, quoteUnits);
 }
Esempio n. 6
0
 @Override
 public String toString() {
   // carefully select useful fields for toString
   ToStringStyle style = ToStringStyle.SHORT_PREFIX_STYLE;
   StringBuffer sb = new StringBuffer();
   style.appendStart(sb, this);
   style.append(sb, "result", getInvocationResult(), null);
   ValueSpecification spec = getSpecification();
   if (spec != null) {
     style.append(sb, "name", spec.getValueName(), null);
     ComputationTargetSpecification targetSpec = spec.getTargetSpecification();
     style.append(sb, "targetId", targetSpec.getIdentifier(), null);
     style.append(sb, "targetType", targetSpec.getType(), null);
     style.append(sb, "properties", spec.getProperties(), null);
   }
   style.append(sb, "value", getValue(), null);
   style.appendEnd(sb, this);
   return sb.toString();
 }