Package org.eclipse.jgit.lib.BitmapIndex

Examples of org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder


  }

  BitmapBuilder findObjects(Set<? extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissingStart)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();

    for (ObjectId obj : start) {
      Bitmap bitmap = bitmapIndex.getBitmap(obj);
      if (bitmap != null)
        bitmapResult.or(bitmap);
    }

    boolean marked = false;
    for (ObjectId obj : start) {
      try {
        if (!bitmapResult.contains(obj)) {
          walker.markStart(walker.parseAny(obj));
          marked = true;
        }
      } catch (MissingObjectException e) {
        if (ignoreMissingStart)
          continue;
        throw e;
      }
    }

    if (marked) {
      walker.setRevFilter(newRevFilter(seen, bitmapResult));

      while (walker.next() != null) {
        // Iterate through all of the commits. The BitmapRevFilter does
        // the work.
        pm.update(1);
      }

      RevObject ro;
      while ((ro = walker.nextObject()) != null) {
        bitmapResult.add(ro, ro.getType());
        pm.update(1);
      }
    }

    return bitmapResult;
View Full Code Here


  private void findObjectsToPackUsingBitmaps(
      PackWriterBitmapWalker bitmapWalker, Set<? extends ObjectId> want,
      Set<? extends ObjectId> have)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true);
    bitmapWalker.reset();
    BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap,
        false);
    BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);

    if (useCachedPacks && reuseSupport != null
        && (excludeInPacks == null || excludeInPacks.length == 0))
      cachedPacks.addAll(
          reuseSupport.getCachedPacksAndUpdate(needBitmap));

    for (BitmapObject obj : needBitmap) {
      ObjectId objectId = obj.getObjectId();
      if (exclude(objectId)) {
        needBitmap.remove(objectId);
        continue;
      }
      addObject(objectId, obj.getType(), 0);
    }
View Full Code Here

      if (cmit.isReuseWalker())
        walker.reset();
      else
        walker = bitmapPreparer.newBitmapWalker();

      BitmapBuilder bitmap = walker.findObjects(
          Collections.singleton(cmit), null, false);

      if (last != null && cmit.isReuseWalker() && !bitmap.contains(last))
        throw new IllegalStateException(MessageFormat.format(
            JGitText.get().bitmapMissingObject, cmit.name(),
            last.name()));
      last = cmit;
      writeBitmaps.addBitmap(cmit, bitmap.build(), cmit.getFlags());

      pm.update(1);
    }

    endPhase(pm);
