Examples of CacheSelectHint


Examples of com.opengamma.engine.cache.CacheSelectHint

    final PlannedJob job = plan.getLeafJobs().iterator().next();
    assertTrue(matchJob(job, _testNode[2]));
    assertEquals(job.getInputJobCount(), 0);
    assertEquals(job.getTails().length, 3);
    int mask = 0;
    final CacheSelectHint jobHint = job.getCacheSelectHint();
    for (PlannedJob tail : job.getTails()) {
      assertEquals(tail.getInputJobCount(), 1);
      assertNull(tail.getDependents());
      assertNull(tail.getTails());
      final CacheSelectHint tailHint = tail.getCacheSelectHint();
      if (matchJob(tail, _testNode[0])) {
        mask |= 1;
        assertTrue(jobHint.isPrivateValue(_testValue20));
        assertTrue(tailHint.isPrivateValue(_testValue20));
        assertFalse(tailHint.isPrivateValue(_testValue0x));
      } else if (matchJob(tail, _testNode[1])) {
        mask |= 2;
        assertTrue(jobHint.isPrivateValue(_testValue21));
        assertTrue(tailHint.isPrivateValue(_testValue21));
        assertFalse(tailHint.isPrivateValue(_testValue1x));
      } else if (matchJob(tail, _testNode[3], _testNode[4])) {
        mask |= 4;
        assertTrue(jobHint.isPrivateValue(_testValue24));
        assertTrue(tailHint.isPrivateValue(_testValue24));
        assertTrue(tailHint.isPrivateValue(_testValue34));
        assertFalse(tailHint.isPrivateValue(_testValuex3));
        assertFalse(tailHint.isPrivateValue(_testValue4x));
      } else {
        fail();
      }
    }
    assertEquals(mask, 7);
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

      plan.print();
    }
    assertEquals(plan.getLeafJobs().size(), 1);
    final PlannedJob job = plan.getLeafJobs().iterator().next();
    assertEquals(job.getItems().size(), 5);
    final CacheSelectHint hint = job.getCacheSelectHint();
    if (PRINT_GRAPHS) {
      System.out.println(hint);
    }
    assertTrue(hint.isPrivateValue(_testValue20));
    assertTrue(hint.isPrivateValue(_testValue21));
    assertTrue(hint.isPrivateValue(_testValue24));
    assertTrue(hint.isPrivateValue(_testValue34));
    assertFalse(hint.isPrivateValue(_testValue0x));
    assertFalse(hint.isPrivateValue(_testValue1x));
    assertFalse(hint.isPrivateValue(_testValue4x));
    assertFalse(hint.isPrivateValue(_testValuex2));
    assertFalse(hint.isPrivateValue(_testValuex3));
    assertNull(job.getDependents());
    assertNull(job.getTails());
    assertEquals(job.getInputJobCount(), 0);
  }
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

    }
    assertEquals(plan.getLeafJobs().size(), 2);
    int mask = 0;
    for (PlannedJob job : plan.getLeafJobs()) {
      assertEquals(job.getInputJobCount(), 0);
      CacheSelectHint hint = job.getCacheSelectHint();
      if (matchJob(job, _testNode[2])) {
        mask |= 1;
        assertEquals(job.getDependents().length, 3);
        assertNull(job.getTails());
        assertFalse(hint.isPrivateValue(_testValue20));
        assertFalse(hint.isPrivateValue(_testValue21));
        assertFalse(hint.isPrivateValue(_testValue24));
        assertFalse(hint.isPrivateValue(_testValuex2));
        for (PlannedJob job2 : job.getDependents()) {
          hint = job2.getCacheSelectHint();
          assertNull(job2.getDependents());
          assertNull(job2.getTails());
          if (matchJob(job2, _testNode[0])) {
            mask |= 2;
            assertEquals(job2.getInputJobCount(), 1);
            assertFalse(hint.isPrivateValue(_testValue0x));
            assertFalse(hint.isPrivateValue(_testValue20));
          } else if (matchJob(job2, _testNode[1])) {
            mask |= 4;
            assertEquals(job2.getInputJobCount(), 1);
            assertFalse(hint.isPrivateValue(_testValue1x));
            assertFalse(hint.isPrivateValue(_testValue21));
          } else if (matchJob(job2, _testNode[4])) {
            mask |= 8;
            assertEquals(job2.getInputJobCount(), 2);
            assertFalse(hint.isPrivateValue(_testValue4x));
            assertFalse(hint.isPrivateValue(_testValue24));
            assertFalse(hint.isPrivateValue(_testValue34));
          } else {
            fail();
          }
        }
      } else if (matchJob(job, _testNode[3])) {
        mask |= 16;
        assertEquals(job.getDependents().length, 1);
        assertNull(job.getTails());
        assertFalse(hint.isPrivateValue(_testValue34));
        assertFalse(hint.isPrivateValue(_testValuex3));
        PlannedJob job2 = job.getDependents()[0];
        hint = job2.getCacheSelectHint();
        assertEquals(job2.getInputJobCount(), 2);
        assertNull(job2.getDependents());
        assertNull(job2.getTails());
        assertTrue(matchJob(job2, _testNode[4]));
        assertFalse(hint.isPrivateValue(_testValue4x));
        assertFalse(hint.isPrivateValue(_testValue24));
        assertFalse(hint.isPrivateValue(_testValue34));
      } else {
        fail();
      }
    }
    assertEquals(mask, 31);
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

      plan.print();
    }
    assertEquals(plan.getLeafJobs().size(), 1);
    final PlannedJob job = plan.getLeafJobs().iterator().next();
    assertEquals(job.getInputJobCount(), 0);
    CacheSelectHint hint = job.getCacheSelectHint();
    assertTrue(matchJob(job, _testNode[2]));
    assertFalse(hint.isPrivateValue(_testValue20));
    assertFalse(hint.isPrivateValue(_testValue21));
    assertEquals(job.getDependents().length, 2);
    assertNull(job.getTails());
    int mask = 0;
    for (PlannedJob job2 : job.getDependents()) {
      assertEquals(job2.getInputJobCount(), 1);
      assertNull(job2.getDependents());
      assertNull(job2.getTails());
      hint = job2.getCacheSelectHint();
      if (matchJob(job2, _testNode[0], _testNode[1])) {
        mask |= 1;
        assertFalse(hint.isPrivateValue(_testValue20));
        assertFalse(hint.isPrivateValue(_testValue21));
        assertFalse(hint.isPrivateValue(_testValue0x));
        assertFalse(hint.isPrivateValue(_testValue1x));
      } else if (matchJob(job2, _testNode[3], _testNode[4])) {
        mask |= 2;
        assertFalse(hint.isPrivateValue(_testValue24));
        assertFalse(hint.isPrivateValue(_testValue4x));
        assertFalse(hint.isPrivateValue(_testValuex3));
        assertTrue(hint.isPrivateValue(_testValue34));
      } else {
        Assert.fail();
      }
    }
    assertEquals(mask, 3);
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

    PlannedJob job = plan.getLeafJobs().iterator().next();
    assertEquals(job.getInputJobCount(), 0);
    assertTrue(matchJob(job, _testNode[2]));
    assertEquals(job.getDependents().length, 1);
    assertNull(job.getTails());
    CacheSelectHint hint = job.getCacheSelectHint();
    assertFalse(hint.isPrivateValue(_testValuex2));
    assertFalse(hint.isPrivateValue(_testValue20));
    assertFalse(hint.isPrivateValue(_testValue21));
    assertFalse(hint.isPrivateValue(_testValue24));
    PlannedJob job2 = job.getDependents()[0];
    assertNull(job2.getTails());
    assertEquals(job2.getInputJobCount(), 1);
    assertTrue(matchJob(job2, _testNode[0], _testNode[1], _testNode[3], _testNode[4]));
    assertNull(job2.getDependents());
    assertNull(job2.getTails());
    hint = job2.getCacheSelectHint();
    assertFalse(hint.isPrivateValue(_testValue0x));
    assertFalse(hint.isPrivateValue(_testValue1x));
    assertFalse(hint.isPrivateValue(_testValue4x));
    assertFalse(hint.isPrivateValue(_testValue20));
    assertFalse(hint.isPrivateValue(_testValue21));
    assertFalse(hint.isPrivateValue(_testValue24));
    assertFalse(hint.isPrivateValue(_testValuex3));
    assertTrue(hint.isPrivateValue(_testValue34));
  }
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

    final PlannedJob job = plan.getLeafJobs().iterator().next();
    assertTrue(matchJob(job, _testNode[2]));
    assertEquals(job.getInputJobCount(), 0);
    assertEquals(job.getTails().length, 1);
    final PlannedJob tailJob = job.getTails()[0];
    final CacheSelectHint jobHint = job.getCacheSelectHint();
    final CacheSelectHint tailHint = tailJob.getCacheSelectHint();
    if (matchJob(tailJob, _testNode[0])) {
      assertTrue(jobHint.isPrivateValue(_testValue20));
      assertFalse(jobHint.isPrivateValue(_testValue21));
      assertFalse(jobHint.isPrivateValue(_testValue24));
      assertFalse(jobHint.isPrivateValue(_testValuex2));
      assertFalse(tailHint.isPrivateValue(_testValue0x));
      assertTrue(tailHint.isPrivateValue(_testValue20));
    } else if (matchJob(tailJob, _testNode[1])) {
      assertFalse(jobHint.isPrivateValue(_testValue20));
      assertTrue(jobHint.isPrivateValue(_testValue21));
      assertFalse(jobHint.isPrivateValue(_testValue24));
      assertFalse(jobHint.isPrivateValue(_testValuex2));
      assertFalse(tailHint.isPrivateValue(_testValue1x));
      assertTrue(tailHint.isPrivateValue(_testValue21));
    } else if (matchJob(tailJob, _testNode[3], _testNode[4])) {
      assertFalse(jobHint.isPrivateValue(_testValue20));
      assertFalse(jobHint.isPrivateValue(_testValue21));
      assertTrue(jobHint.isPrivateValue(_testValue24));
      assertFalse(jobHint.isPrivateValue(_testValuex2));
      assertFalse(tailHint.isPrivateValue(_testValuex3));
      assertTrue(tailHint.isPrivateValue(_testValue34));
      assertFalse(tailHint.isPrivateValue(_testValue4x));
      assertTrue(tailHint.isPrivateValue(_testValue24));
    } else {
      fail();
    }
  }
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

    final PlannedJob job = plan.getLeafJobs().iterator().next();
    assertTrue(matchJob(job, _testNode[2]));
    assertEquals(job.getInputJobCount(), 0);
    assertEquals(job.getTails().length, 2);
    int mask = 0;
    final CacheSelectHint jobHint = job.getCacheSelectHint();
    for (PlannedJob tail : job.getTails()) {
      assertEquals(tail.getInputJobCount(), 1);
      assertNull(tail.getDependents());
      assertNull(tail.getTails());
      final CacheSelectHint tailHint = tail.getCacheSelectHint();
      if (matchJob(tail, _testNode[0])) {
        mask |= 1;
        assertTrue(jobHint.isPrivateValue(_testValue20));
        assertTrue(tailHint.isPrivateValue(_testValue20));
        assertFalse(tailHint.isPrivateValue(_testValue0x));
      } else if (matchJob(tail, _testNode[1])) {
        mask |= 2;
        assertTrue(jobHint.isPrivateValue(_testValue21));
        assertTrue(tailHint.isPrivateValue(_testValue21));
        assertFalse(tailHint.isPrivateValue(_testValue1x));
      } else if (matchJob(tail, _testNode[3], _testNode[4])) {
        mask |= 4;
        assertTrue(jobHint.isPrivateValue(_testValue24));
        assertTrue(tailHint.isPrivateValue(_testValue24));
        assertTrue(tailHint.isPrivateValue(_testValue34));
        assertFalse(tailHint.isPrivateValue(_testValuex3));
        assertFalse(tailHint.isPrivateValue(_testValue4x));
      } else {
        fail();
      }
    }
    assertTrue((mask == 3) || (mask == 5) || (mask == 6));
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

  /* package */static CalculationJob adjustCacheHints(final CalculationJob job,
      final Map<ValueSpecification, Triple<CalculationJob, ? extends Set<ValueSpecification>, ? extends Set<ValueSpecification>>> outputs) {
    // (job, private, public)
    final Triple<CalculationJob, ? extends Set<ValueSpecification>, ? extends Set<ValueSpecification>> jobValues = Triple
        .of(job, new HashSet<ValueSpecification>(), new HashSet<ValueSpecification>());
    final CacheSelectHint hint = job.getCacheSelectHint();
    for (CalculationJobItem item : job.getJobItems()) {
      for (ValueSpecification input : item.getInputs()) {
        final Triple<CalculationJob, ? extends Set<ValueSpecification>, ? extends Set<ValueSpecification>> producer = outputs.get(input);
        if (producer == null) {
          // Input produced by a previous job, so must be in the shared cache
          assert !hint.isPrivateValue(input);
          jobValues.getThird().add(input);
        } else if (producer.getFirst() != job) {
          // Input produced by a previous job into the private cache -- rewrite to the shared
          assert hint.isPrivateValue(input);
          jobValues.getThird().add(input);
          if (producer.getSecond().remove(input)) {
            producer.getThird().add(input);
          }
        }
      }
      for (ValueSpecification output : item.getOutputs()) {
        if (hint.isPrivateValue(output)) {
          // Private output -- may be subject to a rewrite
          jobValues.getSecond().add(output);
          outputs.put(output, jobValues);
        } else {
          // Shared output
          jobValues.getThird().add(output);
        }
      }
    }
    // Rewriting the tail can further adjust the sets in our data triple from the original private/shared distribution
    final Collection<CalculationJob> oldTail = job.getTail();
    final Collection<CalculationJob> newTail;
    if (oldTail != null) {
      newTail = new ArrayList<CalculationJob>(oldTail.size());
      for (CalculationJob tail : oldTail) {
        newTail.add(adjustCacheHints(tail, outputs));
      }
    } else {
      newTail = null;
    }
    // Recalculate the smallest hint for our rewritten data
    final CacheSelectHint newHint;
    if (jobValues.getSecond().size() > jobValues.getThird().size()) {
      newHint = CacheSelectHint.sharedValues(jobValues.getThird());
    } else {
      newHint = CacheSelectHint.privateValues(jobValues.getSecond());
    }
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

      final CalculationJobItem jobItem = new CalculationJobItem(
          node.getFunction().getFunction().getFunctionDefinition().getUniqueId(), node.getFunction().getParameters(),
          node.getComputationTarget(), inputs, node.getOutputValues(), logMode);
      items.add(jobItem);
    }
    final CacheSelectHint hint = createCacheSelectHint(context);
    final Set<GraphFragment> outputFragments = getOutputFragments();
    final Collection<GraphFragment> tailFragments = getTail();
    final PlannedJob[] tailJobs;
    if (tailFragments != null) {
      int index = 0;
View Full Code Here

Examples of com.opengamma.engine.cache.CacheSelectHint

        }
        sharedValues.add(specification);
      }
    }
    s_logger.debug("{} private values, {} shared values in graph", privateValues.size(), sharedValues.size());
    final CacheSelectHint cacheHint;
    if (privateValues.size() < sharedValues.size()) {
      cacheHint = CacheSelectHint.privateValues(privateValues);
    } else {
      cacheHint = CacheSelectHint.sharedValues(sharedValues);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.