• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / 1787

28 Oct 2023 12:35PM UTC coverage: 91.591% (+0.009%) from 91.582%
1787

push

Evergreen

web-flow
Improve configurations for sanitized builds (#6911)

* Refactor sanitizer flags for different build types:

** Enable address sanitizer for msvc
** Allow to build with sanitizer for diffent optimized build (also Debug)
** Make RelASAN, RelTSAN, RelUSAN, RelUSAN just shortcuts for half-optimized builds

* Fix usage of moved object for fuzz tester
* Check asan/tsan on macos x64/arm64
* Check asan with msvc 2019
* Remove Jenkins sanitized builders replaced by evergreen configs
* Work-around stack-use-after-scope with msvc2019 and mpark
* Fix crash on check with staled ColKeys
* fix a buffer overrun in a test
* fix a race in async_open_realm test util
* Add some logger related test fixes
* Work around catch2 limmitation with not thread safe asserts and TSAN races
* Run multiprocesses tests under sanitizers
* add assert for an error reported by undefined sanitizer
* Workaround uv scheduler main thread only constraint for callbacks called from non main thread and requesting a realm

---------

Co-authored-by: James Stone <james.stone@mongodb.com>

94356 of 173648 branches covered (0.0%)

54 of 63 new or added lines in 15 files covered. (85.71%)

2202 existing lines in 52 files now uncovered.

230692 of 251872 relevant lines covered (91.59%)

7167285.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.31
/src/realm/array_integer_tpl.hpp
1
/*************************************************************************
2
 *
3
 * Copyright 2021 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#ifndef REALM_ARRAY_INTEGER_TPL_HPP
20
#define REALM_ARRAY_INTEGER_TPL_HPP
21

22
#include <realm/array_integer.hpp>
23
#include <realm/array_with_find.hpp>
24

25
namespace realm {
26

27
template <class cond, class Callback>
28
bool ArrayInteger::find(value_type value, size_t start, size_t end, QueryStateBase* state, Callback callback) const
29
{
4,993,242✔
30
    return ArrayWithFind(*this).find<cond, Callback>(value, start, end, 0, state, callback);
4,993,242✔
31
}
4,993,242✔
32

33
template <class Callback>
34
inline bool ArrayIntNull::find_impl(int cond, value_type value, size_t start, size_t end, QueryStateBase* state,
35
                                    Callback callback) const
36
{
×
37
    switch (cond) {
×
38
        case cond_Equal:
×
39
            return find_impl<Equal>(value, start, end, state, callback);
×
40
        case cond_NotEqual:
×
41
            return find_impl<NotEqual>(value, start, end, state, callback);
×
42
        case cond_Greater:
×
43
            return find_impl<Greater>(value, start, end, state, callback);
×
44
        case cond_Less:
×
45
            return find_impl<Less>(value, start, end, state, callback);
×
46
        case cond_None:
×
47
            return find_impl<None>(value, start, end, state, callback);
×
48
        case cond_LeftNotNull:
×
49
            return find_impl<NotNull>(value, start, end, state, callback);
×
50
    }
×
51
    REALM_ASSERT_DEBUG(false);
×
UNCOV
52
    return false;
×
UNCOV
53
}
×
54

55
template <class cond, class Callback>
56
bool ArrayIntNull::find_impl(value_type opt_value, size_t start, size_t end, QueryStateBase* state,
57
                             Callback callback) const
58
{
232,161✔
59
    int64_t null_value = Array::get(0);
232,161✔
60
    bool find_null = !bool(opt_value);
232,161✔
61
    int64_t value;
232,161✔
62

116,079✔
63
    size_t end2 = (end == npos ? size() : end) + 1;
220,179✔
64
    size_t start2 = start + 1;
232,161✔
65
    size_t baseindex2 = size_t(-1);
232,161✔
66

116,079✔
67
    if constexpr (std::is_same_v<cond, Equal>) {
232,161✔
68
        if (find_null) {
121,449✔
69
            value = null_value;
7,488✔
70
        }
7,488✔
71
        else {
113,961✔
72
            if (*opt_value == null_value) {
113,961✔
73
                // If the value to search for is equal to the null value, the value cannot be in the array
UNCOV
74
                return true;
×
UNCOV
75
            }
×
76
            else {
113,961✔
77
                value = *opt_value;
113,961✔
78
            }
113,961✔
79
        }
113,961✔
80

55,353✔
81
        // Fall back to plain Array find.
55,353✔
82
        return ArrayWithFind(*this).find<cond>(value, start2, end2, baseindex2, state, callback);
121,449✔
83
    }
121,449✔
84
    else {
110,709✔
85
        cond c;
110,709✔
86

55,353✔
87
        if (opt_value) {
110,709✔
88
            value = *opt_value;
89,796✔
89
        }
89,796✔
90
        else {
20,913✔
91
            value = null_value;
20,913✔
92
        }
20,913✔
93

55,353✔
94
        for (size_t i = start2; i < end2; ++i) {
18,490,206!
95
            int64_t v = Array::get(i);
18,416,103✔
96
            bool value_is_null = (v == null_value);
18,416,103✔
97
            if (c(v, value, value_is_null, find_null)) {
18,416,103!
98
                util::Optional<int64_t> v2 = value_is_null ? util::none : util::make_optional(v);
18,380,835!
99
                if (!ArrayWithFind(*this).find_action(i + baseindex2, v2, state, callback)) {
18,380,907✔
100
                    return false; // tell caller to stop aggregating/search
36,606✔
101
                }
36,606✔
102
            }
18,380,907✔
103
        }
18,416,103✔
104
        return true; // tell caller to continue aggregating/search (on next array leafs)
92,406✔
105
    }
110,709✔
106
}
232,161✔
107

108
template <class cond>
109
size_t ArrayIntNull::find_first(value_type value, size_t start, size_t end) const
110
{
85,578✔
111
    QueryStateFindFirst state;
85,578✔
112
    find_impl<cond>(value, start, end, &state, nullptr);
85,578✔
113

42,789✔
114
    if (state.match_count() > 0)
85,578✔
115
        return to_size_t(state.m_state);
48,126✔
116
    else
37,452✔
117
        return not_found;
37,452✔
118
}
85,578✔
119

120
template <class cond, class Callback>
121
inline bool ArrayIntNull::find(value_type value, size_t start, size_t end, QueryStateBase* state,
122
                               Callback callback) const
123
{
146,586✔
124
    return find_impl<cond, Callback>(value, start, end, state, callback);
146,586✔
125
}
146,586✔
126

127
} // namespace realm
128

129
#endif /* REALM_ARRAY_INTEGER_TPL_HPP */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc