Skip to content

Commit 7889de7

Browse files
authored
0 and -ve checks for the new inserts only (#152)
1 parent 26aadba commit 7889de7

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

src/sparse/inverted_index.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,27 @@ namespace ndd {
15231523

15241524
size_t ei = 0;
15251525
size_t bi = 0;
1526+
1527+
/**
1528+
* Checks if the incoming block updates have any weights
1529+
* that are 0s or negatives.
1530+
*/
1531+
for (size_t i = 0; i < block_updates.size(); i++) {
1532+
const float update_value = block_updates[i].second;
1533+
if (update_value == 0.0f) {
1534+
LOG_WARN(2227,
1535+
index_id_,
1536+
"addDocumentsBatch received zero value for term "
1537+
<< term_id << "; entry will be treated as deleted");
1538+
} else if (update_value < 0.0f) {
1539+
LOG_WARN(2228,
1540+
index_id_,
1541+
"addDocumentsBatch received negative value " << update_value
1542+
<< " for term " << term_id
1543+
<< "; treating as dead");
1544+
}
1545+
}
1546+
15261547
while (ei < existing.size() && bi < block_updates.size()) {
15271548
ndd::idInt existing_id = existing[ei].doc_id;
15281549
ndd::idInt update_id = block_updates[bi].first;
@@ -1555,17 +1576,6 @@ namespace ndd {
15551576
if (e.value > 0.0f) {
15561577
new_live_in_block++;
15571578
if (e.value > new_block_max) new_block_max = e.value;
1558-
} else if (e.value == 0.0f) {
1559-
LOG_WARN(2227,
1560-
index_id_,
1561-
"addDocumentsBatch received zero value for term "
1562-
<< term_id << "; entry will be treated as deleted");
1563-
} else {
1564-
LOG_WARN(2228,
1565-
index_id_,
1566-
"addDocumentsBatch received negative value " << e.value
1567-
<< " for term " << term_id
1568-
<< "; treating as dead");
15691579
}
15701580
}
15711581

0 commit comments

Comments
 (0)