journal: respect anchor on non-data-only queries (#16109)
respect anchor on non-data-only queries
Costa Tsaousis committed
Oct 3, 2023 at 15:49 UTC
70ff3991a7d5d52418668b3aff46b50460ec9441
1 file changed
+12
-6
libnetdata/facets/facets.c
+12
-6
@@ -1736,14 +1736,18 @@ void facets_rows_begin(FACETS *facets) {
1736
bool facets_row_finished(FACETS *facets, usec_t usec) {
1737
facets->operations.rows.evaluated++;
1738
1739
- if((facets->query && facets->keys_filtered_by_query && !facets->current_row.keys_matched_by_query) ||
1739
+ if(unlikely((facets->query && facets->keys_filtered_by_query && !facets->current_row.keys_matched_by_query) ||
1740
(facets->timeframe.before_ut && usec > facets->timeframe.before_ut) ||
1741
- (facets->timeframe.after_ut && usec < facets->timeframe.after_ut) ||
1742
- !facets_is_entry_within_anchor(facets, usec) /* this has to be last */) {
1741
+ (facets->timeframe.after_ut && usec < facets->timeframe.after_ut))) {
1742
// this row is not useful
1743
// 1. not matched by full text search, or
1745
- // 2. not in our timeframe, or
1746
- // 3. is not selected by the anchor
1744
+ // 2. not in our timeframe
1745
+ facets_reset_keys_with_value_and_row(facets);
1746
+ return false;
1747
+ }
1748
+
1749
+ bool within_anchor = facets_is_entry_within_anchor(facets, usec);
1750
+ if(unlikely(!within_anchor && (facets->options & FACETS_OPTION_DATA_ONLY))) {
1751
facets_reset_keys_with_value_and_row(facets);
1752
return false;
1753
}
@@ -1798,7 +1802,9 @@ bool facets_row_finished(FACETS *facets, usec_t usec) {
1802
if(selected_keys == total_keys) {
1803
// we need to keep this row
1804
facets_histogram_update_value(facets, usec);
1801
- facets_row_keep(facets, usec);
1805
+
1806
+ if(within_anchor)
1807
+ facets_row_keep(facets, usec);
1808
}
1809
1810
facets_reset_keys_with_value_and_row(facets);