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

realm / realm-core / github_pull_request_319175

19 May 2025 08:16PM UTC coverage: 91.119% (-0.02%) from 91.143%
github_pull_request_319175

Pull #8082

Evergreen

web-flow
Bump setuptools from 70.0.0 to 78.1.1 in /evergreen/hang_analyzer

Bumps [setuptools](https://github.com/pypa/setuptools) from 70.0.0 to 78.1.1.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](https://github.com/pypa/setuptools/compare/v70.0.0...v78.1.1)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-version: 78.1.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #8082: Bump setuptools from 70.0.0 to 78.1.1 in /evergreen/hang_analyzer

102788 of 181548 branches covered (56.62%)

217441 of 238634 relevant lines covered (91.12%)

5497200.53 hits per line

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

93.08
/src/realm/collection_parent.cpp
1
/*************************************************************************
2
 *
3
 * Copyright 2023 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/collection_parent.hpp>
20
#include "realm/list.hpp"
21
#include "realm/set.hpp"
22
#include "realm/dictionary.hpp"
23
#include "realm/util/overload.hpp"
24

25
#include <random>
26
#include <mutex>
27

28
namespace realm {
29

30
std::ostream& operator<<(std::ostream& ostr, const PathElement& elem)
31
{
220,371✔
32
    if (elem.is_ndx()) {
220,371✔
33
        size_t ndx = elem.get_ndx();
46,386✔
34
        if (ndx == 0) {
46,386✔
35
            ostr << "FIRST";
15,726✔
36
        }
15,726✔
37
        else if (ndx == size_t(-1)) {
30,660✔
38
            ostr << "LAST";
330✔
39
        }
330✔
40
        else {
30,330✔
41
            ostr << elem.get_ndx();
30,330✔
42
        }
30,330✔
43
    }
46,386✔
44
    else if (elem.is_col_key()) {
173,985✔
45
        ostr << elem.get_col_key();
×
46
    }
×
47
    else if (elem.is_key()) {
173,985✔
48
        ostr << "'" << elem.get_key() << "'";
173,841✔
49
    }
173,841✔
50
    else if (elem.is_all()) {
144✔
51
        ostr << '*';
144✔
52
    }
144✔
53

54
    return ostr;
220,371✔
55
}
220,371✔
56

57
std::ostream& operator<<(std::ostream& ostr, const Path& path)
58
{
94,191✔
59
    for (auto& elem : path) {
219,315✔
60
        ostr << '[' << elem << ']';
219,315✔
61
    }
219,315✔
62
    return ostr;
94,191✔
63
}
94,191✔
64

65
bool StablePath::is_prefix_of(const StablePath& other) const noexcept
66
{
10,614✔
67
    if (size() > other.size())
10,614✔
68
        return false;
186✔
69
    return std::equal(begin(), end(), other.begin());
10,428✔
70
}
10,614✔
71

72
/***************************** CollectionParent ******************************/
73

74
CollectionParent::~CollectionParent() {}
5,131,617✔
75

76
void CollectionParent::check_level() const
77
{
101,298✔
78
    if (size_t(m_level) + 1 > s_max_level) {
101,298✔
79
        throw LogicError(ErrorCodes::LimitExceeded, "Max nesting level reached");
6✔
80
    }
6✔
81
}
101,298✔
82

83
template <typename Base, template <typename> typename Collection, typename LinkCol>
84
std::unique_ptr<Base> create_collection(ColKey col_key, uint8_t level)
85
{
470,838✔
86
    bool nullable = col_key.get_attrs().test(col_attr_Nullable);
470,838✔
87
    switch (col_key.get_type()) {
470,838✔
88
        case col_type_Int:
27,060✔
89
            if (nullable)
27,060✔
90
                return std::make_unique<Collection<util::Optional<Int>>>(col_key);
5,514✔
91
            return std::make_unique<Collection<Int>>(col_key);
21,546✔
92
        case col_type_Bool:
9,048✔
93
            if (nullable)
9,048✔
94
                return std::make_unique<Collection<util::Optional<Bool>>>(col_key);
4,704✔
95
            return std::make_unique<Collection<Bool>>(col_key);
4,344✔
96
        case col_type_Float:
9,840✔
97
            if (nullable)
9,840✔
98
                return std::make_unique<Collection<util::Optional<Float>>>(col_key);
5,118✔
99
            return std::make_unique<Collection<Float>>(col_key);
4,722✔
100
        case col_type_Double:
10,098✔
101
            if (nullable)
10,098✔
102
                return std::make_unique<Collection<util::Optional<Double>>>(col_key);
5,118✔
103
            return std::make_unique<Collection<Double>>(col_key);
4,980✔
104
        case col_type_String:
277,152✔
105
            return std::make_unique<Collection<String>>(col_key);
277,152✔
106
        case col_type_Binary:
9,666✔
107
            return std::make_unique<Collection<Binary>>(col_key);
9,666✔
108
        case col_type_Timestamp:
9,762✔
109
            return std::make_unique<Collection<Timestamp>>(col_key);
9,762✔
110
        case col_type_Decimal:
9,348✔
111
            return std::make_unique<Collection<Decimal128>>(col_key);
9,348✔
112
        case col_type_ObjectId:
18,198✔
113
            if (nullable)
18,198✔
114
                return std::make_unique<Collection<util::Optional<ObjectId>>>(col_key);
13,836✔
115
            return std::make_unique<Collection<ObjectId>>(col_key);
4,362✔
116
        case col_type_UUID:
9,090✔
117
            if (nullable)
9,090✔
118
                return std::make_unique<Collection<util::Optional<UUID>>>(col_key);
4,740✔
119
            return std::make_unique<Collection<UUID>>(col_key);
4,350✔
120
        case col_type_TypedLink:
✔
121
            return std::make_unique<Collection<ObjLink>>(col_key);
×
122
        case col_type_Mixed:
16,698✔
123
            return std::make_unique<Collection<Mixed>>(col_key, level + 1);
16,698✔
124
        case col_type_Link:
64,878✔
125
            return std::make_unique<LinkCol>(col_key);
64,878✔
126
        default:
✔
127
            REALM_TERMINATE("Unsupported column type.");
128
    }
470,838✔
129
}
470,838✔
130

131
LstBasePtr CollectionParent::get_listbase_ptr(ColKey col_key, uint8_t level)
132
{
353,019✔
133
    REALM_ASSERT(col_key.get_attrs().test(col_attr_List) || col_key.get_type() == col_type_Mixed);
353,019✔
134
    return create_collection<LstBase, Lst, LnkLst>(col_key, level);
353,019✔
135
}
353,019✔
136

137
SetBasePtr CollectionParent::get_setbase_ptr(ColKey col_key, uint8_t level)
138
{
117,819✔
139
    REALM_ASSERT(col_key.get_attrs().test(col_attr_Set));
117,819✔
140
    return create_collection<SetBase, Set, LnkSet>(col_key, level);
117,819✔
141
}
117,819✔
142

143
CollectionBasePtr CollectionParent::get_collection_ptr(ColKey col_key, uint8_t level)
144
{
127,701✔
145
    if (col_key.is_list()) {
127,701✔
146
        return get_listbase_ptr(col_key, level);
23,631✔
147
    }
23,631✔
148
    else if (col_key.is_set()) {
104,070✔
149
        return get_setbase_ptr(col_key, level);
74,271✔
150
    }
74,271✔
151
    else if (col_key.is_dictionary()) {
29,799✔
152
        return std::make_unique<Dictionary>(col_key, level + 1);
29,799✔
153
    }
29,799✔
154
    return {};
×
155
}
127,701✔
156

157
int64_t CollectionParent::generate_key(size_t sz)
158
{
248,262✔
159
    static std::mt19937 gen32;
248,262✔
160
    static std::mutex mutex;
248,262✔
161

162
    int64_t key;
248,262✔
163
    const std::lock_guard<std::mutex> lock(mutex);
248,262✔
164
    do {
248,646✔
165
        if (sz < 0x10) {
248,646✔
166
            key = int8_t(gen32());
101,268✔
167
        }
101,268✔
168
        else if (sz < 0x1000) {
147,378✔
169
            key = int16_t(gen32());
147,378✔
170
        }
147,378✔
171
        else {
×
172
            key = int32_t(gen32());
×
173
        }
×
174
    } while (key == 0);
248,646✔
175

176
    return key;
248,262✔
177
}
248,262✔
178

179
void CollectionParent::set_key(BPlusTreeMixed& tree, size_t index)
180
{
100,884✔
181
    int64_t key = generate_key(tree.size());
100,884✔
182
    while (tree.find_key(key) != realm::not_found) {
100,989✔
183
        key++;
105✔
184
    }
105✔
185
    tree.set_key(index, key);
100,884✔
186
}
100,884✔
187

188
} // 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

© 2025 Coveralls, Inc