Пример #1
0
  /**
   * Create a new bitmap for the s-step by doing a AND between this bitmap and the bitmap of an
   * item.
   *
   * @param bitmapItem the bitmap of the item used for the S-Step
   * @param sequencesSize the sequence lengths
   * @param lastBitIndex the last bit index
   * @param maxGap
   * @return return the new bitmap
   */
  Bitmap createNewBitmapSStep(
      Bitmap bitmapItem, List<Integer> sequencesSize, int lastBitIndex, int maxGap) {
    // INTERSECTION_COUNT++;

    // create a new bitset that will be use for the new bitmap
    BitSet newBitset = new BitSet(lastBitIndex);
    // create the new bitmap
    Bitmap newBitmap = new Bitmap(newBitset);

    // We do an AND with the bitmap of the item and this bitmap
    for (int bitK = bitmap.nextSetBit(0); bitK >= 0; bitK = bitmap.nextSetBit(bitK + 1)) {

      // find the sid of this bit
      int sid = bitToSID(bitK, sequencesSize);

      // get the last bit for this sid
      int lastBitOfSID = lastBitOfSID(sid, sequencesSize, lastBitIndex);

      boolean match = false;
      for (int bit = bitmapItem.bitmap.nextSetBit(bitK + 1);
          bit >= 0 && bit <= lastBitOfSID && (bit - bitK <= maxGap);
          bit = bitmapItem.bitmap.nextSetBit(bit + 1)) {

        // new
        int tid = bit - sequencesSize.get(sid);

        newBitmap.bitmap.set(bit);

        match = true;

        //				System.out.println();
        //				System.out.println("bit " + bit);
        //				System.out.println("sid " + sid);
        //				System.out.println("seqSize " + sequencesSize.get(sid));
        //				System.out.println("tid " + tid);
        if (firstItemsetID == -1 || tid < firstItemsetID) {
          firstItemsetID = tid;
        }
      }
      if (match) {
        // update the support
        if (sid != newBitmap.lastSID) {
          newBitmap.support++;
          newBitmap.sidsum += sid;
        }
        newBitmap.lastSID = sid;
      }
      bitK = lastBitOfSID; // to skip the bit from the same sequence
    }
    // We return the resulting bitmap
    return newBitmap;
  }
Пример #2
0
  /**
   * Create a new bitmap by performing the I-STEP with this bitmap and the bitmap of an item.
   *
   * @param bitmapItem the bitmap of the item
   * @param sequencesSize the sequence lengths
   * @param lastBitIndex the last bit index
   * @return the new bitmap
   */
  Bitmap createNewBitmapIStep(Bitmap bitmapItem, List<Integer> sequencesSize, int lastBitIndex) {
    // INTERSECTION_COUNT++;

    // We create the new bitmap
    BitSet newBitset = new BitSet(lastBitIndex); // TODO: USE LAST SET BIT
    Bitmap newBitmap = new Bitmap(newBitset);

    // We do an AND with the bitmap of the item
    for (int bit = bitmap.nextSetBit(0); bit >= 0; bit = bitmap.nextSetBit(bit + 1)) {
      if (bitmapItem.bitmap.get(bit)) { // if both bits are TRUE

        // set the bit
        newBitmap.bitmap.set(bit);
        // update the support
        int sid = bitToSID(bit, sequencesSize);

        if (sid != newBitmap.lastSID) {
          newBitmap.sidsum += sid;
          newBitmap.support++;
        }
        newBitmap.lastSID = sid; // remember the last SID

        // new
        int tid = bit - sequencesSize.get(sid);
        if (firstItemsetID == -1 || tid < firstItemsetID) {
          firstItemsetID = tid;
        }
        // end new

      }
    }
    // Then do the AND
    newBitset.and(bitmapItem.bitmap);

    // We return the resulting bitmap
    return newBitmap;
  }