View Full Code Here

        int flags = nextFlg;
        nextIn = nextSelectionDistance(index, cardinality);
        nextFlg = nextIn == maxCommits ? PackBitmapIndex.FLAG_REUSE : 0;
        mustPick = nextIn == 0;

        BitmapBuilder fullBitmap = commitBitmapIndex.newBitmapBuilder();
        rw.reset();
        rw.markStart(c);
        for (AnyObjectId objectId : result.reuse)
          rw.markUninteresting(rw.parseCommit(objectId));
        rw.setRevFilter(
            PackWriterBitmapWalker.newRevFilter(null, fullBitmap));

        while (rw.next() != null) {
          // Work is done in the RevFilter.
        }

        List<List<BitmapCommit>> matches = new ArrayList<
            List<BitmapCommit>>();
        for (List<BitmapCommit> list : running) {
          BitmapCommit last = list.get(list.size() - 1);
          if (fullBitmap.contains(last))
            matches.add(list);
        }

        List<BitmapCommit> match;
        if (matches.isEmpty()) {
View Full Code Here

    return selections;
  }

  private WalkResult findPaths(RevWalk rw, int expectedNumCommits)
      throws MissingObjectException, IOException {
    BitmapBuilder reuseBitmap = commitBitmapIndex.newBitmapBuilder();
    List<BitmapCommit> reuse = new ArrayList<BitmapCommit>();
    for (PackBitmapIndexRemapper.Entry entry : bitmapRemapper) {
      if ((entry.getFlags() & FLAG_REUSE) != FLAG_REUSE)
        continue;

      RevObject ro = rw.peel(rw.parseAny(entry));
      if (ro instanceof RevCommit) {
        RevCommit rc = (RevCommit) ro;
        reuse.add(new BitmapCommit(rc, false, entry.getFlags()));
        rw.markUninteresting(rc);

        EWAHCompressedBitmap bitmap = bitmapRemapper.ofObjectType(
            bitmapRemapper.getBitmap(rc), Constants.OBJ_COMMIT);
        writeBitmaps.addBitmap(rc, bitmap, 0);
        reuseBitmap.add(rc, Constants.OBJ_COMMIT);
      }
    }
    writeBitmaps.clearBitmaps(); // Remove temporary bitmaps

    // Do a RevWalk by commit time descending. Keep track of all the paths
    // from the wants.
    List<BitmapBuilder> paths = new ArrayList<BitmapBuilder>(want.size());
    Set<RevCommit> peeledWant = new HashSet<RevCommit>(want.size());
    for (AnyObjectId objectId : want) {
      RevObject ro = rw.peel(rw.parseAny(objectId));
      if (ro instanceof RevCommit && !reuseBitmap.contains(ro)) {
        RevCommit rc = (RevCommit) ro;
        peeledWant.add(rc);
        rw.markStart(rc);

        BitmapBuilder bitmap = commitBitmapIndex.newBitmapBuilder();
        bitmap.or(reuseBitmap);
        bitmap.add(rc, Constants.OBJ_COMMIT);
        paths.add(bitmap);
      }
    }

    // Update the paths from the wants and create a list of commits in
    // reverse iteration order.
    RevCommit[] commits = new RevCommit[expectedNumCommits];
    int pos = commits.length;
    RevCommit rc;
    while ((rc = rw.next()) != null) {
      commits[--pos] = rc;
      for (BitmapBuilder path : paths) {
        if (path.contains(rc)) {
          for (RevCommit c : rc.getParents())
            path.add(c, Constants.OBJ_COMMIT);
        }
      }

      pm.update(1);
    }

    // Remove the reused bitmaps from the paths
    if (!reuse.isEmpty())
      for (BitmapBuilder bitmap : paths)
        bitmap.andNot(reuseBitmap);

    // Sort the paths
    List<BitmapBuilder> distinctPaths = new ArrayList<BitmapBuilder>(paths.size());
    while (!paths.isEmpty()) {
      Collections.sort(paths, BUILDER_BY_CARDINALITY_DSC);
      BitmapBuilder largest = paths.remove(0);
      distinctPaths.add(largest);

      // Update the remaining paths, by removing the objects from
      // the path that was just added.
      for (int i = paths.size() - 1; i >= 0; i--)
View Full Code Here

  private void findObjectsToPackUsingBitmaps(
      PackWriterBitmapWalker bitmapWalker, Set<? extends ObjectId> want,
      Set<? extends ObjectId> have)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null);
    bitmapWalker.reset();
    BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap);
    BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);

    if (useCachedPacks && reuseSupport != null
        && (excludeInPacks == null || excludeInPacks.length == 0))
      cachedPacks.addAll(
          reuseSupport.getCachedPacksAndUpdate(needBitmap));

    for (BitmapObject obj : needBitmap) {
      ObjectId objectId = obj.getObjectId();
      if (exclude(objectId)) {
        needBitmap.remove(objectId);
        continue;
      }
      addObject(objectId, obj.getType(), 0);
    }
View Full Code Here

      if (cmit.isReuseWalker())
        walker.reset();
      else
        walker = bitmapPreparer.newBitmapWalker();

      BitmapBuilder bitmap = walker.findObjects(
          Collections.singleton(cmit), null);

      if (last != null && cmit.isReuseWalker() && !bitmap.contains(last))
        throw new IllegalStateException(MessageFormat.format(
            JGitText.get().bitmapMissingObject, cmit.name(),
            last.name()));
      last = cmit;
      writeBitmaps.addBitmap(cmit, bitmap.build(), cmit.getFlags());

      pm.update(1);
    }

    endPhase(pm);
View Full Code Here

  }

  BitmapBuilder findObjects(Set<? extends ObjectId> start, BitmapBuilder seen)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();

    for (ObjectId obj : start) {
      Bitmap bitmap = bitmapIndex.getBitmap(obj);
      if (bitmap != null)
        bitmapResult.or(bitmap);
    }

    boolean marked = false;
    for (ObjectId obj : start) {
      if (!bitmapResult.contains(obj)) {
        walker.markStart(walker.parseAny(obj));
        marked = true;
      }
    }

    if (marked) {
      walker.setRevFilter(newRevFilter(seen, bitmapResult));

      while (walker.next() != null) {
        // Iterate through all of the commits. The BitmapRevFilter does
        // the work.
        pm.update(1);
      }

      RevObject ro;
      while ((ro = walker.nextObject()) != null) {
        bitmapResult.add(ro, ro.getType());
        pm.update(1);
      }
    }

    return bitmapResult;
