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

realm / realm-core / 2288

01 May 2024 08:17PM UTC coverage: 90.738% (-0.02%) from 90.756%
2288

push

Evergreen

web-flow
[bindgen] fix signature of update_base_url (#7665)

101892 of 180214 branches covered (56.54%)

212458 of 234145 relevant lines covered (90.74%)

5757351.37 hits per line

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

75.87
/src/realm/cluster.cpp
1
/*************************************************************************
2
 *
3
 * Copyright 2016 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/cluster.hpp"
20
#include "realm/array_integer.hpp"
21
#include "realm/array_basic.hpp"
22
#include "realm/array_bool.hpp"
23
#include "realm/array_string.hpp"
24
#include "realm/array_binary.hpp"
25
#include "realm/array_mixed.hpp"
26
#include "realm/array_timestamp.hpp"
27
#include "realm/array_decimal128.hpp"
28
#include "realm/array_fixed_bytes.hpp"
29
#include "realm/array_key.hpp"
30
#include "realm/array_ref.hpp"
31
#include "realm/array_typed_link.hpp"
32
#include "realm/array_backlink.hpp"
33
#include "realm/column_type_traits.hpp"
34
#include "realm/replication.hpp"
35
#include "realm/dictionary.hpp"
36
#include "realm/list.hpp"
37
#include <iostream>
38
#include <cmath>
39

40
namespace realm {
41

42
/******************************* FieldValues *********************************/
43

44
FieldValues::FieldValues(std::initializer_list<FieldValue> init)
45
    : m_values(init)
389,772✔
46
{
800,808✔
47
    if (m_values.size() > 1) {
800,808✔
48
        // Sort according to ColKey index
49
        std::sort(m_values.begin(), m_values.end(), [](const auto& a, const auto& b) {
52,401✔
50
            return a.col_key.get_index().val < b.col_key.get_index().val;
52,401✔
51
        });
52,401✔
52
    }
17,502✔
53
}
800,808✔
54

55
void FieldValues::insert(ColKey k, Mixed val, bool is_default)
56
{
757,293✔
57
    if (m_values.empty()) {
757,293✔
58
        m_values.emplace_back(k, val, is_default);
745,110✔
59
        return;
745,110✔
60
    }
745,110✔
61
    unsigned int idx = k.get_index().val;
12,183✔
62
    auto it = std::lower_bound(m_values.begin(), m_values.end(), idx, [](const auto& a, unsigned int i) {
23,610✔
63
        return a.col_key.get_index().val < i;
23,610✔
64
    });
23,610✔
65
    m_values.insert(it, {k, val, is_default});
12,183✔
66
}
12,183✔
67

68
/******************************* ClusterNode *********************************/
69

70
void ClusterNode::IteratorState::clear()
71
{
2,120,706✔
72
    m_current_leaf.detach();
2,120,706✔
73
    m_key_offset = 0;
2,120,706✔
74
    m_current_index = size_t(-1);
2,120,706✔
75
}
2,120,706✔
76

77
void ClusterNode::IteratorState::init(State& s, ObjKey key)
78
{
55,800✔
79
    m_current_leaf.init(s.mem);
55,800✔
80
    m_current_index = s.index;
55,800✔
81
    m_key_offset = key.value - m_current_leaf.get_key_value(m_current_index);
55,800✔
82
    m_current_leaf.set_offset(m_key_offset);
55,800✔
83
}
55,800✔
84

85
const Table* ClusterNode::get_owning_table() const noexcept
86
{
104,841✔
87
    return m_tree_top.get_owning_table();
104,841✔
88
}
104,841✔
89

90
void ClusterNode::get(ObjKey k, ClusterNode::State& state) const
91
{
104,007,780✔
92
    if (!k || !try_get(k, state)) {
104,008,269✔
93
        throw KeyNotFound(util::format("No object with key '%1' in '%2'", k.value, get_owning_table()->get_name()));
210✔
94
    }
210✔
95
}
104,007,780✔
96

97

98
/********************************* Cluster ***********************************/
99

100
MemRef Cluster::create_empty_cluster(Allocator& alloc)
101
{
272,205✔
102
    Array arr(alloc);
272,205✔
103
    arr.create(Array::type_HasRefs); // Throws
272,205✔
104

105
    arr.add(RefOrTagged::make_tagged(0)); // Compact form
272,205✔
106
    return arr.get_mem();
272,205✔
107
}
272,205✔
108

109

110
template <class T>
111
inline void Cluster::do_create(ColKey col)
112
{
179,862✔
113
    T arr(m_alloc);
179,862✔
114
    arr.create();
179,862✔
115
    auto col_ndx = col.get_index();
179,862✔
116
    arr.set_parent(this, col_ndx.val + s_first_col_index);
179,862✔
117
    arr.update_parent();
179,862✔
118
}
179,862✔
119

120
void Cluster::create()
121
{
95,805✔
122
    Array::create(type_HasRefs, false, s_first_col_index);
95,805✔
123
    Array::set(0, RefOrTagged::make_tagged(0)); // Size = 0
95,805✔
124

125
    auto column_initialize = [this](ColKey col_key) {
186,009✔
126
        auto col_ndx = col_key.get_index();
186,009✔
127
        while (size() <= col_ndx.val + 1)
372,015✔
128
            add(0);
186,006✔
129
        auto type = col_key.get_type();
186,009✔
130
        auto attr = col_key.get_attrs();
186,009✔
131
        if (attr.test(col_attr_Collection)) {
186,009✔
132
            ArrayRef arr(m_alloc);
6,150✔
133
            arr.create();
6,150✔
134
            arr.set_parent(this, col_ndx.val + s_first_col_index);
6,150✔
135
            arr.update_parent();
6,150✔
136
            return IteratorControl::AdvanceToNext;
6,150✔
137
        }
6,150✔
138
        switch (type) {
179,859✔
139
            case col_type_Int:
108,507✔
140
                if (attr.test(col_attr_Nullable)) {
108,507✔
141
                    do_create<ArrayIntNull>(col_key);
7,440✔
142
                }
7,440✔
143
                else {
101,067✔
144
                    do_create<ArrayInteger>(col_key);
101,067✔
145
                }
101,067✔
146
                break;
108,507✔
147
            case col_type_Bool:
687✔
148
                do_create<ArrayBoolNull>(col_key);
687✔
149
                break;
687✔
150
            case col_type_Float:
1,110✔
151
                do_create<ArrayFloatNull>(col_key);
1,110✔
152
                break;
1,110✔
153
            case col_type_Double:
5,790✔
154
                do_create<ArrayDoubleNull>(col_key);
5,790✔
155
                break;
5,790✔
156
            case col_type_String: {
47,178✔
157
                if (m_tree_top.is_string_enum_type(col_ndx)) {
47,178✔
158
                    do_create<ArrayInteger>(col_key);
5,340✔
159
                }
5,340✔
160
                else {
41,838✔
161
                    do_create<ArrayString>(col_key);
41,838✔
162
                }
41,838✔
163
                break;
47,178✔
164
            }
×
165
            case col_type_Binary:
5,280✔
166
                do_create<ArrayBinary>(col_key);
5,280✔
167
                break;
5,280✔
168
            case col_type_Mixed:
72✔
169
                do_create<ArrayMixed>(col_key);
72✔
170
                break;
72✔
171
            case col_type_Timestamp:
2,451✔
172
                do_create<ArrayTimestamp>(col_key);
2,451✔
173
                break;
2,451✔
174
            case col_type_Decimal:
276✔
175
                do_create<ArrayDecimal128>(col_key);
276✔
176
                break;
276✔
177
            case col_type_ObjectId:
2,877✔
178
                do_create<ArrayObjectIdNull>(col_key);
2,877✔
179
                break;
2,877✔
180
            case col_type_UUID:
408✔
181
                do_create<ArrayUUIDNull>(col_key);
408✔
182
                break;
408✔
183
            case col_type_Link:
2,190✔
184
                do_create<ArrayKey>(col_key);
2,190✔
185
                break;
2,190✔
186
            case col_type_TypedLink:
✔
187
                do_create<ArrayTypedLink>(col_key);
×
188
                break;
×
189
            case col_type_BackLink:
3,036✔
190
                do_create<ArrayBacklink>(col_key);
3,036✔
191
                break;
3,036✔
192
            default:
✔
193
                REALM_UNREACHABLE();
194
        }
179,859✔
195
        return IteratorControl::AdvanceToNext;
179,862✔
196
    };
179,859✔
197
    m_tree_top.m_owner->for_each_and_every_column(column_initialize);
95,805✔
198

199
    // By specifying the minimum size, we ensure that the array has a capacity
200
    // to hold m_size 64 bit refs.
201
    ensure_size(m_size * 8);
95,805✔
202
    // "ensure_size" may COW, but as array is just created, it has no parents, so
203
    // failing to update parent is not an error.
204
    clear_missing_parent_update();
95,805✔
205
}
95,805✔
206

207
void Cluster::init(MemRef mem)
208
{
203,839,200✔
209
    Array::init_from_mem(mem);
203,839,200✔
210
    auto rot = Array::get_as_ref_or_tagged(0);
203,839,200✔
211
    if (rot.is_tagged()) {
203,839,200✔
212
        m_keys.detach();
142,364,892✔
213
    }
142,364,892✔
214
    else {
61,474,308✔
215
        m_keys.init_from_ref(rot.get_as_ref());
61,474,308✔
216
    }
61,474,308✔
217
}
203,839,200✔
218

219
void Cluster::update_from_parent() noexcept
220
{
624,414✔
221
    Array::update_from_parent();
624,414✔
222
    auto rot = Array::get_as_ref_or_tagged(0);
624,414✔
223
    if (!rot.is_tagged()) {
624,414✔
224
        m_keys.update_from_parent();
24,264✔
225
    }
24,264✔
226
}
624,414✔
227

228
MemRef Cluster::ensure_writeable(ObjKey)
229
{
×
230
    // By specifying the minimum size, we ensure that the array has a capacity
231
    // to hold m_size 64 bit refs.
232
    copy_on_write(8 * m_size);
×
233

234
    return get_mem();
×
235
}
×
236

237
void Cluster::update_ref_in_parent(ObjKey, ref_type)
238
{
×
239
    REALM_UNREACHABLE();
240
}
×
241

242
size_t Cluster::node_size_from_header(Allocator& alloc, const char* header)
243
{
71,032,587✔
244
    auto rot = Array::get_as_ref_or_tagged(header, s_key_ref_or_size_index);
71,032,587✔
245
    if (rot.is_tagged()) {
71,037,465✔
246
        return size_t(rot.get_as_int());
70,857,057✔
247
    }
70,857,057✔
248
    else {
2,147,664,055✔
249
        return Array::get_size_from_header(alloc.translate(rot.get_as_ref()));
2,147,664,055✔
250
    }
2,147,664,055✔
251
}
71,032,587✔
252

253
template <class T>
254
inline void Cluster::set_spec(T&, ColKey::Idx) const
255
{
36,526,869✔
256
}
36,526,869✔
257

258
template <>
259
inline void Cluster::set_spec(ArrayString& arr, ColKey::Idx col_ndx) const
260
{
3,137,841✔
261
    m_tree_top.set_spec(arr, col_ndx);
3,137,841✔
262
}
3,137,841✔
263

264
template <class T>
265
inline void Cluster::do_insert_row(size_t ndx, ColKey col, Mixed init_val, bool nullable)
266
{
32,472,420✔
267
    using U = typename util::RemoveOptional<typename T::value_type>::type;
32,472,420✔
268

269
    T arr(m_alloc);
32,472,420✔
270
    auto col_ndx = col.get_index();
32,472,420✔
271
    arr.set_parent(this, col_ndx.val + s_first_col_index);
32,472,420✔
272
    set_spec<T>(arr, col_ndx);
32,472,420✔
273
    arr.init_from_parent();
32,472,420✔
274
    if (init_val.is_null()) {
32,472,420✔
275
        arr.insert(ndx, T::default_value(nullable));
31,594,164✔
276
    }
31,594,164✔
277
    else {
878,256✔
278
        arr.insert(ndx, init_val.get<U>());
878,256✔
279
    }
878,256✔
280
}
32,472,420✔
281

282
inline void Cluster::do_insert_key(size_t ndx, ColKey col_key, Mixed init_val, ObjKey origin_key)
283
{
260,544✔
284
    ObjKey target_key = init_val.is_null() ? ObjKey{} : init_val.get<ObjKey>();
260,544✔
285
    ArrayKey arr(m_alloc);
260,544✔
286
    auto col_ndx = col_key.get_index();
260,544✔
287
    arr.set_parent(this, col_ndx.val + s_first_col_index);
260,544✔
288
    arr.init_from_parent();
260,544✔
289
    arr.insert(ndx, target_key);
260,544✔
290

291
    // Insert backlink if link is not null
292
    if (target_key) {
260,544✔
293
        const Table* origin_table = m_tree_top.get_owning_table();
12✔
294
        ColKey opp_col = origin_table->get_opposite_column(col_key);
12✔
295
        TableRef opp_table = origin_table->get_opposite_table(col_key);
12✔
296
        Obj target_obj = opp_table->get_object(target_key);
12✔
297
        target_obj.add_backlink(opp_col, origin_key);
12✔
298
    }
12✔
299
}
260,544✔
300

301
inline void Cluster::do_insert_mixed(size_t ndx, ColKey col_key, Mixed init_value, ObjKey origin_key)
302
{
19,272✔
303
    ArrayMixed arr(m_alloc);
19,272✔
304
    arr.set_parent(this, col_key.get_index().val + s_first_col_index);
19,272✔
305
    arr.init_from_parent();
19,272✔
306
    arr.insert(ndx, init_value);
19,272✔
307

308
    // Insert backlink if needed
309
    if (init_value.is_type(type_TypedLink)) {
19,272✔
310
        // In case we are inserting in a Dictionary cluster, the backlink will
311
        // be handled in Dictionary::insert function
312
        if (Table* origin_table = const_cast<Table*>(m_tree_top.get_owning_table())) {
24✔
313
            if (origin_table->is_asymmetric()) {
24✔
314
                throw IllegalOperation("Object value not supported in asymmetric table");
6✔
315
            }
6✔
316
            ObjLink link = init_value.get<ObjLink>();
18✔
317
            auto target_table = origin_table->get_parent_group()->get_table(link.get_table_key());
18✔
318
            if (target_table->is_asymmetric()) {
18✔
319
                throw IllegalOperation("Ephemeral object value not supported");
6✔
320
            }
6✔
321
            ColKey backlink_col_key = target_table->find_or_add_backlink_column(col_key, origin_table->get_key());
12✔
322
            target_table->get_object(link.get_obj_key()).add_backlink(backlink_col_key, origin_key);
12✔
323
        }
12✔
324
    }
24✔
325
}
19,272✔
326

327
inline void Cluster::do_insert_link(size_t ndx, ColKey col_key, Mixed init_val, ObjKey origin_key)
328
{
×
329
    ObjLink target_link = init_val.is_null() ? ObjLink{} : init_val.get<ObjLink>();
×
330
    ArrayTypedLink arr(m_alloc);
×
331
    auto col_ndx = col_key.get_index();
×
332
    arr.set_parent(this, col_ndx.val + s_first_col_index);
×
333
    arr.init_from_parent();
×
334
    arr.insert(ndx, target_link);
×
335

336
    // Insert backlink if link is not null
337
    if (target_link) {
×
338
        Table* origin_table = const_cast<Table*>(m_tree_top.get_owning_table());
×
339
        auto target_table = origin_table->get_parent_group()->get_table(target_link.get_table_key());
×
340

341
        ColKey backlink_col_key = target_table->find_or_add_backlink_column(col_key, origin_table->get_key());
×
342
        target_table->get_object(target_link.get_obj_key()).add_backlink(backlink_col_key, origin_key);
×
343
    }
×
344
}
×
345

346
void Cluster::insert_row(size_t ndx, ObjKey k, const FieldValues& init_values)
347
{
23,419,410✔
348
    // Ensure the cluster array is big enough to hold 64 bit values.
349
    copy_on_write(m_size * 8);
23,419,410✔
350

351
    if (m_keys.is_attached()) {
23,419,410✔
352
        m_keys.insert(ndx, k.value);
1,584,561✔
353
    }
1,584,561✔
354
    else {
21,834,849✔
355
        Array::set(s_key_ref_or_size_index, Array::get(s_key_ref_or_size_index) + 2); // Increments size by 1
21,834,849✔
356
    }
21,834,849✔
357

358
    auto val = init_values.begin();
23,419,410✔
359
    auto insert_in_column = [&](ColKey col_key) {
34,330,449✔
360
        auto col_ndx = col_key.get_index();
34,330,449✔
361
        auto attr = col_key.get_attrs();
34,330,449✔
362
        Mixed init_value;
34,330,449✔
363
        // init_values must be sorted in col_ndx order - this is ensured by ClustTree::insert()
364
        if (val != init_values.end() && val->col_key.get_index().val == col_ndx.val) {
34,330,449✔
365
            init_value = val->value;
822,777✔
366
            ++val;
822,777✔
367
        }
822,777✔
368

369
        auto type = col_key.get_type();
34,330,449✔
370
        if (attr.test(col_attr_Collection)) {
34,330,449✔
371
            REALM_ASSERT(init_value.is_null());
675,765✔
372
            ArrayRef arr(m_alloc);
675,765✔
373
            arr.set_parent(this, col_ndx.val + s_first_col_index);
675,765✔
374
            arr.init_from_parent();
675,765✔
375
            arr.insert(ndx, 0);
675,765✔
376
            return IteratorControl::AdvanceToNext;
675,765✔
377
        }
675,765✔
378

379
        bool nullable = attr.test(col_attr_Nullable);
33,654,684✔
380
        switch (type) {
33,654,684✔
381
            case col_type_Int:
25,604,739✔
382
                if (attr.test(col_attr_Nullable)) {
25,604,739✔
383
                    do_insert_row<ArrayIntNull>(ndx, col_key, init_value, nullable);
1,378,884✔
384
                }
1,378,884✔
385
                else {
24,225,855✔
386
                    do_insert_row<ArrayInteger>(ndx, col_key, init_value, nullable);
24,225,855✔
387
                }
24,225,855✔
388
                break;
25,604,739✔
389
            case col_type_Bool:
186,780✔
390
                do_insert_row<ArrayBoolNull>(ndx, col_key, init_value, nullable);
186,780✔
391
                break;
186,780✔
392
            case col_type_Float:
323,994✔
393
                do_insert_row<ArrayFloatNull>(ndx, col_key, init_value, nullable);
323,994✔
394
                break;
323,994✔
395
            case col_type_Double:
1,493,730✔
396
                do_insert_row<ArrayDoubleNull>(ndx, col_key, init_value, nullable);
1,493,730✔
397
                break;
1,493,730✔
398
            case col_type_String:
2,909,358✔
399
                do_insert_row<ArrayString>(ndx, col_key, init_value, nullable);
2,909,358✔
400
                break;
2,909,358✔
401
            case col_type_Binary:
1,364,196✔
402
                do_insert_row<ArrayBinary>(ndx, col_key, init_value, nullable);
1,364,196✔
403
                break;
1,364,196✔
404
            case col_type_Mixed: {
19,272✔
405
                do_insert_mixed(ndx, col_key, init_value, ObjKey(k.value + get_offset()));
19,272✔
406
                break;
19,272✔
407
            }
×
408
            case col_type_Timestamp:
224,286✔
409
                do_insert_row<ArrayTimestamp>(ndx, col_key, init_value, nullable);
224,286✔
410
                break;
224,286✔
411
            case col_type_Decimal:
78,222✔
412
                do_insert_row<ArrayDecimal128>(ndx, col_key, init_value, nullable);
78,222✔
413
                break;
78,222✔
414
            case col_type_ObjectId:
172,188✔
415
                do_insert_row<ArrayObjectIdNull>(ndx, col_key, init_value, nullable);
172,188✔
416
                break;
172,188✔
417
            case col_type_UUID:
119,652✔
418
                do_insert_row<ArrayUUIDNull>(ndx, col_key, init_value, nullable);
119,652✔
419
                break;
119,652✔
420
            case col_type_Link:
260,544✔
421
                do_insert_key(ndx, col_key, init_value, ObjKey(k.value + get_offset()));
260,544✔
422
                break;
260,544✔
423
            case col_type_TypedLink:
✔
424
                do_insert_link(ndx, col_key, init_value, ObjKey(k.value + get_offset()));
×
425
                break;
×
426
            case col_type_BackLink: {
964,605✔
427
                ArrayBacklink arr(m_alloc);
964,605✔
428
                arr.set_parent(this, col_ndx.val + s_first_col_index);
964,605✔
429
                arr.init_from_parent();
964,605✔
430
                arr.insert(ndx, 0);
964,605✔
431
                break;
964,605✔
432
            }
×
433
            default:
✔
434
                REALM_ASSERT(false);
×
435
                break;
×
436
        }
33,654,684✔
437
        return IteratorControl::AdvanceToNext;
33,607,938✔
438
    };
33,654,684✔
439
    m_tree_top.m_owner->for_each_and_every_column(insert_in_column);
23,419,410✔
440
}
23,419,410✔
441

442
template <class T>
443
inline void Cluster::do_move(size_t ndx, ColKey col_key, Cluster* to)
444
{
21,702✔
445
    auto col_ndx = col_key.get_index().val + s_first_col_index;
21,702✔
446
    T src(m_alloc);
21,702✔
447
    src.set_parent(this, col_ndx);
21,702✔
448
    src.init_from_parent();
21,702✔
449

450
    T dst(m_alloc);
21,702✔
451
    dst.set_parent(to, col_ndx);
21,702✔
452
    dst.init_from_parent();
21,702✔
453

454
    src.move(dst, ndx);
21,702✔
455
}
21,702✔
456

457
void Cluster::move(size_t ndx, ClusterNode* new_node, int64_t offset)
458
{
11,421✔
459
    auto new_leaf = static_cast<Cluster*>(new_node);
11,421✔
460

461
    auto move_from_column = [&](ColKey col_key) {
21,702✔
462
        auto attr = col_key.get_attrs();
21,702✔
463
        auto type = col_key.get_type();
21,702✔
464

465
        if (attr.test(col_attr_Collection)) {
21,702✔
466
            do_move<ArrayRef>(ndx, col_key, new_leaf);
30✔
467
            return IteratorControl::AdvanceToNext;
30✔
468
        }
30✔
469

470
        switch (type) {
21,672✔
471
            case col_type_Int:
20,802✔
472
                if (attr.test(col_attr_Nullable)) {
20,802✔
473
                    do_move<ArrayIntNull>(ndx, col_key, new_leaf);
9,399✔
474
                }
9,399✔
475
                else {
11,403✔
476
                    do_move<ArrayInteger>(ndx, col_key, new_leaf);
11,403✔
477
                }
11,403✔
478
                break;
20,802✔
479
            case col_type_Bool:
36✔
480
                do_move<ArrayBoolNull>(ndx, col_key, new_leaf);
36✔
481
                break;
36✔
482
            case col_type_Float:
36✔
483
                do_move<ArrayFloat>(ndx, col_key, new_leaf);
36✔
484
                break;
36✔
485
            case col_type_Double:
36✔
486
                do_move<ArrayDouble>(ndx, col_key, new_leaf);
36✔
487
                break;
36✔
488
            case col_type_String: {
36✔
489
                if (m_tree_top.is_string_enum_type(col_key.get_index()))
36✔
490
                    do_move<ArrayInteger>(ndx, col_key, new_leaf);
×
491
                else
36✔
492
                    do_move<ArrayString>(ndx, col_key, new_leaf);
36✔
493
                break;
36✔
494
            }
×
495
            case col_type_Binary:
36✔
496
                do_move<ArrayBinary>(ndx, col_key, new_leaf);
36✔
497
                break;
36✔
498
            case col_type_Mixed:
✔
499
                do_move<ArrayMixed>(ndx, col_key, new_leaf);
×
500
                break;
×
501
            case col_type_Timestamp:
36✔
502
                do_move<ArrayTimestamp>(ndx, col_key, new_leaf);
36✔
503
                break;
36✔
504
            case col_type_Decimal:
36✔
505
                do_move<ArrayDecimal128>(ndx, col_key, new_leaf);
36✔
506
                break;
36✔
507
            case col_type_ObjectId:
36✔
508
                do_move<ArrayObjectIdNull>(ndx, col_key, new_leaf);
36✔
509
                break;
36✔
510
            case col_type_UUID:
120✔
511
                do_move<ArrayUUIDNull>(ndx, col_key, new_leaf);
120✔
512
                break;
120✔
513
            case col_type_Link:
6✔
514
                do_move<ArrayKey>(ndx, col_key, new_leaf);
6✔
515
                break;
6✔
516
            case col_type_TypedLink:
✔
517
                do_move<ArrayTypedLink>(ndx, col_key, new_leaf);
×
518
                break;
×
519
            case col_type_BackLink:
456✔
520
                do_move<ArrayBacklink>(ndx, col_key, new_leaf);
456✔
521
                break;
456✔
522
            default:
✔
523
                REALM_ASSERT(false);
×
524
                break;
×
525
        }
21,672✔
526
        return IteratorControl::AdvanceToNext;
21,672✔
527
    };
21,672✔
528
    m_tree_top.m_owner->for_each_and_every_column(move_from_column);
11,421✔
529
    for (size_t i = ndx; i < m_keys.size(); i++) {
1,222,710✔
530
        new_leaf->m_keys.add(m_keys.get(i) - offset);
1,211,289✔
531
    }
1,211,289✔
532
    m_keys.truncate(ndx);
11,421✔
533
}
11,421✔
534

535
Cluster::~Cluster() {}
209,176,083✔
536

537
ColKey Cluster::get_col_key(size_t ndx_in_parent) const
538
{
18,654✔
539
    ColKey::Idx col_ndx{unsigned(ndx_in_parent - 1)}; // <- leaf_index here. Opaque.
18,654✔
540
    auto col_key = get_owning_table()->leaf_ndx2colkey(col_ndx);
18,654✔
541
    REALM_ASSERT(col_key.get_index().val == col_ndx.val);
18,654✔
542
    return col_key;
18,654✔
543
}
18,654✔
544

545
void Cluster::ensure_general_form()
546
{
61,446✔
547
    if (!m_keys.is_attached()) {
61,446✔
548
        size_t current_size = get_size_in_compact_form();
48,234✔
549
        m_keys.create(current_size, 255);
48,234✔
550
        m_keys.update_parent();
48,234✔
551
        for (size_t i = 0; i < current_size; i++) {
5,513,148✔
552
            m_keys.set(i, i);
5,464,914✔
553
        }
5,464,914✔
554
    }
48,234✔
555
}
61,446✔
556

557
template <class T>
558
inline void Cluster::do_insert_column(ColKey col_key, bool nullable)
559
{
558,417✔
560
    size_t sz = node_size();
558,417✔
561

562
    T arr(m_alloc);
558,417✔
563
    arr.create();
558,417✔
564
    auto val = T::default_value(nullable);
558,417✔
565
    for (size_t i = 0; i < sz; i++) {
6,790,497✔
566
        arr.add(val);
6,232,080✔
567
    }
6,232,080✔
568
    auto col_ndx = col_key.get_index();
558,417✔
569
    unsigned ndx = col_ndx.val + s_first_col_index;
558,417✔
570

571
    // Fill up if indexes are not consecutive
572
    while (size() < ndx)
558,417✔
573
        Array::add(0);
×
574

575
    if (ndx == size())
558,417✔
576
        Array::insert(ndx, from_ref(arr.get_ref()));
558,327✔
577
    else
90✔
578
        Array::set(ndx, from_ref(arr.get_ref()));
90✔
579
}
558,417✔
580

581
void Cluster::insert_column(ColKey col_key)
582
{
750,618✔
583
    auto attr = col_key.get_attrs();
750,618✔
584
    auto type = col_key.get_type();
750,618✔
585
    if (attr.test(col_attr_Collection)) {
750,618✔
586
        size_t sz = node_size();
192,201✔
587

588
        ArrayRef arr(m_alloc);
192,201✔
589
        arr.create(sz);
192,201✔
590
        auto col_ndx = col_key.get_index();
192,201✔
591
        unsigned idx = col_ndx.val + s_first_col_index;
192,201✔
592
        if (idx == size())
192,201✔
593
            Array::insert(idx, from_ref(arr.get_ref()));
192,201✔
594
        else
×
595
            Array::set(idx, from_ref(arr.get_ref()));
×
596
        return;
192,201✔
597
    }
192,201✔
598
    bool nullable = attr.test(col_attr_Nullable);
558,417✔
599
    switch (type) {
558,417✔
600
        case col_type_Int:
249,651✔
601
            if (nullable) {
249,651✔
602
                do_insert_column<ArrayIntNull>(col_key, nullable);
21,279✔
603
            }
21,279✔
604
            else {
228,372✔
605
                do_insert_column<ArrayInteger>(col_key, nullable);
228,372✔
606
            }
228,372✔
607
            break;
249,651✔
608
        case col_type_Bool:
5,484✔
609
            do_insert_column<ArrayBoolNull>(col_key, nullable);
5,484✔
610
            break;
5,484✔
611
        case col_type_Float:
6,444✔
612
            do_insert_column<ArrayFloatNull>(col_key, nullable);
6,444✔
613
            break;
6,444✔
614
        case col_type_Double:
7,080✔
615
            do_insert_column<ArrayDoubleNull>(col_key, nullable);
7,080✔
616
            break;
7,080✔
617
        case col_type_String:
78,825✔
618
            do_insert_column<ArrayString>(col_key, nullable);
78,825✔
619
            break;
78,825✔
620
        case col_type_Binary:
6,870✔
621
            do_insert_column<ArrayBinary>(col_key, nullable);
6,870✔
622
            break;
6,870✔
623
        case col_type_Mixed:
6,924✔
624
            do_insert_column<ArrayMixed>(col_key, nullable);
6,924✔
625
            break;
6,924✔
626
        case col_type_Timestamp:
23,181✔
627
            do_insert_column<ArrayTimestamp>(col_key, nullable);
23,181✔
628
            break;
23,181✔
629
        case col_type_Decimal:
5,022✔
630
            do_insert_column<ArrayDecimal128>(col_key, nullable);
5,022✔
631
            break;
5,022✔
632
        case col_type_ObjectId:
48,807✔
633
            do_insert_column<ArrayObjectIdNull>(col_key, nullable);
48,807✔
634
            break;
48,807✔
635
        case col_type_UUID:
5,616✔
636
            do_insert_column<ArrayUUIDNull>(col_key, nullable);
5,616✔
637
            break;
5,616✔
638
        case col_type_Link:
31,035✔
639
            do_insert_column<ArrayKey>(col_key, nullable);
31,035✔
640
            break;
31,035✔
641
        case col_type_TypedLink:
✔
642
            do_insert_column<ArrayTypedLink>(col_key, nullable);
×
643
            break;
×
644
        case col_type_BackLink:
83,478✔
645
            do_insert_column<ArrayBacklink>(col_key, nullable);
83,478✔
646
            break;
83,478✔
647
        default:
✔
648
            REALM_UNREACHABLE();
649
            break;
×
650
    }
558,417✔
651
}
558,417✔
652

653
void Cluster::remove_column(ColKey col_key)
654
{
6,321✔
655
    auto col_ndx = col_key.get_index();
6,321✔
656
    unsigned idx = col_ndx.val + s_first_col_index;
6,321✔
657
    ref_type ref = to_ref(Array::get(idx));
6,321✔
658
    if (ref != 0) {
6,321✔
659
        Array::destroy_deep(ref, m_alloc);
6,321✔
660
    }
6,321✔
661
    if (idx == size() - 1)
6,321✔
662
        Array::erase(idx);
4,773✔
663
    else
1,548✔
664
        Array::set(idx, 0);
1,548✔
665
}
6,321✔
666

667
ref_type Cluster::insert(ObjKey k, const FieldValues& init_values, ClusterNode::State& state)
668
{
23,391,663✔
669
    int64_t current_key_value = -1;
23,391,663✔
670
    size_t sz;
23,391,663✔
671
    size_t ndx;
23,391,663✔
672
    ref_type ret = 0;
23,391,663✔
673

674
    auto on_error = [&] {
23,391,663✔
675
        throw KeyAlreadyUsed(
18✔
676
            util::format("When inserting key '%1' in '%2'", k.value, get_owning_table()->get_name()));
18✔
677
    };
18✔
678

679
    if (m_keys.is_attached()) {
23,391,663✔
680
        sz = m_keys.size();
1,573,206✔
681
        ndx = m_keys.lower_bound(uint64_t(k.value));
1,573,206✔
682
        if (ndx < sz) {
1,573,206✔
683
            current_key_value = m_keys.get(ndx);
616,752✔
684
            if (k.value == current_key_value) {
616,752✔
685
                on_error();
18✔
686
            }
18✔
687
        }
616,752✔
688
    }
1,573,206✔
689
    else {
21,818,457✔
690
        sz = size_t(Array::get(s_key_ref_or_size_index)) >> 1; // Size is stored as tagged integer
21,818,457✔
691
        if (uint64_t(k.value) < sz) {
21,818,457✔
692
            on_error();
×
693
        }
×
694
        // Key value is bigger than all other values, should be put last
695
        ndx = sz;
21,818,457✔
696
        if (uint64_t(k.value) > sz && sz < cluster_node_size) {
21,818,457✔
697
            ensure_general_form();
16,971✔
698
        }
16,971✔
699
    }
21,818,457✔
700

701
    REALM_ASSERT_DEBUG(sz <= cluster_node_size);
23,391,663✔
702
    if (REALM_LIKELY(sz < cluster_node_size)) {
23,391,663✔
703
        insert_row(ndx, k, init_values); // Throws
23,321,835✔
704
        state.mem = get_mem();
23,321,835✔
705
        state.index = ndx;
23,321,835✔
706
    }
23,321,835✔
707
    else {
69,828✔
708
        // Split leaf node
709
        Cluster new_leaf(0, m_alloc, m_tree_top);
69,828✔
710
        new_leaf.create();
69,828✔
711
        if (ndx == sz) {
85,086✔
712
            new_leaf.insert_row(0, ObjKey(0), init_values); // Throws
85,086✔
713
            state.split_key = k.value;
85,086✔
714
            state.mem = new_leaf.get_mem();
85,086✔
715
            state.index = 0;
85,086✔
716
        }
85,086✔
717
        else {
4,294,967,294✔
718
            // Current cluster must be in general form to get here
719
            REALM_ASSERT_DEBUG(m_keys.is_attached());
4,294,967,294✔
720
            new_leaf.ensure_general_form();
4,294,967,294✔
721
            move(ndx, &new_leaf, current_key_value);
4,294,967,294✔
722
            insert_row(ndx, k, init_values); // Throws
4,294,967,294✔
723
            state.mem = get_mem();
4,294,967,294✔
724
            state.split_key = current_key_value;
4,294,967,294✔
725
            state.index = ndx;
4,294,967,294✔
726
        }
4,294,967,294✔
727
        ret = new_leaf.get_ref();
69,828✔
728
    }
69,828✔
729

730
    return ret;
23,391,663✔
731
}
23,391,663✔
732

733
bool Cluster::try_get(ObjKey k, ClusterNode::State& state) const noexcept
734
{
156,704,172✔
735
    state.mem = get_mem();
156,704,172✔
736
    if (m_keys.is_attached()) {
156,704,172✔
737
        state.index = m_keys.lower_bound(uint64_t(k.value));
50,181,054✔
738
        return state.index != m_keys.size() && m_keys.get(state.index) == uint64_t(k.value);
50,181,054✔
739
    }
50,181,054✔
740
    else {
106,523,118✔
741
        if (uint64_t(k.value) < uint64_t(Array::get(s_key_ref_or_size_index) >> 1)) {
106,523,118✔
742
            state.index = size_t(k.value);
88,583,979✔
743
            return true;
88,583,979✔
744
        }
88,583,979✔
745
    }
106,523,118✔
746
    return false;
17,939,139✔
747
}
156,704,172✔
748

749
ObjKey Cluster::get(size_t ndx, ClusterNode::State& state) const
750
{
11,442,285✔
751
    state.index = ndx;
11,442,285✔
752
    state.mem = get_mem();
11,442,285✔
753
    return get_real_key(ndx);
11,442,285✔
754
}
11,442,285✔
755

756
template <class T>
757
inline void Cluster::do_erase(size_t ndx, ColKey col_key)
758
{
6,604,899✔
759
    auto col_ndx = col_key.get_index();
6,604,899✔
760
    T values(m_alloc);
6,604,899✔
761
    values.set_parent(this, col_ndx.val + s_first_col_index);
6,604,899✔
762
    set_spec<T>(values, col_ndx);
6,604,899✔
763
    values.init_from_parent();
6,604,899✔
764
    ObjLink link;
6,604,899✔
765
    if constexpr (std::is_same_v<T, ArrayTypedLink>) {
6,604,899✔
766
        link = values.get(ndx);
×
767
    }
×
768
    if constexpr (std::is_same_v<T, ArrayMixed>) {
6,604,899✔
769
        Mixed value = values.get(ndx);
777✔
770
        if (value.is_type(type_TypedLink)) {
777✔
771
            link = value.get<ObjLink>();
24✔
772
        }
24✔
773
    }
777✔
774
    if (link) {
6,604,899✔
775
        if (const Table* origin_table = m_tree_top.get_owning_table()) {
24!
776
            auto target_obj = origin_table->get_parent_group()->get_object(link);
24✔
777

778
            ColKey backlink_col_key = target_obj.get_table()->find_backlink_column(col_key, origin_table->get_key());
24✔
779
            REALM_ASSERT(backlink_col_key);
24!
780
            target_obj.remove_one_backlink(backlink_col_key, get_real_key(ndx)); // Throws
24✔
781
        }
24✔
782
    }
24✔
783
    values.erase(ndx);
6,604,899✔
784
}
6,604,899✔
785

786
inline void Cluster::do_erase_key(size_t ndx, ColKey col_key, CascadeState& state)
787
{
68,109✔
788
    ArrayKey values(m_alloc);
68,109✔
789
    auto col_ndx = col_key.get_index();
68,109✔
790
    values.set_parent(this, col_ndx.val + s_first_col_index);
68,109✔
791
    values.init_from_parent();
68,109✔
792

793
    ObjKey key = values.get(ndx);
68,109✔
794
    if (key != null_key) {
68,109✔
795
        do_remove_backlinks(get_real_key(ndx), col_key, std::vector<ObjKey>{key}, state);
65,361✔
796
    }
65,361✔
797
    values.erase(ndx);
68,109✔
798
}
68,109✔
799

800
size_t Cluster::get_ndx(ObjKey k, size_t ndx) const noexcept
801
{
9,939,543✔
802
    size_t index;
9,939,543✔
803
    if (m_keys.is_attached()) {
9,939,543✔
804
        index = m_keys.lower_bound(uint64_t(k.value));
9,825,189✔
805
        if (index == m_keys.size() || m_keys.get(index) != uint64_t(k.value)) {
9,825,225✔
806
            return realm::npos;
18✔
807
        }
18✔
808
    }
9,825,189✔
809
    else {
114,354✔
810
        index = size_t(k.value);
114,354✔
811
        if (index >= get_as_ref_or_tagged(s_key_ref_or_size_index).get_as_int()) {
114,354✔
812
            return realm::npos;
×
813
        }
×
814
    }
114,354✔
815
    return index + ndx;
9,939,525✔
816
}
9,939,543✔
817

818
size_t Cluster::erase(ObjKey key, CascadeState& state)
819
{
5,000,637✔
820
    size_t ndx = get_ndx(key, 0);
5,000,637✔
821
    if (ndx == realm::npos)
5,000,637✔
822
        throw KeyNotFound(util::format("When erasing key '%1' in '%2'", key.value, get_owning_table()->get_name()));
18✔
823
    std::vector<ColKey> backlink_column_keys;
5,000,619✔
824

825
    auto erase_in_column = [&](ColKey col_key) {
6,704,013✔
826
        auto col_type = col_key.get_type();
6,704,013✔
827
        auto attr = col_key.get_attrs();
6,704,013✔
828
        if (attr.test(col_attr_Collection)) {
6,704,013✔
829
            auto col_ndx = col_key.get_index();
31,050✔
830
            ArrayRef values(m_alloc);
31,050✔
831
            values.set_parent(this, col_ndx.val + s_first_col_index);
31,050✔
832
            values.init_from_parent();
31,050✔
833
            ref_type ref = values.get(ndx);
31,050✔
834

835
            if (ref) {
31,050✔
836
                const Table* origin_table = m_tree_top.get_owning_table();
11,352✔
837
                if (attr.test(col_attr_Dictionary)) {
11,352✔
838
                    if (col_type == col_type_Mixed || col_type == col_type_Link) {
2,655✔
839
                        Obj obj(origin_table->m_own_ref, get_mem(), key, ndx);
354✔
840
                        Dictionary dict(obj, col_key);
354✔
841
                        dict.remove_backlinks(state);
354✔
842
                    }
354✔
843
                }
2,655✔
844
                else if (col_type == col_type_Link) {
8,697✔
845
                    BPlusTree<ObjKey> links(m_alloc);
3,951✔
846
                    links.init_from_ref(ref);
3,951✔
847
                    if (links.size() > 0) {
3,951✔
848
                        do_remove_backlinks(ObjKey(key.value + m_offset), col_key, links.get_all(), state);
1,032✔
849
                    }
1,032✔
850
                }
3,951✔
851
                else if (col_type == col_type_TypedLink) {
4,746✔
852
                    BPlusTree<ObjLink> links(m_alloc);
×
853
                    links.init_from_ref(ref);
×
854
                    for (size_t i = 0; i < links.size(); i++) {
×
855
                        ObjLink link = links.get(i);
×
856
                        auto target_obj = origin_table->get_parent_group()->get_object(link);
×
857
                        ColKey backlink_col_key =
×
858
                            target_obj.get_table()->find_backlink_column(col_key, origin_table->get_key());
×
859
                        target_obj.remove_one_backlink(backlink_col_key, ObjKey(key.value + m_offset));
×
860
                    }
×
861
                }
×
862
                else if (col_type == col_type_Mixed) {
4,746✔
863
                    Obj obj(origin_table->m_own_ref, get_mem(), key, ndx);
216✔
864
                    Lst<Mixed> list(obj, col_key);
216✔
865
                    list.remove_backlinks(state);
216✔
866
                }
216✔
867
                Array::destroy_deep(ref, m_alloc);
11,352✔
868
            }
11,352✔
869

870
            values.erase(ndx);
31,050✔
871

872
            return IteratorControl::AdvanceToNext;
31,050✔
873
        }
31,050✔
874

875
        switch (col_type) {
6,672,963✔
876
            case col_type_Int:
5,984,820✔
877
                if (attr.test(col_attr_Nullable)) {
5,984,820✔
878
                    do_erase<ArrayIntNull>(ndx, col_key);
1,276,128✔
879
                }
1,276,128✔
880
                else {
4,708,692✔
881
                    do_erase<ArrayInteger>(ndx, col_key);
4,708,692✔
882
                }
4,708,692✔
883
                break;
5,984,820✔
884
            case col_type_Bool:
42,399✔
885
                do_erase<ArrayBoolNull>(ndx, col_key);
42,399✔
886
                break;
42,399✔
887
            case col_type_Float:
36,489✔
888
                do_erase<ArrayFloatNull>(ndx, col_key);
36,489✔
889
                break;
36,489✔
890
            case col_type_Double:
36,504✔
891
                do_erase<ArrayDoubleNull>(ndx, col_key);
36,504✔
892
                break;
36,504✔
893
            case col_type_String:
75,654✔
894
                do_erase<ArrayString>(ndx, col_key);
75,654✔
895
                break;
75,654✔
896
            case col_type_Binary:
39,672✔
897
                do_erase<ArrayBinary>(ndx, col_key);
39,672✔
898
                break;
39,672✔
899
            case col_type_Mixed:
777✔
900
                do_erase<ArrayMixed>(ndx, col_key);
777✔
901
                break;
777✔
902
            case col_type_Timestamp:
45,333✔
903
                do_erase<ArrayTimestamp>(ndx, col_key);
45,333✔
904
                break;
45,333✔
905
            case col_type_Decimal:
36,279✔
906
                do_erase<ArrayDecimal128>(ndx, col_key);
36,279✔
907
                break;
36,279✔
908
            case col_type_ObjectId:
38,826✔
909
                do_erase<ArrayObjectIdNull>(ndx, col_key);
38,826✔
910
                break;
38,826✔
911
            case col_type_UUID:
60,285✔
912
                do_erase<ArrayUUIDNull>(ndx, col_key);
60,285✔
913
                break;
60,285✔
914
            case col_type_Link:
68,109✔
915
                do_erase_key(ndx, col_key, state);
68,109✔
916
                break;
68,109✔
917
            case col_type_TypedLink:
✔
918
                do_erase<ArrayTypedLink>(ndx, col_key);
×
919
                break;
×
920
            case col_type_BackLink:
207,858✔
921
                if (state.m_mode == CascadeState::Mode::None) {
207,858✔
922
                    do_erase<ArrayBacklink>(ndx, col_key);
188,577✔
923
                }
188,577✔
924
                else {
19,281✔
925
                    // Postpone the deletion of backlink entries or else the
926
                    // checks for if there's any remaining backlinks will
927
                    // check the wrong row for columns which have already
928
                    // had values erased from them.
929
                    backlink_column_keys.push_back(col_key);
19,281✔
930
                }
19,281✔
931
                break;
207,858✔
932
            default:
✔
933
                REALM_ASSERT(false);
×
934
                break;
×
935
        }
6,672,963✔
936
        return IteratorControl::AdvanceToNext;
6,672,921✔
937
    };
6,672,963✔
938
    m_tree_top.m_owner->for_each_and_every_column(erase_in_column);
5,000,619✔
939

940
    // Any remaining backlink columns to erase from?
941
    for (auto k : backlink_column_keys)
5,000,619✔
942
        do_erase<ArrayBacklink>(ndx, k);
19,281✔
943

944
    if (m_keys.is_attached()) {
5,000,619✔
945
        m_keys.erase(ndx);
4,960,125✔
946
    }
4,960,125✔
947
    else {
40,494✔
948
        size_t current_size = get_size_in_compact_form();
40,494✔
949
        if (ndx == current_size - 1) {
40,494✔
950
            // When deleting last, we can still maintain compact form
951
            set(0, RefOrTagged::make_tagged(current_size - 1));
26,142✔
952
        }
26,142✔
953
        else {
14,352✔
954
            ensure_general_form();
14,352✔
955
            m_keys.erase(ndx);
14,352✔
956
        }
14,352✔
957
    }
40,494✔
958

959
    return node_size();
5,000,619✔
960
}
5,000,637✔
961

962
void Cluster::nullify_incoming_links(ObjKey key, CascadeState& state)
963
{
4,902,198✔
964
    size_t ndx = get_ndx(key, 0);
4,902,198✔
965
    if (ndx == realm::npos)
4,902,198✔
966
        throw KeyNotFound(util::format("Key '%1' not found in '%2' when nullifying incoming links", key.value,
×
967
                                       get_owning_table()->get_class_name()));
×
968

969
    // We must start with backlink columns in case the corresponding link
970
    // columns are in the same table so that we can nullify links before
971
    // erasing rows in the link columns.
972
    //
973
    // This phase also generates replication instructions documenting the side-
974
    // effects of deleting the object (i.e. link nullifications). These instructions
975
    // must come before the actual deletion of the object, but at the same time
976
    // the Replication object may need a consistent view of the row (not including
977
    // link columns). Therefore we first nullify links to this object, then
978
    // generate the instruction, and then delete the row in the remaining columns.
979

980
    auto nullify_fwd_links = [&](ColKey col_key) {
4,902,198✔
981
        ColKey::Idx leaf_ndx = col_key.get_index();
190,329✔
982
        auto type = col_key.get_type();
190,329✔
983
        REALM_ASSERT(type == col_type_BackLink);
190,329✔
984
        ArrayBacklink values(m_alloc);
190,329✔
985
        values.set_parent(this, leaf_ndx.val + s_first_col_index);
190,329✔
986
        values.init_from_parent();
190,329✔
987
        // Ensure that Cluster is writable and able to hold references to nodes in
988
        // the slab area before nullifying or deleting links. These operation may
989
        // both have the effect that other objects may be constructed and manipulated.
990
        // If those other object are in the same cluster that the object to be deleted
991
        // is in, then that will cause another accessor to this cluster to be created.
992
        // It would lead to an error if the cluster node was relocated without it being
993
        // reflected in the context here.
994
        values.copy_on_write();
190,329✔
995
        values.nullify_fwd_links(ndx, state);
190,329✔
996

997
        return IteratorControl::AdvanceToNext;
190,329✔
998
    };
190,329✔
999

1000
    m_tree_top.get_owning_table()->for_each_backlink_column(nullify_fwd_links);
4,902,198✔
1001
}
4,902,198✔
1002

1003
void Cluster::upgrade_string_to_enum(ColKey col_key, ArrayString& keys)
1004
{
1,089✔
1005
    auto col_ndx = col_key.get_index();
1,089✔
1006
    Array indexes(m_alloc);
1,089✔
1007
    indexes.create(Array::type_Normal, false);
1,089✔
1008
    ArrayString values(m_alloc);
1,089✔
1009
    ref_type ref = Array::get_as_ref(col_ndx.val + s_first_col_index);
1,089✔
1010
    values.init_from_ref(ref);
1,089✔
1011
    size_t sz = values.size();
1,089✔
1012
    for (size_t i = 0; i < sz; i++) {
118,545✔
1013
        auto v = values.get(i);
117,456✔
1014
        size_t pos = keys.lower_bound(v);
117,456✔
1015
        REALM_ASSERT_3(pos, !=, keys.size());
117,456✔
1016
        indexes.add(pos);
117,456✔
1017
    }
117,456✔
1018
    Array::set(col_ndx.val + s_first_col_index, indexes.get_ref());
1,089✔
1019
    Array::destroy_deep(ref, m_alloc);
1,089✔
1020
}
1,089✔
1021

1022
void Cluster::init_leaf(ColKey col_key, ArrayPayload* leaf) const
1023
{
8,670,990✔
1024
    auto col_ndx = col_key.get_index();
8,670,990✔
1025
    // FIXME: Move this validation into callers.
1026
    // Currently, the query subsystem may call with an unvalidated key.
1027
    // once fixed, reintroduce the noexcept declaration :-D
1028
    if (auto t = m_tree_top.get_owning_table())
8,670,990✔
1029
        t->check_column(col_key);
8,579,796✔
1030
    ref_type ref = to_ref(Array::get(col_ndx.val + 1));
8,670,990✔
1031
    if (leaf->need_spec()) {
8,670,990✔
1032
        m_tree_top.set_spec(*leaf, col_ndx);
137,727✔
1033
    }
137,727✔
1034
    leaf->init_from_ref(ref);
8,670,990✔
1035
    leaf->set_parent(const_cast<Cluster*>(this), col_ndx.val + 1);
8,670,990✔
1036
}
8,670,990✔
1037

1038
void Cluster::add_leaf(ColKey col_key, ref_type ref)
1039
{
×
1040
    auto col_ndx = col_key.get_index();
×
1041
    REALM_ASSERT((col_ndx.val + 1) == size());
×
1042
    Array::insert(col_ndx.val + 1, from_ref(ref));
×
1043
}
×
1044

1045
template <typename ArrayType>
1046
void Cluster::verify(ref_type ref, size_t index, util::Optional<size_t>& sz) const
1047
{
586,656✔
1048
    ArrayType arr(get_alloc());
586,656✔
1049
    set_spec(arr, ColKey::Idx{unsigned(index) - 1});
586,656✔
1050
    arr.set_parent(const_cast<Cluster*>(this), index);
586,656✔
1051
    arr.init_from_ref(ref);
586,656✔
1052
    arr.verify();
586,656✔
1053
    if (sz) {
586,656✔
1054
        REALM_ASSERT(arr.size() == *sz);
221,799!
1055
    }
221,799✔
1056
    else {
364,857✔
1057
        sz = arr.size();
364,857✔
1058
    }
364,857✔
1059
}
586,656✔
1060
namespace {
1061

1062
template <typename ArrayType>
1063
void verify_list(ArrayRef& arr, size_t sz)
1064
{
102,390✔
1065
    for (size_t n = 0; n < sz; n++) {
379,617!
1066
        if (ref_type bp_tree_ref = arr.get(n)) {
277,227!
1067
            BPlusTree<ArrayType> links(arr.get_alloc());
122,808✔
1068
            links.init_from_ref(bp_tree_ref);
122,808✔
1069
            links.set_parent(&arr, n);
122,808✔
1070
            links.verify();
122,808✔
1071
        }
122,808✔
1072
    }
277,227✔
1073
}
102,390✔
1074

1075
template <typename SetType>
1076
void verify_set(ArrayRef& arr, size_t sz)
1077
{
174✔
1078
    for (size_t n = 0; n < sz; ++n) {
402!
1079
        if (ref_type bp_tree_ref = arr.get(n)) {
228!
1080
            BPlusTree<SetType> elements(arr.get_alloc());
216✔
1081
            elements.init_from_ref(bp_tree_ref);
216✔
1082
            elements.set_parent(&arr, n);
216✔
1083
            elements.verify();
216✔
1084

1085
            // FIXME: Check uniqueness of elements.
1086
        }
216✔
1087
    }
228✔
1088
}
174✔
1089

1090
} // namespace
1091

1092
void Cluster::verify() const
1093
{
401,463✔
1094
#ifdef REALM_DEBUG
401,463✔
1095
    util::Optional<size_t> sz;
401,463✔
1096

1097
    auto verify_column = [this, &sz](ColKey col_key) {
701,496✔
1098
        size_t col = col_key.get_index().val + s_first_col_index;
701,496✔
1099
        ref_type ref = Array::get_as_ref(col);
701,496✔
1100
        auto attr = col_key.get_attrs();
701,496✔
1101
        auto col_type = col_key.get_type();
701,496✔
1102
        bool nullable = attr.test(col_attr_Nullable);
701,496✔
1103

1104
        if (attr.test(col_attr_List)) {
701,496✔
1105
            ArrayRef arr(get_alloc());
102,408✔
1106
            arr.set_parent(const_cast<Cluster*>(this), col);
102,408✔
1107
            arr.init_from_ref(ref);
102,408✔
1108
            arr.verify();
102,408✔
1109
            if (sz) {
102,408✔
1110
                REALM_ASSERT(arr.size() == *sz);
78,051✔
1111
            }
78,051✔
1112
            else {
24,357✔
1113
                sz = arr.size();
24,357✔
1114
            }
24,357✔
1115

1116
            switch (col_type) {
102,408✔
1117
                case col_type_Int:
41,535✔
1118
                    if (nullable) {
41,535✔
1119
                        verify_list<util::Optional<int64_t>>(arr, *sz);
×
1120
                    }
×
1121
                    else {
41,535✔
1122
                        verify_list<int64_t>(arr, *sz);
41,535✔
1123
                    }
41,535✔
1124
                    break;
41,535✔
1125
                case col_type_Bool:
✔
1126
                    verify_list<Bool>(arr, *sz);
×
1127
                    break;
×
1128
                case col_type_Float:
6✔
1129
                    verify_list<Float>(arr, *sz);
6✔
1130
                    break;
6✔
1131
                case col_type_Double:
✔
1132
                    verify_list<Double>(arr, *sz);
×
1133
                    break;
×
1134
                case col_type_String:
35,646✔
1135
                    verify_list<String>(arr, *sz);
35,646✔
1136
                    break;
35,646✔
1137
                case col_type_Binary:
24,000✔
1138
                    verify_list<Binary>(arr, *sz);
24,000✔
1139
                    break;
24,000✔
1140
                case col_type_Timestamp:
✔
1141
                    verify_list<Timestamp>(arr, *sz);
×
1142
                    break;
×
1143
                case col_type_Decimal:
✔
1144
                    verify_list<Decimal128>(arr, *sz);
×
1145
                    break;
×
1146
                case col_type_ObjectId:
✔
1147
                    verify_list<ObjectId>(arr, *sz);
×
1148
                    break;
×
1149
                case col_type_UUID:
✔
1150
                    verify_list<UUID>(arr, *sz);
×
1151
                    break;
×
1152
                case col_type_Link:
1,203✔
1153
                    verify_list<ObjKey>(arr, *sz);
1,203✔
1154
                    break;
1,203✔
1155
                default:
18✔
1156
                    // FIXME: Nullable primitives
1157
                    break;
18✔
1158
            }
102,408✔
1159
            return IteratorControl::AdvanceToNext;
102,408✔
1160
        }
102,408✔
1161
        else if (attr.test(col_attr_Dictionary)) {
599,088✔
1162
            ArrayRef arr(get_alloc());
12,168✔
1163
            arr.set_parent(const_cast<Cluster*>(this), col);
12,168✔
1164
            arr.init_from_ref(ref);
12,168✔
1165
            arr.verify();
12,168✔
1166
            if (sz) {
12,168✔
1167
                REALM_ASSERT(arr.size() == *sz);
138✔
1168
            }
138✔
1169
            else {
12,030✔
1170
                sz = arr.size();
12,030✔
1171
            }
12,030✔
1172
            for (size_t n = 0; n < sz; n++) {
24,504✔
1173
                if (auto ref = arr.get(n)) {
12,336✔
1174
                    Dictionary dict(get_alloc(), col_key, to_ref(ref));
12,222✔
1175
                    dict.verify();
12,222✔
1176
                }
12,222✔
1177
            }
12,336✔
1178
            return IteratorControl::AdvanceToNext;
12,168✔
1179
        }
12,168✔
1180
        else if (attr.test(col_attr_Set)) {
586,920✔
1181
            ArrayRef arr(get_alloc());
270✔
1182
            arr.set_parent(const_cast<Cluster*>(this), col);
270✔
1183
            arr.init_from_ref(ref);
270✔
1184
            arr.verify();
270✔
1185
            if (sz) {
270✔
1186
                REALM_ASSERT(arr.size() == *sz);
252✔
1187
            }
252✔
1188
            else {
18✔
1189
                sz = arr.size();
18✔
1190
            }
18✔
1191
            switch (col_type) {
270✔
1192
                case col_type_Int:
138✔
1193
                    if (nullable) {
138✔
1194
                        verify_set<util::Optional<int64_t>>(arr, *sz);
×
1195
                    }
×
1196
                    else {
138✔
1197
                        verify_set<int64_t>(arr, *sz);
138✔
1198
                    }
138✔
1199
                    break;
138✔
1200
                case col_type_Bool:
✔
1201
                    verify_set<Bool>(arr, *sz);
×
1202
                    break;
×
1203
                case col_type_Float:
✔
1204
                    verify_set<Float>(arr, *sz);
×
1205
                    break;
×
1206
                case col_type_Double:
✔
1207
                    verify_set<Double>(arr, *sz);
×
1208
                    break;
×
1209
                case col_type_String:
6✔
1210
                    verify_set<String>(arr, *sz);
6✔
1211
                    break;
6✔
1212
                case col_type_Binary:
18✔
1213
                    verify_set<Binary>(arr, *sz);
18✔
1214
                    break;
18✔
1215
                case col_type_Timestamp:
✔
1216
                    verify_set<Timestamp>(arr, *sz);
×
1217
                    break;
×
1218
                case col_type_Decimal:
✔
1219
                    verify_set<Decimal128>(arr, *sz);
×
1220
                    break;
×
1221
                case col_type_ObjectId:
✔
1222
                    verify_set<ObjectId>(arr, *sz);
×
1223
                    break;
×
1224
                case col_type_UUID:
✔
1225
                    verify_set<UUID>(arr, *sz);
×
1226
                    break;
×
1227
                case col_type_Link:
12✔
1228
                    verify_set<ObjKey>(arr, *sz);
12✔
1229
                    break;
12✔
1230
                default:
96✔
1231
                    // FIXME: Nullable primitives
1232
                    break;
96✔
1233
            }
270✔
1234
            return IteratorControl::AdvanceToNext;
270✔
1235
        }
270✔
1236

1237
        switch (col_type) {
586,650✔
1238
            case col_type_Int:
362,400✔
1239
                if (nullable) {
362,400✔
1240
                    verify<ArrayIntNull>(ref, col, sz);
53,616✔
1241
                }
53,616✔
1242
                else {
308,784✔
1243
                    verify<ArrayInteger>(ref, col, sz);
308,784✔
1244
                }
308,784✔
1245
                break;
362,400✔
1246
            case col_type_Bool:
7,158✔
1247
                verify<ArrayBoolNull>(ref, col, sz);
7,158✔
1248
                break;
7,158✔
1249
            case col_type_Float:
261✔
1250
                verify<ArrayFloatNull>(ref, col, sz);
261✔
1251
                break;
261✔
1252
            case col_type_Double:
207✔
1253
                verify<ArrayDoubleNull>(ref, col, sz);
207✔
1254
                break;
207✔
1255
            case col_type_String:
152,625✔
1256
                verify<ArrayString>(ref, col, sz);
152,625✔
1257
                break;
152,625✔
1258
            case col_type_Binary:
49,884✔
1259
                verify<ArrayBinary>(ref, col, sz);
49,884✔
1260
                break;
49,884✔
1261
            case col_type_Mixed:
2,688✔
1262
                verify<ArrayMixed>(ref, col, sz);
2,688✔
1263
                break;
2,688✔
1264
            case col_type_Timestamp:
6,948✔
1265
                verify<ArrayTimestamp>(ref, col, sz);
6,948✔
1266
                break;
6,948✔
1267
            case col_type_Decimal:
42✔
1268
                verify<ArrayDecimal128>(ref, col, sz);
42✔
1269
                break;
42✔
1270
            case col_type_ObjectId:
42✔
1271
                verify<ArrayObjectIdNull>(ref, col, sz);
42✔
1272
                break;
42✔
1273
            case col_type_UUID:
✔
1274
                verify<ArrayUUIDNull>(ref, col, sz);
×
1275
                break;
×
1276
            case col_type_Link:
1,695✔
1277
                verify<ArrayKey>(ref, col, sz);
1,695✔
1278
                break;
1,695✔
1279
            case col_type_BackLink:
2,706✔
1280
                verify<ArrayBacklink>(ref, col, sz);
2,706✔
1281
                break;
2,706✔
1282
            default:
✔
1283
                break;
×
1284
        }
586,650✔
1285
        return IteratorControl::AdvanceToNext;
586,647✔
1286
    };
586,650✔
1287

1288
    m_tree_top.m_owner->for_each_and_every_column(verify_column);
401,463✔
1289
#endif
401,463✔
1290
}
401,463✔
1291

1292
// LCOV_EXCL_START
1293
void Cluster::dump_objects(int64_t key_offset, std::string lead) const
1294
{
×
1295
    std::cout << lead << "leaf - size: " << node_size() << std::endl;
×
1296
    if (!m_keys.is_attached()) {
×
1297
        std::cout << lead << "compact form" << std::endl;
×
1298
    }
×
1299

1300
    for (unsigned i = 0; i < node_size(); i++) {
×
1301
        int64_t key_value;
×
1302
        if (m_keys.is_attached()) {
×
1303
            key_value = m_keys.get(i);
×
1304
        }
×
1305
        else {
×
1306
            key_value = int64_t(i);
×
1307
        }
×
1308
        std::cout << lead << "key: " << std::hex << key_value + key_offset << std::dec;
×
1309
        m_tree_top.m_owner->for_each_and_every_column([&](ColKey col) {
×
1310
            size_t j = col.get_index().val + 1;
×
1311
            if (col.get_attrs().test(col_attr_List)) {
×
1312
                ref_type ref = Array::get_as_ref(j);
×
1313
                ArrayRef refs(m_alloc);
×
1314
                refs.init_from_ref(ref);
×
1315
                std::cout << ", {";
×
1316
                ref = refs.get(i);
×
1317
                if (ref) {
×
1318
                    if (col.get_type() == col_type_Int) {
×
1319
                        // This is easy to handle
1320
                        Array ints(m_alloc);
×
1321
                        ints.init_from_ref(ref);
×
1322
                        for (size_t n = 0; n < ints.size(); n++) {
×
1323
                            std::cout << ints.get(n) << ", ";
×
1324
                        }
×
1325
                    }
×
1326
                    else {
×
1327
                        std::cout << col.get_type();
×
1328
                    }
×
1329
                }
×
1330
                std::cout << "}";
×
1331
                return IteratorControl::AdvanceToNext;
×
1332
            }
×
1333

1334
            switch (col.get_type()) {
×
1335
                case col_type_Int: {
×
1336
                    bool nullable = col.get_attrs().test(col_attr_Nullable);
×
1337
                    ref_type ref = Array::get_as_ref(j);
×
1338
                    if (nullable) {
×
1339
                        ArrayIntNull arr_int_null(m_alloc);
×
1340
                        arr_int_null.init_from_ref(ref);
×
1341
                        if (arr_int_null.is_null(i)) {
×
1342
                            std::cout << ", null";
×
1343
                        }
×
1344
                        else {
×
1345
                            std::cout << ", " << *arr_int_null.get(i);
×
1346
                        }
×
1347
                    }
×
1348
                    else {
×
1349
                        Array arr(m_alloc);
×
1350
                        arr.init_from_ref(ref);
×
1351
                        std::cout << ", " << arr.get(i);
×
1352
                    }
×
1353
                    break;
×
1354
                }
×
1355
                case col_type_Bool: {
×
1356
                    ArrayBoolNull arr(m_alloc);
×
1357
                    ref_type ref = Array::get_as_ref(j);
×
1358
                    arr.init_from_ref(ref);
×
1359
                    auto val = arr.get(i);
×
1360
                    std::cout << ", " << (val ? (*val ? "true" : "false") : "null");
×
1361
                    break;
×
1362
                }
×
1363
                case col_type_Float: {
×
1364
                    ArrayFloatNull arr(m_alloc);
×
1365
                    ref_type ref = Array::get_as_ref(j);
×
1366
                    arr.init_from_ref(ref);
×
1367
                    auto val = arr.get(i);
×
1368
                    if (val)
×
1369
                        std::cout << ", " << *val;
×
1370
                    else
×
1371
                        std::cout << ", null";
×
1372
                    break;
×
1373
                }
×
1374
                case col_type_Double: {
×
1375
                    ArrayDoubleNull arr(m_alloc);
×
1376
                    ref_type ref = Array::get_as_ref(j);
×
1377
                    arr.init_from_ref(ref);
×
1378
                    auto val = arr.get(i);
×
1379
                    if (val)
×
1380
                        std::cout << ", " << *val;
×
1381
                    else
×
1382
                        std::cout << ", null";
×
1383
                    break;
×
1384
                }
×
1385
                case col_type_String: {
×
1386
                    ArrayString arr(m_alloc);
×
1387
                    set_spec(arr, col.get_index());
×
1388
                    ref_type ref = Array::get_as_ref(j);
×
1389
                    arr.init_from_ref(ref);
×
1390
                    std::cout << ", " << arr.get(i);
×
1391
                    break;
×
1392
                }
×
1393
                case col_type_Binary: {
×
1394
                    ArrayBinary arr(m_alloc);
×
1395
                    ref_type ref = Array::get_as_ref(j);
×
1396
                    arr.init_from_ref(ref);
×
1397
                    std::cout << ", " << arr.get(i);
×
1398
                    break;
×
1399
                }
×
1400
                case col_type_Mixed: {
×
1401
                    ArrayMixed arr(m_alloc);
×
1402
                    ref_type ref = Array::get_as_ref(j);
×
1403
                    arr.init_from_ref(ref);
×
1404
                    std::cout << ", " << arr.get(i);
×
1405
                    break;
×
1406
                }
×
1407
                case col_type_Timestamp: {
×
1408
                    ArrayTimestamp arr(m_alloc);
×
1409
                    ref_type ref = Array::get_as_ref(j);
×
1410
                    arr.init_from_ref(ref);
×
1411
                    if (arr.is_null(i)) {
×
1412
                        std::cout << ", null";
×
1413
                    }
×
1414
                    else {
×
1415
                        std::cout << ", " << arr.get(i);
×
1416
                    }
×
1417
                    break;
×
1418
                }
×
1419
                case col_type_Decimal: {
×
1420
                    ArrayDecimal128 arr(m_alloc);
×
1421
                    ref_type ref = Array::get_as_ref(j);
×
1422
                    arr.init_from_ref(ref);
×
1423
                    if (arr.is_null(i)) {
×
1424
                        std::cout << ", null";
×
1425
                    }
×
1426
                    else {
×
1427
                        std::cout << ", " << arr.get(i);
×
1428
                    }
×
1429
                    break;
×
1430
                }
×
1431
                case col_type_ObjectId: {
×
1432
                    ArrayObjectIdNull arr(m_alloc);
×
1433
                    ref_type ref = Array::get_as_ref(j);
×
1434
                    arr.init_from_ref(ref);
×
1435
                    if (arr.is_null(i)) {
×
1436
                        std::cout << ", null";
×
1437
                    }
×
1438
                    else {
×
1439
                        std::cout << ", " << *arr.get(i);
×
1440
                    }
×
1441
                    break;
×
1442
                }
×
1443
                case col_type_UUID: {
×
1444
                    ArrayUUIDNull arr(m_alloc);
×
1445
                    ref_type ref = Array::get_as_ref(j);
×
1446
                    arr.init_from_ref(ref);
×
1447
                    if (arr.is_null(i)) {
×
1448
                        std::cout << ", null";
×
1449
                    }
×
1450
                    else {
×
1451
                        std::cout << ", " << arr.get(i);
×
1452
                    }
×
1453
                    break;
×
1454
                }
×
1455
                case col_type_Link: {
×
1456
                    ArrayKey arr(m_alloc);
×
1457
                    ref_type ref = Array::get_as_ref(j);
×
1458
                    arr.init_from_ref(ref);
×
1459
                    std::cout << ", " << arr.get(i);
×
1460
                    break;
×
1461
                }
×
1462
                case col_type_BackLink: {
×
1463
                    break;
×
1464
                }
×
1465
                default:
×
1466
                    std::cout << ", Error";
×
1467
                    break;
×
1468
            }
×
1469
            return IteratorControl::AdvanceToNext;
×
1470
        });
×
1471
        std::cout << std::endl;
×
1472
    }
×
1473
}
×
1474
// LCOV_EXCL_STOP
1475

1476
void Cluster::remove_backlinks(const Table* origin_table, ObjKey origin_key, ColKey origin_col_key,
1477
                               const std::vector<ObjKey>& keys, CascadeState& state)
1478
{
67,143✔
1479
    TableRef target_table = origin_table->get_opposite_table(origin_col_key);
67,143✔
1480
    ColKey backlink_col_key = origin_table->get_opposite_column(origin_col_key);
67,143✔
1481
    bool strong_links = target_table->is_embedded();
67,143✔
1482

1483
    for (auto key : keys) {
68,775✔
1484
        if (key != null_key) {
68,775✔
1485
            bool is_unres = key.is_unresolved();
68,775✔
1486
            Obj target_obj = is_unres ? target_table->m_tombstones->get(key) : target_table->m_clusters.get(key);
68,775✔
1487
            bool last_removed = target_obj.remove_one_backlink(backlink_col_key, origin_key); // Throws
68,775✔
1488
            if (is_unres) {
68,775✔
1489
                if (last_removed) {
30✔
1490
                    // Check is there are more backlinks
1491
                    if (!target_obj.has_backlinks(false)) {
24✔
1492
                        // Tombstones can be erased right away - there is no cascading effect
1493
                        target_table->m_tombstones->erase(key, state);
18✔
1494
                    }
18✔
1495
                }
24✔
1496
            }
30✔
1497
            else {
68,745✔
1498
                state.enqueue_for_cascade(target_obj, strong_links, last_removed);
68,745✔
1499
            }
68,745✔
1500
        }
68,775✔
1501
    }
68,775✔
1502
}
67,143✔
1503

1504
void Cluster::remove_backlinks(const Table* origin_table, ObjKey origin_key, ColKey origin_col_key,
1505
                               const std::vector<ObjLink>& links, CascadeState& state)
1506
{
144✔
1507
    Group* group = origin_table->get_parent_group();
144✔
1508
    TableKey origin_table_key = origin_table->get_key();
144✔
1509

1510
    for (auto link : links) {
240✔
1511
        if (link) {
240✔
1512
            bool is_unres = link.get_obj_key().is_unresolved();
240✔
1513
            Obj target_obj = group->get_object(link);
240✔
1514
            TableRef target_table = target_obj.get_table();
240✔
1515
            ColKey backlink_col_key = target_table->find_or_add_backlink_column(origin_col_key, origin_table_key);
240✔
1516

1517
            bool last_removed = target_obj.remove_one_backlink(backlink_col_key, origin_key); // Throws
240✔
1518
            if (is_unres) {
240✔
1519
                if (last_removed) {
6✔
1520
                    // Check is there are more backlinks
1521
                    if (!target_obj.has_backlinks(false)) {
6✔
1522
                        // Tombstones can be erased right away - there is no cascading effect
1523
                        target_table->m_tombstones->erase(link.get_obj_key(), state);
6✔
1524
                    }
6✔
1525
                }
6✔
1526
            }
6✔
1527
            else {
234✔
1528
                state.enqueue_for_cascade(target_obj, false, last_removed);
234✔
1529
            }
234✔
1530
        }
240✔
1531
    }
240✔
1532
}
144✔
1533

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