Package com.facebook.LinkBench.distributions

Examples of com.facebook.LinkBench.distributions.ID2Chooser


    linksloaded = 0;
    sameShuffle = 0;
    diffShuffle = 0;
    stats = new SampledStats(loaderID, maxsamples, csvStreamOut);

    id2chooser = new ID2Chooser(props, startid1, maxid1, 1, 1);
  }
View Full Code Here


        readDistUncorr = AccessDistributions.loadAccessDistribution(props,
            startid1, maxid1, DistributionType.LINK_READS_UNCORR);
      }
    }

    id2chooser = new ID2Chooser(props, startid1, maxid1,
                                nrequesters, requesterID);

    // Distribution of #id2s per multiget
    String multigetDistClass = props.getProperty(Config.LINK_MULTIGET_DIST);
    if (multigetDistClass != null && multigetDistClass.trim().length() != 0) {
View Full Code Here

    long min = 500;
    long max = n + min;
    long seed = 5313242;
    Random rng = new Random(seed);

    ID2Chooser c = new ID2Chooser(props, min, max, 1, 1);
    // Check we don't get the same id2 more than once (i.e. duplicate links)

    int nlinks = 50;
    HashMap<Long, Integer> seen = new HashMap<Long, Integer>();

    long id1 = 1234;
    for (int i = 0; i < nlinks; i++) {
      long id2 = c.chooseForLoad(rng, id1, LinkStore.DEFAULT_LINK_TYPE, i);
      Integer j = seen.get(id2);
      if (j != null) {
        fail("Same link generated twice: (" + id1 + ", " + id2 + ") for " +
            " indices " + j + " and " + i);
      }
View Full Code Here

    Random rng = new Random(seed);
    long n = 10000;
    long min = 500;
    long max = n + min;
    int trials = 1000;
    ID2Chooser c = new ID2Chooser(props, min, max, 1, 1);
    for (int i = 0; i < trials; i++) {
      long id2 = c.chooseForOp(rng, i + min, LinkStore.DEFAULT_LINK_TYPE, 1.0);
      assert(id2 >= min);

      id2 = c.chooseForOp(rng, i + min, LinkStore.DEFAULT_LINK_TYPE, 0.5);
      assert(id2 >= min);
    }
  }
View Full Code Here

  public void testMatchPercent() {
    long seed = 15325435L;
    Random rng = new Random(seed);

    int minid = 500, maxid=1000000;
    ID2Chooser chooser = new ID2Chooser(props, minid, maxid, 1, 0);
    for (int id1 = minid; id1 < maxid; id1 += 3763) {
      HashSet<Long> existing = new HashSet<Long>();
      long nlinks = chooser.calcTotalLinkCount(id1);
      for (long i = 0; i < nlinks; i++) {
        long id2 = chooser.chooseForLoad(rng, id1,
                                LinkStore.DEFAULT_LINK_TYPE, i);
        existing.add(id2);
      }

      int trials = 10000;

      int hit = 0; // hit for prob = 50%

      for (int i = 0; i < trials; i++) {
        // Test with 100% prob of hit
        long id2 = chooser.chooseForOp(rng, id1,
                                          LinkStore.DEFAULT_LINK_TYPE, 1.0);
        assertTrue(existing.contains(id2) || existing.size() == 0);

        // Test with 50% prob of hit
        id2 = chooser.chooseForOp(rng, id1, LinkStore.DEFAULT_LINK_TYPE, 0.5);
        if (existing.contains(id2)) {
          hit++;
        }
      }
View Full Code Here

    long startid = 1, maxid = 1000;
    Properties newProps = new Properties(props);
    int nLinkTypes = 10;
    newProps.setProperty(Config.LINK_TYPE_COUNT, Integer.toString(nLinkTypes));

    ID2Chooser chooser = new ID2Chooser(newProps, startid, maxid, 1, 0);
    long linkTypes[] = chooser.getLinkTypes();
    assertEquals(nLinkTypes, linkTypes.length);

    // Check it works for some different IDs
    for (long id = startid; id < maxid; id += 7) {
      long totalCount = 0;
      for (long linkType: linkTypes) {
        totalCount += chooser.calcLinkCount(id, linkType);
      }
      assertEquals(chooser.calcTotalLinkCount(id), totalCount);
    }
  }
View Full Code Here

TOP

Related Classes of com.facebook.LinkBench.distributions.ID2Chooser

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.