protected static int inplaceand(int[] bitmap, IteratingRLW32 i) { int pos = 0; int s; while ((s = i.size()) > 0) { if (pos + s < bitmap.length) { final int L = i.getRunningLength(); if (!i.getRunningBit()) { for (int k = pos; k < pos + L; ++k) bitmap[k] = 0; final int LR = i.getNumberOfLiteralWords(); for (int k = 0; k < LR; ++k) bitmap[pos++] &= i.getLiteralWordAt(k); if (!i.next()) { return pos; int l = i.getRunningLength(); if (pos + l > bitmap.length) { if (!i.getRunningBit()) { for (int k = pos; k < bitmap.length; ++k) bitmap[k] = 0; i.discardFirstWords(howMany); return bitmap.length; if (!i.getRunningBit()) for (int k = pos; k < pos + l; ++k) bitmap[k] = 0; pos += l; for (int k = 0; pos < bitmap.length; ++k)
private void setupForCurrentRunningLengthWord() { this.runningLength = WORD_IN_BITS * this.parent.getRunningLength() + this.position; if (!this.parent.getRunningBit()) { this.position = this.runningLength; } this.wordPosition = 0; this.wordLength = this.parent.getNumberOfLiteralWords(); }
/** * @param i iterator we wish to iterate over * @return the cardinality (number of set bits) corresponding to the * iterator */ public static int cardinality(final IteratingRLW32 i) { int answer = 0; while (true) { if (i.getRunningBit()) answer += i.getRunningLength() * EWAHCompressedBitmap32.WORD_IN_BITS; int il = i.getNumberOfLiteralWords(); for (int k = 0; k < il; ++k) answer += Integer.bitCount(i.getLiteralWordAt(k)); if (!i.next()) break; } return answer; }
/** * Write out the content of the iterator, but as if it were all zeros. * * @param container where we write * @param i the iterator */ protected static void dischargeAsEmpty(final BitmapStorage32 container, final IteratingRLW32 i) { while (i.size() > 0) { container.addStreamOfEmptyWords(false, i.size()); i.next(); } }
private boolean literalHasNext() { while (this.word == 0 && this.wordPosition < this.wordLength) { this.word = this.parent.getLiteralWordAt(this.wordPosition++); this.literalPosition = this.position; this.position += WORD_IN_BITS; } return this.word != 0; } }
/** * @return whether we could find another set bit; don't move if there is * an unprocessed value */ private boolean moveToNext() { while (!runningHasNext() && !literalHasNext()) { if (this.parent.next()) setupForCurrentRunningLengthWord(); else return false; } return true; }
/** * @param i iterator we wish to iterate over * @return the cardinality (number of set bits) corresponding to the * iterator */ public static int cardinality(final IteratingRLW32 i) { int answer = 0; while (true) { if (i.getRunningBit()) answer += i.getRunningLength() * EWAHCompressedBitmap32.WORD_IN_BITS; int il = i.getNumberOfLiteralWords(); for (int k = 0; k < il; ++k) answer += Integer.bitCount(i.getLiteralWordAt(k)); if (!i.next()) break; } return answer; }
private void setupForCurrentRunningLengthWord() { this.runningLength = WORD_IN_BITS * this.parent.getRunningLength() + this.position; if (!this.parent.getRunningBit()) { this.position = this.runningLength; } this.wordPosition = 0; this.wordLength = this.parent.getNumberOfLiteralWords(); }
/** * Write out the content of the iterator, but as if it were all zeros. * * @param container where we write * @param i the iterator */ protected static void dischargeAsEmpty(final BitmapStorage32 container, final IteratingRLW32 i) { while (i.size() > 0) { container.addStreamOfEmptyWords(false, i.size()); i.next(); } }
@Override public EWAHIterator32 next() { this.buffer.clear(); int effective = 0; Iterator<IteratingRLW32> i = this.ll.iterator(); while (i.hasNext()) { IteratingRLW32 rlw = i.next(); if (rlw.size() > 0) { int eff = IteratorAggregation32.inplacexor( this.hardbitmap, rlw); if (eff > effective) effective = eff; } else i.remove(); } for (int k = 0; k < effective; ++k) this.buffer.addWord(this.hardbitmap[k]); Arrays.fill(this.hardbitmap, 0); return this.buffer.getEWAHIterator(); } }
private boolean literalHasNext() { while (this.word == 0 && this.wordPosition < this.wordLength) { this.word = this.parent.getLiteralWordAt(this.wordPosition++); this.literalPosition = this.position; this.position += WORD_IN_BITS; } return this.word != 0; } }
/** * @return whether we could find another set bit; don't move if there is * an unprocessed value */ private boolean moveToNext() { while (!runningHasNext() && !literalHasNext()) { if (this.parent.next()) setupForCurrentRunningLengthWord(); else return false; } return true; }
protected static int inplacexor(int[] bitmap, IteratingRLW32 i) { int pos = 0; int s; while ((s = i.size()) > 0) { if (pos + s < bitmap.length) { final int L = i.getRunningLength(); if (i.getRunningBit()) { for (int k = pos; k < pos + L; ++k) bitmap[k] = ~bitmap[k]; final int LR = i.getNumberOfLiteralWords(); for (int k = 0; k < LR; ++k) bitmap[pos++] ^= i.getLiteralWordAt(k); if (!i.next()) { return pos; int l = i.getRunningLength(); if (pos + l > bitmap.length) { if (i.getRunningBit()) { for (int k = pos; k < bitmap.length; ++k) bitmap[k] = ~bitmap[k]; i.discardFirstWords(howMany); return bitmap.length; if (i.getRunningBit()) for (int k = pos; k < pos + l; ++k) bitmap[k] = ~bitmap[k]; pos += l; for (int k = 0; pos < bitmap.length; ++k)
/** * Turn an iterator into a bitmap * * @param i iterator we wish to materialize * @param c where we write */ public static void materialize(final IteratingRLW32 i, final BitmapStorage32 c) { while (true) { if (i.getRunningLength() > 0) { c.addStreamOfEmptyWords(i.getRunningBit(), i.getRunningLength()); } int il = i.getNumberOfLiteralWords(); for (int k = 0; k < il ; ++k) c.addWord(i.getLiteralWordAt(k)); if (!i.next()) break; } }
protected static int inplacexor(int[] bitmap, IteratingRLW32 i) { int pos = 0; int s; while ((s = i.size()) > 0) { if (pos + s < bitmap.length) { final int L = i.getRunningLength(); if (i.getRunningBit()) { for (int k = pos; k < pos + L; ++k) bitmap[k] = ~bitmap[k]; final int LR = i.getNumberOfLiteralWords(); for (int k = 0; k < LR; ++k) bitmap[pos++] ^= i.getLiteralWordAt(k); if (!i.next()) { return pos; int l = i.getRunningLength(); if (pos + l > bitmap.length) { if (i.getRunningBit()) { for (int k = pos; k < bitmap.length; ++k) bitmap[k] = ~bitmap[k]; i.discardFirstWords(howMany); return bitmap.length; if (i.getRunningBit()) for (int k = pos; k < pos + l; ++k) bitmap[k] = ~bitmap[k]; pos += l; for (int k = 0; pos < bitmap.length; ++k)
/** * Turn an iterator into a bitmap * * @param i iterator we wish to materialize * @param c where we write */ public static void materialize(final IteratingRLW32 i, final BitmapStorage32 c) { while (true) { if (i.getRunningLength() > 0) { c.addStreamOfEmptyWords(i.getRunningBit(), i.getRunningLength()); } int il = i.getNumberOfLiteralWords(); for (int k = 0; k < il ; ++k) c.addWord(i.getLiteralWordAt(k)); if (!i.next()) break; } }
@Override public EWAHIterator32 next() { this.buffer.clear(); int effective = 0; Iterator<IteratingRLW32> i = this.ll.iterator(); while (i.hasNext()) { IteratingRLW32 rlw = i.next(); if (rlw.size() > 0) { int eff = IteratorAggregation32.inplaceor( this.hardBitmap, rlw); if (eff > effective) effective = eff; } else i.remove(); } for (int k = 0; k < effective; ++k) this.buffer.addWord(this.hardBitmap[k]); Arrays.fill(this.hardBitmap, 0); return this.buffer.getEWAHIterator(); } }
protected static int inplaceand(int[] bitmap, IteratingRLW32 i) { int pos = 0; int s; while ((s = i.size()) > 0) { if (pos + s < bitmap.length) { final int L = i.getRunningLength(); if (!i.getRunningBit()) { for (int k = pos; k < pos + L; ++k) bitmap[k] = 0; final int LR = i.getNumberOfLiteralWords(); for (int k = 0; k < LR; ++k) bitmap[pos++] &= i.getLiteralWordAt(k); if (!i.next()) { return pos; int l = i.getRunningLength(); if (pos + l > bitmap.length) { if (!i.getRunningBit()) { for (int k = pos; k < bitmap.length; ++k) bitmap[k] = 0; i.discardFirstWords(howMany); return bitmap.length; if (!i.getRunningBit()) for (int k = pos; k < pos + l; ++k) bitmap[k] = 0; pos += l; for (int k = 0; pos < bitmap.length; ++k)