Package com.opengamma.engine.cache

Examples of com.opengamma.engine.cache.CacheSelectHint


  }

  @Override
  public CalculationJob buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
    final CalculationJobSpecification jobSpec = CalculationJobSpecificationFudgeBuilder.buildObjectImpl(message);
    final CacheSelectHint cacheSelectHint = CacheSelectHintFudgeBuilder.buildObjectImpl(message);
    final long[] requiredJobIds = message.getValue(long[].class, REQUIRED_FIELD_NAME);
    final long functionInitializationIdentifier = message.getLong(FUNCTION_INITIALIZATION_IDENTIFIER_FIELD_NAME);
    final VersionCorrection resolverVersionCorrection = deserializer.fieldValueToObject(VersionCorrection.class, message.getByName(RESOLVER_VERSION_CORRECTION_FIELD_NAME));
    final List<CalculationJobItem> jobItems = buildItemsObject(deserializer, message.getMessage(ITEMS_FIELD_NAME));
    return new CalculationJob(jobSpec, functionInitializationIdentifier, resolverVersionCorrection, requiredJobIds, jobItems, cacheSelectHint);
View Full Code Here


   * @param receiver the receiver to notify when the second job completes, not null
   */
  private static DispatchableJob splitJob(final WatchedJob creator, final CalculationJob job) {
    final List<CalculationJobItem> items = job.getJobItems();
    s_logger.debug("Splitting {} for resubmission ", job);
    final CacheSelectHint hint = job.getCacheSelectHint();
    // Build the head job items
    final int headItemCount = items.size() >> 1;
    final List<CalculationJobItem> headItems = new ArrayList<CalculationJobItem>(headItemCount);
    final Set<ValueSpecification> headShared = new HashSet<ValueSpecification>();
    final Set<ValueSpecification> headPrivate = new HashSet<ValueSpecification>();
    final int tailItemCount = (items.size() + 1) >> 1;
    for (int i = 0; i < headItemCount; i++) {
      final CalculationJobItem item = items.get(i);
      headItems.add(item);
      for (ValueSpecification input : item.getInputs()) {
        if (hint.isPrivateValue(input)) {
          headPrivate.add(input);
        } else {
          headShared.add(input);
        }
      }
      for (ValueSpecification output : item.getOutputs()) {
        if (hint.isPrivateValue(output)) {
          headPrivate.add(output);
        } else {
          headShared.add(output);
        }
      }
    }
    // Build the tail job items and adjust the cache hint for head private values
    final List<CalculationJobItem> tailItems = new ArrayList<CalculationJobItem>(tailItemCount);
    final Set<ValueSpecification> tailShared = new HashSet<ValueSpecification>();
    final Set<ValueSpecification> tailPrivate = new HashSet<ValueSpecification>();
    for (int i = 0; i < tailItemCount; i++) {
      final CalculationJobItem item = items.get(headItemCount + i);
      tailItems.add(item);
      for (ValueSpecification input : item.getInputs()) {
        if (hint.isPrivateValue(input)) {
          // If the head had this as private, make shared
          if (headPrivate.remove(input)) {
            headShared.add(input);
            tailShared.add(input);
          }
        } else {
          tailShared.add(input);
        }
      }
      for (ValueSpecification output : item.getOutputs()) {
        if (hint.isPrivateValue(output)) {
          tailPrivate.add(output);
        } else {
          tailShared.add(output);
        }
      }
    }
    // Construct the head cache hint, job specification (synthetic ID) and job
    final CacheSelectHint headHint;
    if (headPrivate.size() > headShared.size()) {
      headHint = CacheSelectHint.sharedValues(headShared);
    } else {
      headHint = CacheSelectHint.privateValues(headPrivate);
    }
    final CalculationJob head = new CalculationJob(job.getSpecification().withJobId(JobIdSource.getId()), job.getFunctionInitializationIdentifier(), job.getResolverVersionCorrection(), null,
        headItems, headHint);
    // Construct the tail cache hint, job specification (using original ID) and job
    final CacheSelectHint tailHint;
    if (tailPrivate.size() > tailShared.size()) {
      tailHint = CacheSelectHint.sharedValues(tailShared);
    } else {
      tailHint = CacheSelectHint.privateValues(tailPrivate);
    }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.cache.CacheSelectHint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.