Skip to content

Commit 7753d5d

Browse files
authored
Make assignment of contains Or stick in query builder
* make assignment of contains Or stick in query builder * test for contains or flag fix * take out unused variable * extra tests on contains Or flag
1 parent 412790a commit 7753d5d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

include/helib/partialMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ class QueryBuilder
444444
for (long i = 0; i < long(expr.size()); ++i) { // Each tau
445445
mus[i] = 0; // Set mu to zero.
446446
Matrix<long> M(columns, 1); // Create temp tau matrix
447-
containsOR = (expr[i].size() > 1) ? true : false;
447+
containsOR = (expr[i].size() > 1) ? true : containsOR;
448448
for (long j = 0; j < long(expr[i].size()); ++j) // Each column index
449449
M(expr[i][j], 0) = 1; // Mark those columns as 1
450450
taus.push_back(std::move(M));

tests/TestPartialMatch.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,25 @@ TEST(TestPartialMatch, databaseLookupQueryAPIGeneratesPostFix)
705705
EXPECT_EQ("0 1 2 3 && || &&", res->eval());
706706
}
707707

708+
TEST(TestPartialMatch, containsOrFlagInBuild)
709+
{
710+
const helib::QueryExpr& name = helib::makeQueryExpr(0);
711+
const helib::QueryExpr& age = helib::makeQueryExpr(1);
712+
const helib::QueryExpr& height = helib::makeQueryExpr(2);
713+
long columns = 4;
714+
helib::QueryBuilder res1((name || age) && height);
715+
helib::Query_t query = res1.build(columns);
716+
EXPECT_EQ(query.containsOR, true);
717+
718+
helib::QueryBuilder res2(height && (name || age));
719+
query = res2.build(columns);
720+
EXPECT_EQ(query.containsOR, true);
721+
722+
helib::QueryBuilder res3(height && name && age);
723+
query = res3.build(columns);
724+
EXPECT_EQ(query.containsOR, false);
725+
}
726+
708727
TEST(TestPartialMatch, databaseLookupQueryAPIGeneratesMusAndTaus)
709728
{
710729
const helib::QueryExpr& name = helib::makeQueryExpr(0);

0 commit comments

Comments
 (0)