Package javaewah

Examples of javaewah.EWAHCompressedBitmap


          public StoredEntry next() {
            if (!hasNext())
              throw new NoSuchElementException();
            StoredBitmap item = byAddOrder.get(index);
            int bestXorOffset = 0;
            EWAHCompressedBitmap bestBitmap = item.getBitmap();

            // Attempt to compress the bitmap with an XOR of the
            // previously written entries.
            for (int i = 1; i <= MAX_XOR_OFFSET_SEARCH; i++) {
              int curr = i + index;
              if (curr >= byAddOrder.size())
                break;

              StoredBitmap other = byAddOrder.get(curr);
              EWAHCompressedBitmap bitmap = other.getBitmap()
                  .xor(item.getBitmap());

              if (bitmap.sizeInBytes()
                  < bestBitmap.sizeInBytes()) {
                bestBitmap = bitmap;
                bestXorOffset = i;
              }
            }
View Full Code Here


  PackBitmapIndex getPackBitmapIndex() {
    return packIndex;
  }

  public CompressedBitmap getBitmap(AnyObjectId objectId) {
    EWAHCompressedBitmap compressed = packIndex.getBitmap(objectId);
    if (compressed == null)
      return null;
    return new CompressedBitmap(compressed);
  }
View Full Code Here

    }
    return false;
  }

  private static final EWAHCompressedBitmap ones(int sizeInBits) {
    EWAHCompressedBitmap mask = new EWAHCompressedBitmap();
    mask.addStreamOfEmptyWords(
        true, sizeInBits / EWAHCompressedBitmap.wordinbits);
    int remaining = sizeInBits % EWAHCompressedBitmap.wordinbits;
    if (remaining > 0)
      mask.add((1L << remaining) - 1, remaining);
    return mask;
  }
View Full Code Here

    private BitSet toAdd;

    private BitSet toRemove;

    private ComboBitset() {
      this(new EWAHCompressedBitmap());
    }
View Full Code Here

    private ComboBitset(EWAHCompressedBitmap bitmap) {
      this.inflatingBitmap = new InflatingBitSet(bitmap);
    }

    EWAHCompressedBitmap combine() {
      EWAHCompressedBitmap toAddCompressed = null;
      if (toAdd != null) {
        toAddCompressed = toAdd.toEWAHCompressedBitmap();
        toAdd = null;
      }

      EWAHCompressedBitmap toRemoveCompressed = null;
      if (toRemove != null) {
        toRemoveCompressed = toRemove.toEWAHCompressedBitmap();
        toRemove = null;
      }
View Full Code Here

    public boolean removeAllOrNone(PackBitmapIndex index) {
      if (!packIndex.equals(index))
        return false;

      EWAHCompressedBitmap curr = bitset.combine()
          .xor(ones(indexObjectCount));

      IntIterator ii = curr.intIterator();
      if (ii.hasNext() && ii.next() < indexObjectCount)
        return false;
      bitset = new ComboBitset(curr);
      return true;
    }
View Full Code Here

    for (int i = 0; i < (int) numEntries; i++) {
      IO.readFully(fd, scratch, 0, 6);
      int nthObjectId = NB.decodeInt32(scratch, 0);
      int xorOffset = scratch[4];
      int flags = scratch[5];
      EWAHCompressedBitmap bitmap = readBitmap(dataInput);

      if (nthObjectId < 0)
        throw new IOException(MessageFormat.format(
            JGitText.get().invalidId, String.valueOf(nthObjectId)));
      if (xorOffset < 0)
View Full Code Here

    return packIndex;
  }

  private static EWAHCompressedBitmap readBitmap(DataInput dataInput)
      throws IOException {
    EWAHCompressedBitmap bitmap = new EWAHCompressedBitmap();
    bitmap.deserialize(dataInput);
    return bitmap;
  }
View Full Code Here

      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);
View Full Code Here

TOP

Related Classes of javaewah.EWAHCompressedBitmap

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.