本文整理汇总了Java中org.roaringbitmap.RoaringBitmap.andNot方法的典型用法代码示例。如果您正苦于以下问题:Java RoaringBitmap.andNot方法的具体用法?Java RoaringBitmap.andNot怎么用?Java RoaringBitmap.andNot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.roaringbitmap.RoaringBitmap
的用法示例。
在下文中一共展示了RoaringBitmap.andNot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: andNot
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Override
public RoaringBitmap andNot(RoaringBitmap original, List<RoaringBitmap> bitmaps) {
if (bitmaps.isEmpty()) {
return copy(original);
} else {
RoaringBitmap container = RoaringBitmap.andNot(original, bitmaps.get(0));
for (int i = 1; i < bitmaps.size(); i++) {
container.andNot(bitmaps.get(i));
if (container.isEmpty()) {
break;
}
}
return container;
}
}
示例2: buildIndexMask
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Override
public RoaringBitmap buildIndexMask(int largestIndex,
MiruInvertedIndex<RoaringBitmap, RoaringBitmap> removalIndex,
BitmapAndLastId<RoaringBitmap> container,
StackBuffer stackBuffer) throws Exception {
RoaringBitmap mask = new RoaringBitmap();
if (largestIndex < 0) {
return mask;
}
mask.flip(0, largestIndex + 1);
if (removalIndex != null) {
if (container == null) {
container = new BitmapAndLastId<>();
}
removalIndex.getIndex(container, stackBuffer);
if (container.isSet()) {
mask.andNot(container.getBitmap());
}
}
return mask;
}
示例3: solve
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
static void solve(RoaringBitmap[] bits, int depth, int bitIndex, RoaringBitmap candidate, boolean[] output, Solution solution) {
RoaringBitmap zero = RoaringBitmap.andNot(candidate, bits[bitIndex]);
RoaringBitmap ones = RoaringBitmap.and(candidate, bits[bitIndex]);
if (bitIndex > 0) {
output[bitIndex] = true;
solve(bits, depth + 1, bitIndex - 1, ones, output, solution);
} else if (!ones.isEmpty()) {
output[bitIndex] = true;
solution.stream(output, ones.getCardinality());
}
if (bitIndex > 0) {
output[bitIndex] = false;
solve(bits, depth + 1, bitIndex - 1, zero, output, solution);
} else if (!zero.isEmpty()) {
output[bitIndex] = false;
solution.stream(output, zero.getCardinality());
}
}
示例4: lookupIds
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
/**
* This function fetches the ids in tag store that match the given query. In the current OpenTSDB
* use case, a typical query consists of a metric name and a set of tag matchers. Currently, we
* can have only one tagMatcher per tag key and a tag matcher is not reused, so we inline the tag
* key and value parsing logic here. If tag matchers in slow path are used among queries, it is
* worth creating a specialized tag matcher class for each match type.
*/
private RoaringBitmap lookupIds(final Query q) {
Predicate<TagMatcher> notTagMatcher =
t -> (t.type == MatchType.NOT_LITERAL_OR || t.type == MatchType.NOT_ILITERAL_OR);
List<TagMatcher> inclusiveTagMatchers =
q.tagMatchers.stream().filter(notTagMatcher.negate()).collect(Collectors.toList());
List<TagMatcher> exclusionTagMatchers =
q.tagMatchers.stream().filter(notTagMatcher).collect(Collectors.toList());
// If no tag filters are specifed, then just match on metric name. If no exclusion tag filters
// are given just match on the included tag filters.
if ((inclusiveTagMatchers.isEmpty() && exclusionTagMatchers.isEmpty())
|| (!inclusiveTagMatchers.isEmpty() && exclusionTagMatchers.isEmpty())) {
return getIncludedIds(q.metricName, inclusiveTagMatchers);
}
// If only exclusion tag matchers are specified, get all the metrics that match the wildcard
// tag and then remove the omit the ones that match the OR query.
// TODO: This case can be slightly faster if there is a function that computes negations.
if (inclusiveTagMatchers.isEmpty() && !exclusionTagMatchers.isEmpty()) {
inclusiveTagMatchers = exclusionTagMatchers.stream()
.map(matcher -> TagMatcher.wildcardMatch(matcher.tag.key, "*"))
.collect(Collectors.toList());
}
// If both included and excluded tag matchers are given, do a difference operation.
RoaringBitmap inclusiveIds = getIncludedIds(q.metricName, inclusiveTagMatchers);
RoaringBitmap excludedIds = getExcludedIds(q.metricName, exclusionTagMatchers);
return RoaringBitmap.andNot(inclusiveIds, excludedIds);
}
示例5: inPlaceAndNot
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Override
public void inPlaceAndNot(RoaringBitmap original, MiruInvertedIndex<RoaringBitmap, RoaringBitmap> not, StackBuffer stackBuffer) throws Exception {
BitmapAndLastId<RoaringBitmap> index = new BitmapAndLastId<>();
not.getIndex(index, stackBuffer);
if (index.isSet()) {
original.andNot(index.getBitmap());
}
}
示例6: andNotTx
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Override
public RoaringBitmap andNotTx(MiruTxIndex<RoaringBitmap> original, List<MiruTxIndex<RoaringBitmap>> not, StackBuffer stackBuffer) throws Exception {
RoaringBitmap container = original.txIndex((bitmap, filer, offset, stackBuffer1) -> {
if (bitmap != null) {
return bitmap;
} else if (filer != null) {
return bitmapFromFiler(filer, offset, stackBuffer1);
} else {
return new RoaringBitmap();
}
}, stackBuffer);
if (container.isEmpty() || not.isEmpty()) {
return container;
}
for (MiruTxIndex<RoaringBitmap> index : not) {
RoaringBitmap andNot = index.txIndex((bitmap, filer, offset, stackBuffer1) -> {
if (bitmap != null) {
return bitmap;
} else if (filer != null) {
return bitmapFromFiler(filer, offset, stackBuffer1);
} else {
return null;
}
}, stackBuffer);
if (andNot != null) {
container.andNot(andNot);
}
if (container.isEmpty()) {
return container;
}
}
return container;
}
示例7: compare
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
/**
* Treating the bitmaps as a bit-sliced index, solve for >=K.
*
* @param acc
* @param K
* @param universeSize
* @return
*/
@Override
public RoaringBitmap compare(RoaringBitmap[] acc, int K, int universeSize) {
int lastBitSlice = acc.length - 1;
// use the O'Neil and Quass
// comparison. (Algo 4.2)
int beGtrThan = K - 1;
RoaringBitmap beq = new RoaringBitmap();
beq.flip(0, universeSize); // all ones bitmap
RoaringBitmap bgt = new RoaringBitmap();
int numberOfLeadingZeroSlices = 32 - (lastBitSlice + 1);
if (Integer.numberOfLeadingZeros(beGtrThan) < numberOfLeadingZeroSlices)
return bgt;
// an improvement is that we can stop as soon as there are only trailing
// ones in the constant.
int finalSlice = 0;
finalSlice = Integer.numberOfTrailingZeros(~beGtrThan); // omitted
// optimization
for (int i = lastBitSlice; i >= finalSlice; --i)
if ((beGtrThan & (1 << i)) != 0)
beq.and(acc[i]);
else {
bgt.or(RoaringBitmap.and(beq, acc[i]));
beq.andNot(acc[i]);
}
return bgt;
}
示例8: andNot
import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Override
public Bitmap andNot(Bitmap other) {
return new RoaringBitmapWrapper(
RoaringBitmap.andNot(bitmap, ((RoaringBitmapWrapper) other).bitmap));
}