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

realm / realm-core / jorgen.edelbo_390

12 Aug 2024 12:13PM UTC coverage: 91.108% (+0.02%) from 91.085%
jorgen.edelbo_390

Pull #7979

Evergreen

jedelbo
Create test file in file-format 24
Pull Request #7979: Create test file in file-format 24

102766 of 181590 branches covered (56.59%)

19 of 19 new or added lines in 1 file covered. (100.0%)

1020 existing lines in 55 files now uncovered.

217365 of 238579 relevant lines covered (91.11%)

5621116.99 hits per line

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

51.11
/src/realm/array_with_find.cpp
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
#include <realm/array_with_find.hpp>
20

21
namespace realm {
22

23
void ArrayWithFind::find_all(IntegerColumn* result, int64_t value, size_t col_offset, size_t begin, size_t end) const
24
{
102✔
25
    REALM_ASSERT_3(begin, <=, m_array.size());
102✔
26
    REALM_ASSERT(end == npos || (begin <= end && end <= m_array.size()));
102✔
27

28
    if (end == npos)
102✔
29
        end = m_array.m_size;
90✔
30

31
    QueryStateFindAll state(*result);
102✔
32
    REALM_TEMPEX2(find_optimized, Equal, m_array.m_width, (value, begin, end, col_offset, &state));
102✔
33

34
    return;
102✔
35
}
102✔
36

37

38
bool ArrayWithFind::find(int cond, int64_t value, size_t start, size_t end, size_t baseindex,
39
                         QueryStateBase* state) const
UNCOV
40
{
×
UNCOV
41
    if (cond == cond_Equal) {
×
UNCOV
42
        return find<Equal>(value, start, end, baseindex, state);
×
UNCOV
43
    }
×
UNCOV
44
    if (cond == cond_NotEqual) {
×
UNCOV
45
        return find<NotEqual>(value, start, end, baseindex, state);
×
UNCOV
46
    }
×
UNCOV
47
    if (cond == cond_Greater) {
×
UNCOV
48
        return find<Greater>(value, start, end, baseindex, state);
×
UNCOV
49
    }
×
UNCOV
50
    if (cond == cond_Less) {
×
UNCOV
51
        return find<Less>(value, start, end, baseindex, state);
×
UNCOV
52
    }
×
UNCOV
53
    if (cond == cond_None) {
×
UNCOV
54
        return find<None>(value, start, end, baseindex, state);
×
UNCOV
55
    }
×
UNCOV
56
    else if (cond == cond_LeftNotNull) {
×
UNCOV
57
        return find<NotNull>(value, start, end, baseindex, state);
×
UNCOV
58
    }
×
UNCOV
59
    REALM_ASSERT_DEBUG(false);
×
UNCOV
60
    return false;
×
UNCOV
61
}
×
62

63
size_t ArrayWithFind::first_set_bit(uint32_t v) const
64
{
43,334,856✔
65
    // (v & -v) is UB when v is INT_MIN
66
    if (int32_t(v) == std::numeric_limits<int32_t>::min())
43,334,856✔
67
        return 31;
963,042✔
68
    static const int MultiplyDeBruijnBitPosition[32] = {0,  1,  28, 2,  29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4,  8,
42,371,814✔
69
                                                        31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6,  11, 5,  10, 9};
42,371,814✔
70
    return MultiplyDeBruijnBitPosition[(uint32_t((v & -int32_t(v)) * 0x077CB531U)) >> 27];
42,371,814✔
71
}
43,334,856✔
72

73
size_t ArrayWithFind::first_set_bit64(int64_t v) const
74
{
18,401,193✔
75
    unsigned int v0 = unsigned(v);
18,401,193✔
76
    if (v0 != 0)
18,401,193✔
77
        return first_set_bit(v0);
17,985,021✔
78
    unsigned int v1 = unsigned(uint64_t(v) >> 32);
416,172✔
79
    return first_set_bit(v1) + 32;
416,172✔
80
}
18,401,193✔
81

82

83
} // namespace realm
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

© 2026 Coveralls, Inc