View Full Code Here

        int flags = nextFlg;
        nextIn = nextSelectionDistance(index, cardinality);
        nextFlg = nextIn == maxCommits ? PackBitmapIndex.FLAG_REUSE : 0;
        mustPick = nextIn == 0;

        BitmapBuilder fullBitmap = commitBitmapIndex.newBitmapBuilder();
        rw.reset();
        rw.markStart(c);
        for (AnyObjectId objectId : result.reuse)
          rw.markUninteresting(rw.parseCommit(objectId));
        rw.setRevFilter(
            PackWriterBitmapWalker.newRevFilter(null, fullBitmap));

        while (rw.next() != null) {
          // Work is done in the RevFilter.
        }

        List<List<BitmapCommit>> matches = new ArrayList<
            List<BitmapCommit>>();
        for (List<BitmapCommit> list : running) {
          BitmapCommit last = list.get(list.size() - 1);
          if (fullBitmap.contains(last))
            matches.add(list);
        }

        List<BitmapCommit> match;
        if (matches.isEmpty()) {
View Full Code Here

    return selections;
  }

  private WalkResult findPaths(RevWalk rw, int expectedNumCommits)
      throws MissingObjectException, IOException {
    BitmapBuilder reuseBitmap = commitBitmapIndex.newBitmapBuilder();
    List<BitmapCommit> reuse = new ArrayList<BitmapCommit>();
    for (PackBitmapIndexRemapper.Entry entry : bitmapRemapper) {
      if ((entry.getFlags() & FLAG_REUSE) != FLAG_REUSE)
        continue;

      RevObject ro = rw.peel(rw.parseAny(entry));
      if (ro instanceof RevCommit) {
        RevCommit rc = (RevCommit) ro;
        reuse.add(new BitmapCommit(rc, false, entry.getFlags()));
        rw.markUninteresting(rc);

        EWAHCompressedBitmap bitmap = bitmapRemapper.ofObjectType(
            bitmapRemapper.getBitmap(rc), Constants.OBJ_COMMIT);
        writeBitmaps.addBitmap(rc, bitmap, 0);
        reuseBitmap.add(rc, Constants.OBJ_COMMIT);
      }
    }
    writeBitmaps.clearBitmaps(); // Remove temporary bitmaps

    // Do a RevWalk by commit time descending. Keep track of all the paths
    // from the wants.
    List<BitmapBuilder> paths = new ArrayList<BitmapBuilder>(want.size());
    Set<RevCommit> peeledWant = new HashSet<RevCommit>(want.size());
    for (AnyObjectId objectId : want) {
      RevObject ro = rw.peel(rw.parseAny(objectId));
      if (ro instanceof RevCommit && !reuseBitmap.contains(ro)) {
        RevCommit rc = (RevCommit) ro;
        peeledWant.add(rc);
        rw.markStart(rc);

        BitmapBuilder bitmap = commitBitmapIndex.newBitmapBuilder();
        bitmap.or(reuseBitmap);
        bitmap.add(rc, Constants.OBJ_COMMIT);
        paths.add(bitmap);
      }
    }

    // Update the paths from the wants and create a list of commits in
    // reverse iteration order.
    RevCommit[] commits = new RevCommit[expectedNumCommits];
    int pos = commits.length;
    RevCommit rc;
    while ((rc = rw.next()) != null) {
      commits[--pos] = rc;
      for (BitmapBuilder path : paths) {
        if (path.contains(rc)) {
          for (RevCommit c : rc.getParents())
            path.add(c, Constants.OBJ_COMMIT);
        }
      }

      pm.update(1);
    }

    // Remove the reused bitmaps from the paths
    if (!reuse.isEmpty())
      for (BitmapBuilder bitmap : paths)
        bitmap.andNot(reuseBitmap);

    // Sort the paths
    List<BitmapBuilder> distinctPaths = new ArrayList<BitmapBuilder>(paths.size());
    while (!paths.isEmpty()) {
      Collections.sort(paths, BUILDER_BY_CARDINALITY_DSC);
      BitmapBuilder largest = paths.remove(0);
      distinctPaths.add(largest);

      // Update the remaining paths, by removing the objects from
      // the path that was just added.
      for (int i = paths.size() - 1; i >= 0; i--)
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder

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.