summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2023-01-23 21:56:51 +0000
committerArne Juul <arnej@yahooinc.com>2023-01-23 21:56:51 +0000
commit4b6f692bed109678f01b591f1a737f6d74775058 (patch)
tree6ea59d4ca175490d9c1217bf03e11fe7163dce1b
parenta69b9c38acebdbfd8240024601a9e61cc624605a (diff)
* use the sanitize range and check in "andWith" also
* verifyInclusiveStart is not needed now that we do range checks * the unit tests could only work in "/home/balder"
-rw-r--r--searchlib/src/tests/common/bitvector/bitvector_test.cpp13
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvector.cpp19
-rw-r--r--searchlib/src/vespa/searchlib/common/partialbitvector.h2
3 files changed, 13 insertions, 21 deletions
diff --git a/searchlib/src/tests/common/bitvector/bitvector_test.cpp b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
index 9547e162c72..9afc4601801 100644
--- a/searchlib/src/tests/common/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
@@ -304,9 +304,6 @@ TEST("requireThatSequentialOperationsOnPartialWorks")
PartialBitVector after(1000, 1100);
after.setInterval(1000, 1100);
- EXPECT_EXCEPTION(p2.orWith(after), vespalib::IllegalArgumentException,
- "IllegalArgumentException: [717, 919] starts before which is not allowed currently [1000, 1100] at "
- "verifyInclusiveStart in /home/balder/git/vespa/searchlib/src/vespa/searchlib/common/bitvector.cpp:33");
EXPECT_EQUAL(202u, p2.countTrueBits());
}
@@ -365,9 +362,13 @@ verifyNonOverlappingWorksAsZeroPadded(bool clear, Func func) {
BitVector::UP right = createEveryNthBitSet(3, 2000, 100);
EXPECT_EQUAL(CNT, left->countTrueBits());
EXPECT_EQUAL(CNT, right->countTrueBits());
- EXPECT_EXCEPTION(func(*left, *right), vespalib::IllegalArgumentException,
- "IllegalArgumentException: [1000, 1100] starts before which is not allowed currently [2000, 2100] at "
- "verifyInclusiveStart in /home/balder/git/vespa/searchlib/src/vespa/searchlib/common/bitvector.cpp:33");
+ func(*left, *right);
+ EXPECT_EQUAL(clear ? 0 : CNT, left->countTrueBits());
+ EXPECT_EQUAL(CNT, right->countTrueBits());
+ left = createEveryNthBitSet(3, 1000, 100);
+ right = createEveryNthBitSet(3, 2000, 100);
+ EXPECT_EQUAL(CNT, left->countTrueBits());
+ EXPECT_EQUAL(CNT, right->countTrueBits());
func(*right, *left);
EXPECT_EQUAL(CNT, left->countTrueBits());
EXPECT_EQUAL(clear ? 0 : CNT, right->countTrueBits());
diff --git a/searchlib/src/vespa/searchlib/common/bitvector.cpp b/searchlib/src/vespa/searchlib/common/bitvector.cpp
index 19d0e194432..cba3ef4f842 100644
--- a/searchlib/src/vespa/searchlib/common/bitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/bitvector.cpp
@@ -23,17 +23,6 @@ using vespalib::alloc::Alloc;
namespace {
-void verifyInclusiveStart(const search::BitVector & a, const search::BitVector & b) __attribute__((noinline));
-
-void verifyInclusiveStart(const search::BitVector & a, const search::BitVector & b)
-{
- if (a.getStartIndex() < b.getStartIndex()) {
- throw IllegalArgumentException(make_string("[%d, %d] starts before which is not allowed currently [%d, %d]",
- a.getStartIndex(), a.size(), b.getStartIndex(), b.size()),
- VESPA_STRLOC);
- }
-}
-
constexpr size_t MMAP_LIMIT = 256_Mi;
}
@@ -192,7 +181,6 @@ BitVector::countInterval(Range range_in) const
void
BitVector::orWith(const BitVector & right)
{
- verifyInclusiveStart(*this, right);
Range range = sanitize(right.range());
if ( ! range.validNonZero()) return;
@@ -226,7 +214,11 @@ BitVector::repairEnds()
void
BitVector::andWith(const BitVector & right)
{
- verifyInclusiveStart(*this, right);
+ Range range = sanitize(right.range());
+ if ( ! range.validNonZero()) {
+ clear();
+ return;
+ }
uint32_t commonBytes = std::min(getActiveBytes(), numActiveBytes(getStartIndex(), right.size()));
IAccelrated::getAccelerator().andBit(getActiveStart(), right.getWordIndex(getStartIndex()), commonBytes);
@@ -242,7 +234,6 @@ BitVector::andWith(const BitVector & right)
void
BitVector::andNotWith(const BitVector& right)
{
- verifyInclusiveStart(*this, right);
Range range = sanitize(right.range());
if ( ! range.validNonZero()) return;
diff --git a/searchlib/src/vespa/searchlib/common/partialbitvector.h b/searchlib/src/vespa/searchlib/common/partialbitvector.h
index d1baa22f9a1..4fb5c3c0d18 100644
--- a/searchlib/src/vespa/searchlib/common/partialbitvector.h
+++ b/searchlib/src/vespa/searchlib/common/partialbitvector.h
@@ -8,7 +8,7 @@ namespace search {
/**
* search::PartialBitVector is a bitvector that is only represents 1 part
- * of the full space. All operations concerning the whole vector while only
+ * of the full space. All operations concerning the whole vector will only
* be conducted on this smaller area.
*/
class PartialBitVector : public BitVector