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

realm / realm-core / jorgen.edelbo_391

13 Aug 2024 07:57AM UTC coverage: 91.091% (-0.02%) from 91.107%
jorgen.edelbo_391

Pull #7826

Evergreen

web-flow
Merge pull request #7979 from realm/test-upgrade-files

Create test file in file-format 24
Pull Request #7826: Merge Next major

103486 of 182216 branches covered (56.79%)

3157 of 3519 new or added lines in 54 files covered. (89.71%)

191 existing lines in 22 files now uncovered.

219971 of 241486 relevant lines covered (91.09%)

6652643.8 hits per line

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

95.81
/src/realm/array.hpp
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
#ifndef REALM_ARRAY_HPP
20
#define REALM_ARRAY_HPP
21

22
#include <realm/node.hpp>
23
#include <realm/query_state.hpp>
24
#include <realm/query_conditions.hpp>
25
#include <realm/column_fwd.hpp>
26
#include <realm/array_direct.hpp>
27
#include <realm/integer_compressor.hpp>
28

29
namespace realm {
30

31
// Pre-definitions
32
class GroupWriter;
33
namespace _impl {
34
class ArrayWriterBase;
35
}
36

37
struct MemStats {
38
    size_t allocated = 0;
39
    size_t used = 0;
40
    size_t array_count = 0;
41
};
42

43
// Stores a value obtained from Array::get(). It is a ref if the least
44
// significant bit is clear, otherwise it is a tagged integer. A tagged interger
45
// is obtained from a logical integer value by left shifting by one bit position
46
// (multiplying by two), and then setting the least significant bit to
47
// one. Clearly, this means that the maximum value that can be stored as a
48
// tagged integer is 2**63 - 1.
49
class RefOrTagged {
50
public:
51
    bool is_ref() const noexcept;
52
    bool is_tagged() const noexcept;
53
    ref_type get_as_ref() const noexcept;
54
    uint_fast64_t get_as_int() const noexcept;
55

56
    static RefOrTagged make_ref(ref_type) noexcept;
57
    static RefOrTagged make_tagged(uint_fast64_t) noexcept;
58

59
private:
60
    int_fast64_t m_value;
61
    RefOrTagged(int_fast64_t) noexcept;
62
    friend class Array;
63
};
64

65

66
template <class T>
67
class QueryStateFindAll : public QueryStateBase {
68
public:
69
    explicit QueryStateFindAll(T& keys, size_t limit = -1)
70
        : QueryStateBase(limit)
812,712✔
71
        , m_keys(keys)
812,712✔
72
    {
1,634,427✔
73
    }
1,634,427✔
74
    bool match(size_t index, Mixed) noexcept final;
75
    bool match(size_t index) noexcept final;
76

77
private:
78
    T& m_keys;
79
};
80

81
class QueryStateFindFirst : public QueryStateBase {
82
public:
83
    size_t m_state = realm::not_found;
84
    QueryStateFindFirst()
85
        : QueryStateBase(1)
5,985,342✔
86
    {
11,899,371✔
87
    }
11,899,371✔
88
    bool match(size_t index, Mixed) noexcept final;
89
    bool match(size_t index) noexcept final;
90
};
91

92
class Array : public Node, public ArrayParent {
93
public:
94
    /// Create an array accessor in the unattached state.
95
    explicit Array(Allocator& allocator) noexcept;
96
    virtual ~Array() noexcept = default;
854,244,207✔
97

98
    /// Create a new integer array of the specified type and size, and filled
99
    /// with the specified value, and attach this accessor to it. This does not
100
    /// modify the parent reference information of this accessor.
101
    ///
102
    /// Note that the caller assumes ownership of the allocated underlying
103
    /// node. It is not owned by the accessor.
104
    void create(Type, bool context_flag = false, size_t size = 0, int_fast64_t value = 0);
105

106
    /// Reinitialize this array accessor to point to the specified new
107
    /// underlying memory. This does not modify the parent reference information
108
    /// of this accessor.
109
    void init_from_ref(ref_type ref) noexcept
110
    {
233,118,573✔
111
        REALM_ASSERT_DEBUG(ref);
233,118,573✔
112
        char* header = m_alloc.translate(ref);
233,118,573✔
113
        init_from_mem(MemRef(header, ref, m_alloc));
233,118,573✔
114
    }
233,118,573✔
115

116
    /// Same as init_from_ref(ref_type) but avoid the mapping of 'ref' to memory
117
    /// pointer.
118
    void init_from_mem(MemRef) noexcept;
119

120
    /// Same as `init_from_ref(get_ref_from_parent())`.
121
    void init_from_parent() noexcept
122
    {
93,510,006✔
123
        ref_type ref = get_ref_from_parent();
93,510,006✔
124
        init_from_ref(ref);
93,510,006✔
125
    }
93,510,006✔
126

127
    MemRef get_mem() const noexcept;
128

129
    /// Called in the context of Group::commit() to ensure that attached
130
    /// accessors stay valid across a commit. Please note that this works only
131
    /// for non-transactional commits. Accessors obtained during a transaction
132
    /// are always detached when the transaction ends.
133
    void update_from_parent() noexcept;
134

135
    /// Change the type of an already attached array node.
136
    ///
137
    /// The effect of calling this function on an unattached accessor is
138
    /// undefined.
139
    void set_type(Type);
140

141
    /// Construct an empty integer array of the specified type, and return just
142
    /// the reference to the underlying memory.
143
    static MemRef create_empty_array(Type, bool context_flag, Allocator&);
144

145
    /// Construct an integer array of the specified type and size, and return
146
    /// just the reference to the underlying memory. All elements will be
147
    /// initialized to the specified value.
148
    static MemRef create_array(Type, bool context_flag, size_t size, int_fast64_t value, Allocator&);
149

150
    Type get_type() const noexcept;
151

152
    /// The meaning of 'width' depends on the context in which this
153
    /// array is used.
154
    size_t get_width() const noexcept
155
    {
3,594,696✔
156
        REALM_ASSERT_3(m_width, ==, get_width_from_header(get_header()));
3,594,696✔
157
        return m_width;
3,594,696✔
158
    }
3,594,696✔
159

160
    void insert(size_t ndx, int_fast64_t value);
161
    void add(int_fast64_t value);
162

163
    // Used from ArrayBlob
164
    size_t blob_size() const noexcept;
165
    ref_type blob_replace(size_t begin, size_t end, const char* data, size_t data_size, bool add_zero_term);
166

167
    /// This function is guaranteed to not throw if the current width is
168
    /// sufficient for the specified value (e.g. if you have called
169
    /// ensure_minimum_width(value)) and get_alloc().is_read_only(get_ref())
170
    /// returns false (noexcept:array-set). Note that for a value of zero, the
171
    /// first criterion is trivially satisfied.
172
    void set(size_t ndx, int64_t value);
173

174
    void set_as_ref(size_t ndx, ref_type ref);
175

176
    template <size_t w>
177
    static void set(Array&, size_t ndx, int64_t value);
178

179
    int64_t get(size_t ndx) const noexcept;
180

181
    std::vector<int64_t> get_all(size_t b, size_t e) const;
182

183
    template <size_t w>
184
    static int64_t get(const Array& arr, size_t ndx) noexcept;
185

186
    void get_chunk(size_t ndx, int64_t res[8]) const noexcept;
187

188
    template <size_t w>
189
    static void get_chunk(const Array&, size_t ndx, int64_t res[8]) noexcept;
190

191
    ref_type get_as_ref(size_t ndx) const noexcept;
192
    RefOrTagged get_as_ref_or_tagged(size_t ndx) const noexcept;
193

194
    void set(size_t ndx, RefOrTagged);
195
    void add(RefOrTagged);
196
    void ensure_minimum_width(RefOrTagged);
197

198
    int64_t front() const noexcept;
199
    int64_t back() const noexcept;
200

201
    void alloc(size_t init_size, size_t new_width)
202
    {
966,207,207✔
203
        // Node::alloc is the one that triggers copy on write. If we call alloc for a B
204
        //       array we have a bug in our machinery, the array should have been decompressed
205
        //       way before calling alloc.
206
        const auto header = get_header();
966,207,207✔
207
        REALM_ASSERT_3(m_width, ==, get_width_from_header(header));
966,207,207✔
208
        REALM_ASSERT_3(m_size, ==, get_size_from_header(header));
966,207,207✔
209
        Node::alloc(init_size, new_width);
966,207,207✔
210
        update_width_cache_from_header();
966,207,207✔
211
    }
966,207,207✔
212

213
    bool is_empty() const noexcept
214
    {
68,076✔
215
        return size() == 0;
68,076✔
216
    }
68,076✔
217

218
    /// Remove the element at the specified index, and move elements at higher
219
    /// indexes to the next lower index.
220
    ///
221
    /// This function does **not** destroy removed subarrays. That is, if the
222
    /// erased element is a 'ref' pointing to a subarray, then that subarray
223
    /// will not be destroyed automatically.
224
    ///
225
    /// This function guarantees that no exceptions will be thrown if
226
    /// get_alloc().is_read_only(get_ref()) would return false before the
227
    /// call. This is automatically guaranteed if the array is used in a
228
    /// non-transactional context, or if the array has already been successfully
229
    /// modified within the current write transaction.
230
    void erase(size_t ndx);
231

232
    /// Same as erase(size_t), but remove all elements in the specified
233
    /// range.
234
    ///
235
    /// Please note that this function does **not** destroy removed subarrays.
236
    ///
237
    /// This function guarantees that no exceptions will be thrown if
238
    /// get_alloc().is_read_only(get_ref()) would return false before the call.
239
    void erase(size_t begin, size_t end);
240

241
    /// Reduce the size of this array to the specified number of elements. It is
242
    /// an error to specify a size that is greater than the current size of this
243
    /// array. The effect of doing so is undefined. This is just a shorthand for
244
    /// calling the ranged erase() function with appropriate arguments.
245
    ///
246
    /// Please note that this function does **not** destroy removed
247
    /// subarrays. See clear_and_destroy_children() for an alternative.
248
    ///
249
    /// This function guarantees that no exceptions will be thrown if
250
    /// get_alloc().is_read_only(get_ref()) would return false before the call.
251
    void truncate(size_t new_size);
252

253
    /// Reduce the size of this array to the specified number of elements. It is
254
    /// an error to specify a size that is greater than the current size of this
255
    /// array. The effect of doing so is undefined. Subarrays will be destroyed
256
    /// recursively, as if by a call to `destroy_deep(subarray_ref, alloc)`.
257
    ///
258
    /// This function is guaranteed not to throw if
259
    /// get_alloc().is_read_only(get_ref()) returns false.
260
    void truncate_and_destroy_children(size_t new_size);
261

262
    /// Remove every element from this array. This is just a shorthand for
263
    /// calling truncate(0).
264
    ///
265
    /// Please note that this function does **not** destroy removed
266
    /// subarrays. See clear_and_destroy_children() for an alternative.
267
    ///
268
    /// This function guarantees that no exceptions will be thrown if
269
    /// get_alloc().is_read_only(get_ref()) would return false before the call.
270
    void clear();
271

272
    /// Remove every element in this array. Subarrays will be destroyed
273
    /// recursively, as if by a call to `destroy_deep(subarray_ref,
274
    /// alloc)`. This is just a shorthand for calling
275
    /// truncate_and_destroy_children(0).
276
    ///
277
    /// This function guarantees that no exceptions will be thrown if
278
    /// get_alloc().is_read_only(get_ref()) would return false before the call.
279
    void clear_and_destroy_children();
280

281
    /// If neccessary, expand the representation so that it can store the
282
    /// specified value.
283
    void ensure_minimum_width(int_fast64_t value);
284

285
    /// Add \a diff to the element at the specified index.
286
    void adjust(size_t ndx, int_fast64_t diff);
287

288
    /// Add \a diff to all the elements in the specified index range.
289
    void adjust(size_t begin, size_t end, int_fast64_t diff);
290

291
    //@{
292
    /// This is similar in spirit to std::move() from `<algorithm>`.
293
    /// \a dest_begin must not be in the range [`begin`,`end`)
294
    ///
295
    /// This function is guaranteed to not throw if
296
    /// `get_alloc().is_read_only(get_ref())` returns false.
297
    void move(size_t begin, size_t end, size_t dest_begin);
298
    //@}
299

300
    // Move elements from ndx and above to another array
301
    void move(Array& dst, size_t ndx);
302

303
    //@{
304
    /// Find the lower/upper bound of the specified value in a sequence of
305
    /// integers which must already be sorted ascendingly.
306
    ///
307
    /// For an integer value '`v`', lower_bound_int(v) returns the index '`l`'
308
    /// of the first element such that `get(l) &ge; v`, and upper_bound_int(v)
309
    /// returns the index '`u`' of the first element such that `get(u) &gt;
310
    /// v`. In both cases, if no such element is found, the returned value is
311
    /// the number of elements in the array.
312
    ///
313
    ///     3 3 3 4 4 4 5 6 7 9 9 9
314
    ///     ^     ^     ^     ^     ^
315
    ///     |     |     |     |     |
316
    ///     |     |     |     |      -- Lower and upper bound of 15
317
    ///     |     |     |     |
318
    ///     |     |     |      -- Lower and upper bound of 8
319
    ///     |     |     |
320
    ///     |     |      -- Upper bound of 4
321
    ///     |     |
322
    ///     |      -- Lower bound of 4
323
    ///     |
324
    ///      -- Lower and upper bound of 1
325
    ///
326
    /// These functions are similar to std::lower_bound() and
327
    /// std::upper_bound().
328
    ///
329
    /// We currently use binary search. See for example
330
    /// http://www.tbray.org/ongoing/When/200x/2003/03/22/Binary.
331
    ///
332
    /// FIXME: It may be worth considering if overall efficiency can be improved
333
    /// by doing a linear search for short sequences.
334
    size_t lower_bound_int(int64_t value) const noexcept;
335
    size_t upper_bound_int(int64_t value) const noexcept;
336
    size_t lower_bound_int_compressed(int64_t value) const noexcept;
337
    size_t upper_bound_int_compressed(int64_t value) const noexcept;
338
    //@}
339

340
    int64_t get_sum(size_t start = 0, size_t end = size_t(-1)) const
341
    {
24,714✔
342
        return sum(start, end);
24,714✔
343
    }
24,714✔
344

345
    /// This information is guaranteed to be cached in the array accessor.
346
    bool is_inner_bptree_node() const noexcept;
347

348
    /// Returns true if type is either type_HasRefs or type_InnerColumnNode.
349
    ///
350
    /// This information is guaranteed to be cached in the array accessor.
351
    bool has_refs() const noexcept;
352
    void set_has_refs(bool) noexcept;
353

354
    /// This information is guaranteed to be cached in the array accessor.
355
    ///
356
    /// Columns and indexes can use the context bit to differentiate leaf types.
357
    bool get_context_flag() const noexcept;
358
    void set_context_flag(bool) noexcept;
359

360
    /// Recursively destroy children (as if calling
361
    /// clear_and_destroy_children()), then put this accessor into the detached
362
    /// state (as if calling detach()), then free the allocated memory. If this
363
    /// accessor is already in the detached state, this function has no effect
364
    /// (idempotency).
365
    void destroy_deep() noexcept;
366

367
    /// check if the array is encoded (in B format)
368
    inline bool is_compressed() const;
369

370
    inline const IntegerCompressor& integer_compressor() const;
371

372
    /// used only for testing, encode the array passed as argument
373
    bool try_compress(Array&) const;
374

375
    /// used only for testing, decode the array, on which this method is invoked. If the array is not encoded, this is
376
    /// a NOP
377
    bool try_decompress();
378

379
    /// Shorthand for `destroy_deep(MemRef(ref, alloc), alloc)`.
380
    static void destroy_deep(ref_type ref, Allocator& alloc) noexcept;
381

382
    /// Destroy the specified array node and all of its children, recursively.
383
    ///
384
    /// This is done by freeing the specified array node after calling
385
    /// destroy_deep() for every contained 'ref' element.
386
    static void destroy_deep(MemRef, Allocator&) noexcept;
387

388
    // Clone deep
389
    static MemRef clone(MemRef, Allocator& from_alloc, Allocator& target_alloc);
390

391
    // Serialization
392

393
    /// Returns the ref (position in the target stream) of the written copy of
394
    /// this array, or the ref of the original array if \a only_if_modified is
395
    /// true, and this array is unmodified (Alloc::is_read_only()).
396
    ///
397
    /// The number of bytes that will be written by a non-recursive invocation
398
    /// of this function is exactly the number returned by get_byte_size().
399
    ///
400
    /// \param out The destination stream (writer).
401
    ///
402
    /// \param deep If true, recursively write out subarrays, but still subject
403
    /// to \a only_if_modified.
404
    ///
405
    /// \param only_if_modified Set to `false` to always write, or to `true` to
406
    /// only write the array if it has been modified.
407
    ref_type write(_impl::ArrayWriterBase& out, bool deep, bool only_if_modified, bool compress_in_flight) const;
408

409
    /// Same as non-static write() with `deep` set to true. This is for the
410
    /// cases where you do not already have an array accessor available.
411
    /// Compression may be attempted if `compress_in_flight` is true.
412
    /// This should be avoided if you rely on the size of the array beeing unchanged.
413
    static ref_type write(ref_type, Allocator&, _impl::ArrayWriterBase&, bool only_if_modified,
414
                          bool compress_in_flight);
415

416
    inline size_t find_first(int64_t value, size_t begin = 0, size_t end = size_t(-1)) const
417
    {
9,136,899✔
418
        return find_first<Equal>(value, begin, end);
9,136,899✔
419
    }
9,136,899✔
420

421
    // Wrappers for backwards compatibility and for simple use without
422
    // setting up state initialization etc
423
    template <class cond>
424
    size_t find_first(int64_t value, size_t start = 0, size_t end = size_t(-1)) const
425
    {
12,527,145✔
426
        static cond c;
12,527,145✔
427
        REALM_ASSERT(start <= m_size && (end <= m_size || end == size_t(-1)) && start <= end);
12,527,145✔
428
        if (end - start == 1) {
12,527,145✔
429
            return c(get(start), value) ? start : realm::not_found;
1,472,829✔
430
        }
1,472,829✔
431
        // todo, would be nice to avoid this in order to speed up find_first loops
432
        QueryStateFindFirst state;
11,054,316✔
433
        Finder finder = m_vtable->finder[cond::condition];
11,054,316✔
434
        finder(*this, value, start, end, 0, &state);
11,054,316✔
435
        return state.m_state;
11,054,316✔
436
    }
12,527,145✔
437

438
    template <class cond>
439
    bool find(int64_t value, size_t start, size_t end, size_t baseIndex, QueryStateBase* state) const
440
    {
6,938,943✔
441
        Finder finder = m_vtable->finder[cond::condition];
6,938,943✔
442
        return finder(*this, value, start, end, baseIndex, state);
6,938,943✔
443
    }
6,938,943✔
444

445

446
    /// Get the specified element without the cost of constructing an
447
    /// array instance. If an array instance is already available, or
448
    /// you need to get multiple values, then this method will be
449
    /// slower.
450
    static int_fast64_t get(const char* header, size_t ndx) noexcept;
451

452
    /// Like get(const char*, size_t) but gets two consecutive
453
    /// elements.
454
    static std::pair<int64_t, int64_t> get_two(const char* header, size_t ndx) noexcept;
455

456
    static RefOrTagged get_as_ref_or_tagged(const char* header, size_t ndx) noexcept
457
    {
70,990,932✔
458
        return get(header, ndx);
70,990,932✔
459
    }
70,990,932✔
460

461
    /// Get the number of bytes currently in use by this array. This
462
    /// includes the array header, but it does not include allocated
463
    /// bytes corresponding to excess capacity. The result is
464
    /// guaranteed to be a multiple of 8 (i.e., 64-bit aligned).
465
    ///
466
    /// This number is exactly the number of bytes that will be
467
    /// written by a non-recursive invocation of write().
468
    size_t get_byte_size() const noexcept;
469

470
    // Get the number of bytes used by this array and its sub-arrays
471
    size_t get_byte_size_deep() const noexcept
472
    {
156✔
473
        size_t mem = 0;
156✔
474
        _mem_usage(mem);
156✔
475
        return mem;
156✔
476
    }
156✔
477

478

479
    /// Get the maximum number of bytes that can be written by a
480
    /// non-recursive invocation of write() on an array with the
481
    /// specified number of elements, that is, the maximum value that
482
    /// can be returned by get_byte_size().
483
    static size_t get_max_byte_size(size_t num_elems) noexcept;
484

485
    /// FIXME: Belongs in IntegerArray
486
    static size_t calc_aligned_byte_size(size_t size, int width);
487

488
#ifdef REALM_DEBUG
489
    class MemUsageHandler {
490
    public:
491
        virtual void handle(ref_type ref, size_t allocated, size_t used) = 0;
492
    };
493

494
    void report_memory_usage(MemUsageHandler&) const;
495

496
    void stats(MemStats& stats_dest) const noexcept;
497
#endif
498

499
    void verify() const;
500

501
    Array& operator=(const Array&) = delete; // not allowed
502
    Array(const Array&) = delete;            // not allowed
503

504
    /// Takes a 64-bit value and returns the minimum number of bits needed
505
    /// to fit the value. For alignment this is rounded up to nearest
506
    /// log2. Possible results {0, 1, 2, 4, 8, 16, 32, 64}
507
    static uint8_t bit_width(int64_t value);
508

509
protected:
510
    friend class NodeTree;
511
    void copy_on_write();
512
    void copy_on_write(size_t min_size);
513

514
    // This returns the minimum value ("lower bound") of the representable values
515
    // for the given bit width. Valid widths are 0, 1, 2, 4, 8, 16, 32, and 64.
516
    static constexpr int_fast64_t lbound_for_width(size_t width) noexcept;
517

518
    // This returns the maximum value ("inclusive upper bound") of the representable values
519
    // for the given bit width. Valid widths are 0, 1, 2, 4, 8, 16, 32, and 64.
520
    static constexpr int_fast64_t ubound_for_width(size_t width) noexcept;
521

522
    // This will have to be eventually used, exposing this here for testing.
523
    size_t count(int64_t value) const noexcept;
524

525
private:
526
    void update_width_cache_from_header() noexcept;
527

528
    void do_ensure_minimum_width(int_fast64_t);
529

530
    int64_t sum(size_t start, size_t end) const;
531

532
    template <size_t w>
533
    int64_t sum(size_t start, size_t end) const;
534

535
protected:
536
    /// It is an error to specify a non-zero value unless the width
537
    /// type is wtype_Bits. It is also an error to specify a non-zero
538
    /// size if the width type is wtype_Ignore.
539
    static MemRef create(Type, bool, WidthType, size_t, int_fast64_t, Allocator&);
540

541
    // Overriding method in ArrayParent
542
    void update_child_ref(size_t, ref_type) override;
543

544
    // Overriding method in ArrayParent
545
    ref_type get_child_ref(size_t) const noexcept override;
546

547
    void destroy_children(size_t offset = 0) noexcept;
548

549
protected:
550
    // Getters and Setters for adaptive-packed arrays
551
    typedef int64_t (*Getter)(const Array&, size_t); // Note: getters must not throw
552
    typedef void (*Setter)(Array&, size_t, int64_t);
553
    typedef bool (*Finder)(const Array&, int64_t, size_t, size_t, size_t, QueryStateBase*);
554
    typedef void (*ChunkGetter)(const Array&, size_t, int64_t res[8]); // Note: getters must not throw
555

556
    typedef std::vector<int64_t> (*GetterAll)(const Array&, size_t, size_t); // Note: getters must not throw
557

558
    struct VTable {
559
        Getter getter;
560
        ChunkGetter chunk_getter;
561
        GetterAll getter_all;
562
        Setter setter;
563
        Finder finder[cond_VTABLE_FINDER_COUNT]; // one for each active function pointer
564
    };
565
    template <size_t w>
566
    struct VTableForWidth;
567

568
    // This is the one installed into the m_vtable->finder slots.
569
    template <class cond>
570
    static bool find_vtable(const Array&, int64_t value, size_t start, size_t end, size_t baseindex,
571
                            QueryStateBase* state);
572

573
    template <size_t w>
574
    static int64_t get_universal(const char* const data, const size_t ndx);
575

576
protected:
577
    Getter m_getter = nullptr; // cached to avoid indirection
578
    const VTable* m_vtable = nullptr;
579

580
    uint_least8_t m_width = 0; // Size of an element (meaning depend on type of array).
581
    int64_t m_lbound;          // min number that can be stored with current m_width
582
    int64_t m_ubound;          // max number that can be stored with current m_width
583

584
    bool m_is_inner_bptree_node; // This array is an inner node of B+-tree.
585
    bool m_has_refs;             // Elements whose first bit is zero are refs to subarrays.
586
    bool m_context_flag;         // Meaning depends on context.
587

588
    IntegerCompressor m_integer_compressor;
589
    // compress/decompress this array
590
    bool compress_array(Array&) const;
591
    bool decompress_array(Array& arr) const;
592

593
private:
594
    ref_type do_write_shallow(_impl::ArrayWriterBase&) const;
595
    ref_type do_write_deep(_impl::ArrayWriterBase&, bool only_if_modified, bool compress) const;
596

597
    void _mem_usage(size_t& mem) const noexcept;
598

599
#ifdef REALM_DEBUG
600
    void report_memory_usage_2(MemUsageHandler&) const;
601
#endif
602

603

604
private:
605
    friend class Allocator;
606
    friend class SlabAlloc;
607
    friend class GroupWriter;
608
    friend class ArrayWithFind;
609
    friend class IntegerCompressor;
610
    friend class PackedCompressor;
611
    friend class FlexCompressor;
612
};
613

614
class TempArray : public Array {
615
public:
616
    TempArray(size_t sz, Type type = Type::type_HasRefs, bool cf = false)
617
        : Array(Allocator::get_default())
1,529,748✔
618
    {
3,072,963✔
619
        create(type, cf, sz);
3,072,963✔
620
    }
3,072,963✔
621
    ~TempArray()
622
    {
3,073,215✔
623
        destroy();
3,073,215✔
624
    }
3,073,215✔
625
    ref_type write(_impl::ArrayWriterBase& out)
626
    {
3,073,140✔
627
        return Array::write(out, false, false, false);
3,073,140✔
628
    }
3,073,140✔
629
};
630

631
// Implementation:
632

633
inline Array::Array(Allocator& allocator) noexcept
634
    : Node(allocator)
457,735,584✔
635
{
924,754,509✔
636
}
924,754,509✔
637

638
inline bool Array::is_compressed() const
639
{
987,815,220✔
640
    const auto enc = m_integer_compressor.get_encoding();
987,815,220✔
641
    return enc == NodeHeader::Encoding::Flex || enc == NodeHeader::Encoding::Packed;
988,138,059✔
642
}
987,815,220✔
643

644
inline const IntegerCompressor& Array::integer_compressor() const
645
{
3,925,329✔
646
    return m_integer_compressor;
3,925,329✔
647
}
3,925,329✔
648

649
inline int64_t Array::get(size_t ndx) const noexcept
650
{
2,662,221,951✔
651
    REALM_ASSERT_DEBUG(is_attached());
2,662,221,951✔
652
    REALM_ASSERT_DEBUG_EX(ndx < m_size, ndx, m_size);
2,662,221,951✔
653
    return m_getter(*this, ndx);
2,662,221,951✔
654

655
    // Two ideas that are not efficient but may be worth looking into again:
656
    /*
657
        // Assume correct width is found early in REALM_TEMPEX, which is the case for B tree offsets that
658
        // are probably either 2^16 long. Turns out to be 25% faster if found immediately, but 50-300% slower
659
        // if found later
660
        REALM_TEMPEX(return get, (ndx));
661
    */
662
    /*
663
        // Slightly slower in both of the if-cases. Also needs an matchcount m_size check too, to avoid
664
        // reading beyond array.
665
        if (m_width >= 8 && m_size > ndx + 7)
666
            return get<64>(ndx >> m_shift) & m_widthmask;
667
        else
668
            return (this->*(m_vtable->getter))(ndx);
669
    */
670
}
2,662,221,951✔
671

672
inline std::vector<int64_t> Array::get_all(size_t b, size_t e) const
673
{
2✔
674
    REALM_ASSERT_DEBUG(is_compressed());
2✔
675
    return m_vtable->getter_all(*this, b, e);
2✔
676
}
2✔
677

678
template <size_t w>
679
inline int64_t Array::get(const Array& arr, size_t ndx) noexcept
680
{
3,771,619,849✔
681
    REALM_ASSERT_DEBUG(arr.is_attached());
3,771,619,849✔
682
    return get_universal<w>(arr.m_data, ndx);
3,771,619,849✔
683
}
3,771,619,849✔
684

685
constexpr inline int_fast64_t Array::lbound_for_width(size_t width) noexcept
686
{
1,665,628,473✔
687
    if (width == 32) {
1,665,628,473✔
688
        return -0x80000000LL;
678,679,620✔
689
    }
678,679,620✔
690
    else if (width == 16) {
986,948,853✔
691
        return -0x8000LL;
348,395,223✔
692
    }
348,395,223✔
693
    else if (width < 8) {
638,553,630✔
694
        return 0;
411,602,037✔
695
    }
411,602,037✔
696
    else if (width == 8) {
226,951,593✔
697
        return -0x80LL;
154,798,335✔
698
    }
154,798,335✔
699
    else if (width == 64) {
240,500,469✔
700
        return -0x8000000000000000LL;
240,500,469✔
701
    }
240,500,469✔
702
    else {
4,294,967,294✔
703
        REALM_UNREACHABLE();
704
    }
4,294,967,294✔
705
}
1,665,628,473✔
706

707
constexpr inline int_fast64_t Array::ubound_for_width(size_t width) noexcept
708
{
1,674,449,919✔
709
    if (width == 32) {
1,674,449,919✔
710
        return 0x7FFFFFFFLL;
680,395,785✔
711
    }
680,395,785✔
712
    else if (width == 16) {
994,054,134✔
713
        return 0x7FFFLL;
350,009,112✔
714
    }
350,009,112✔
715
    else if (width == 0) {
644,045,022✔
716
        return 0;
66,437,535✔
717
    }
66,437,535✔
718
    else if (width == 1) {
577,607,487✔
719
        return 1;
181,795,788✔
720
    }
181,795,788✔
721
    else if (width == 2) {
395,811,699✔
722
        return 3;
153,307,725✔
723
    }
153,307,725✔
724
    else if (width == 4) {
242,503,974✔
725
        return 15;
19,318,311✔
726
    }
19,318,311✔
727
    else if (width == 8) {
223,185,663✔
728
        return 0x7FLL;
154,898,904✔
729
    }
154,898,904✔
730
    else if (width == 64) {
240,830,067✔
731
        return 0x7FFFFFFFFFFFFFFFLL;
240,830,067✔
732
    }
240,830,067✔
733
    else {
4,294,967,294✔
734
        REALM_UNREACHABLE();
735
    }
4,294,967,294✔
736
}
1,674,449,919✔
737

738
inline bool RefOrTagged::is_ref() const noexcept
739
{
494,489,424✔
740
    return (m_value & 1) == 0;
494,489,424✔
741
}
494,489,424✔
742

743
inline bool RefOrTagged::is_tagged() const noexcept
744
{
425,229,966✔
745
    return !is_ref();
425,229,966✔
746
}
425,229,966✔
747

748
inline ref_type RefOrTagged::get_as_ref() const noexcept
749
{
102,053,598✔
750
    // to_ref() is defined in <alloc.hpp>
751
    return to_ref(m_value);
102,053,598✔
752
}
102,053,598✔
753

754
inline uint_fast64_t RefOrTagged::get_as_int() const noexcept
755
{
113,544,936✔
756
    // The bitwise AND is there in case uint_fast64_t is wider than 64 bits.
757
    return (uint_fast64_t(m_value) & 0xFFFFFFFFFFFFFFFFULL) >> 1;
113,544,936✔
758
}
113,544,936✔
759

760
inline RefOrTagged RefOrTagged::make_ref(ref_type ref) noexcept
761
{
334,749✔
762
    // from_ref() is defined in <alloc.hpp>
763
    int_fast64_t value = from_ref(ref);
334,749✔
764
    return RefOrTagged(value);
334,749✔
765
}
334,749✔
766

767
inline RefOrTagged RefOrTagged::make_tagged(uint_fast64_t i) noexcept
768
{
25,146,690✔
769
    REALM_ASSERT(i < (1ULL << 63));
25,146,690✔
770
    return RefOrTagged((i << 1) | 1);
25,146,690✔
771
}
25,146,690✔
772

773
inline RefOrTagged::RefOrTagged(int_fast64_t value) noexcept
774
    : m_value(value)
257,500,587✔
775
{
531,486,201✔
776
}
531,486,201✔
777

778
inline void Array::create(Type type, bool context_flag, size_t length, int_fast64_t value)
779
{
11,616,003✔
780
    MemRef mem = create_array(type, context_flag, length, value, m_alloc); // Throws
11,616,003✔
781
    init_from_mem(mem);
11,616,003✔
782
}
11,616,003✔
783

784
inline Array::Type Array::get_type() const noexcept
785
{
18✔
786
    if (m_is_inner_bptree_node) {
18✔
787
        REALM_ASSERT_DEBUG(m_has_refs);
6✔
788
        return type_InnerBptreeNode;
6✔
789
    }
6✔
790
    if (m_has_refs)
12✔
791
        return type_HasRefs;
6✔
792
    return type_Normal;
6✔
793
}
12✔
794

795

796
inline void Array::get_chunk(size_t ndx, int64_t res[8]) const noexcept
797
{
2,614,932✔
798
    REALM_ASSERT_DEBUG(ndx < m_size);
2,614,932✔
799
    m_vtable->chunk_getter(*this, ndx, res);
2,614,932✔
800
}
2,614,932✔
801

802
template <size_t w>
803
inline int64_t Array::get_universal(const char* data, size_t ndx)
804
{
3,752,260,321✔
805
    if (w == 64) {
3,752,260,321✔
806
        size_t offset = ndx << 3;
896,846,517✔
807
        return *reinterpret_cast<const int64_t*>(data + offset);
896,846,517✔
808
    }
896,846,517✔
809
    else if (w == 32) {
3,306,465,784✔
810
        size_t offset = ndx << 2;
2,891,566,108✔
811
        return *reinterpret_cast<const int32_t*>(data + offset);
2,891,566,108✔
812
    }
2,891,566,108✔
813
    else if (w == 16) {
883,734,585✔
814
        size_t offset = ndx << 1;
547,624,614✔
815
        return *reinterpret_cast<const int16_t*>(data + offset);
547,624,614✔
816
    }
547,624,614✔
817
    else if (w == 8) {
336,109,971✔
818
        return *reinterpret_cast<const signed char*>(data + ndx);
70,979,196✔
819
    }
70,979,196✔
820
    else if (w == 4) {
265,130,775✔
821
        size_t offset = ndx >> 1;
40,653,405✔
822
        auto d = data[offset];
40,653,405✔
823
        return (d >> ((ndx & 1) << 2)) & 0x0F;
40,653,405✔
824
    }
40,653,405✔
825
    else if (w == 2) {
224,477,370✔
826
        size_t offset = ndx >> 2;
72,732,735✔
827
        auto d = data[offset];
72,732,735✔
828
        return (d >> ((ndx & 3) << 1)) & 0x03;
72,732,735✔
829
    }
72,732,735✔
830
    else if (w == 1) {
151,744,635✔
831
        size_t offset = ndx >> 3;
56,986,584✔
832
        auto d = data[offset];
56,986,584✔
833
        return (d >> (ndx & 7)) & 0x01;
56,986,584✔
834
    }
56,986,584✔
835
    else if (w == 0) {
96,835,821✔
836
        return 0;
96,577,557✔
837
    }
96,577,557✔
838
    else {
2,147,741,911✔
839
        REALM_ASSERT_DEBUG(false);
2,147,741,911✔
840
        return int64_t(-1);
2,147,741,911✔
841
    }
2,147,741,911✔
842
}
3,752,260,321✔
843

844
inline int64_t Array::front() const noexcept
UNCOV
845
{
×
846
    return get(0);
×
847
}
×
848

849
inline int64_t Array::back() const noexcept
850
{
48,013,140✔
851
    return get(m_size - 1);
48,013,140✔
852
}
48,013,140✔
853

854
inline ref_type Array::get_as_ref(size_t ndx) const noexcept
855
{
861,858,432✔
856
    REALM_ASSERT_DEBUG(is_attached());
861,858,432✔
857
    REALM_ASSERT_DEBUG_EX(m_has_refs, m_ref, ndx, m_size);
861,858,432✔
858
    int64_t v = get(ndx);
861,858,432✔
859
    return to_ref(v);
861,858,432✔
860
}
861,858,432✔
861

862
inline RefOrTagged Array::get_as_ref_or_tagged(size_t ndx) const noexcept
863
{
445,164,684✔
864
    REALM_ASSERT(has_refs());
445,164,684✔
865
    return RefOrTagged(get(ndx));
445,164,684✔
866
}
445,164,684✔
867

868
inline void Array::set(size_t ndx, RefOrTagged ref_or_tagged)
869
{
34,420,194✔
870
    REALM_ASSERT(has_refs());
34,420,194✔
871
    set(ndx, ref_or_tagged.m_value); // Throws
34,420,194✔
872
}
34,420,194✔
873

874
inline void Array::add(RefOrTagged ref_or_tagged)
875
{
1,693,464✔
876
    REALM_ASSERT(has_refs());
1,693,464✔
877
    add(ref_or_tagged.m_value); // Throws
1,693,464✔
878
}
1,693,464✔
879

880
inline void Array::ensure_minimum_width(RefOrTagged ref_or_tagged)
881
{
678✔
882
    REALM_ASSERT(has_refs());
678✔
883
    ensure_minimum_width(ref_or_tagged.m_value); // Throws
678✔
884
}
678✔
885

886
inline bool Array::is_inner_bptree_node() const noexcept
887
{
25,778,643✔
888
    return m_is_inner_bptree_node;
25,778,643✔
889
}
25,778,643✔
890

891
inline bool Array::has_refs() const noexcept
892
{
492,871,473✔
893
    return m_has_refs;
492,871,473✔
894
}
492,871,473✔
895

896
inline void Array::set_has_refs(bool value) noexcept
897
{
×
898
    if (m_has_refs != value) {
×
899
        REALM_ASSERT(!is_read_only());
×
900
        m_has_refs = value;
×
901
        set_hasrefs_in_header(value, get_header());
×
902
    }
×
903
}
×
904

905
inline bool Array::get_context_flag() const noexcept
906
{
33,943,803✔
907
    return m_context_flag;
33,943,803✔
908
}
33,943,803✔
909

910
inline void Array::set_context_flag(bool value) noexcept
911
{
711,348✔
912
    if (m_context_flag != value) {
711,348✔
913
        copy_on_write();
711,300✔
914
        m_context_flag = value;
711,300✔
915
        set_context_flag_in_header(value, get_header());
711,300✔
916
    }
711,300✔
917
}
711,348✔
918

919
inline void Array::destroy_deep() noexcept
920
{
753,906✔
921
    if (!is_attached())
753,906✔
922
        return;
684✔
923

924
    if (m_has_refs)
753,222✔
925
        destroy_children();
752,004✔
926

927
    char* header = get_header_from_data(m_data);
753,222✔
928
    m_alloc.free_(m_ref, header);
753,222✔
929
    m_data = nullptr;
753,222✔
930
}
753,222✔
931

932
inline void Array::add(int_fast64_t value)
933
{
846,152,070✔
934
    insert(m_size, value);
846,152,070✔
935
}
846,152,070✔
936

937
inline void Array::erase(size_t ndx)
938
{
11,645,877✔
939
    // This can throw, but only if array is currently in read-only
940
    // memory.
941
    move(ndx + 1, size(), ndx);
11,645,877✔
942

943
    // Update size (also in header)
944
    --m_size;
11,645,877✔
945
    set_header_size(m_size);
11,645,877✔
946
}
11,645,877✔
947

948

949
inline void Array::erase(size_t begin, size_t end)
950
{
×
951
    if (begin != end) {
×
952
        // This can throw, but only if array is currently in read-only memory.
953
        move(end, size(), begin); // Throws
×
954

955
        // Update size (also in header)
956
        m_size -= end - begin;
×
957
        set_header_size(m_size);
×
958
    }
×
959
}
×
960

961
inline void Array::clear()
962
{
2,067,027✔
963
    truncate(0); // Throws
2,067,027✔
964
}
2,067,027✔
965

966
inline void Array::clear_and_destroy_children()
967
{
19,884✔
968
    truncate_and_destroy_children(0);
19,884✔
969
}
19,884✔
970

971
inline void Array::destroy_deep(ref_type ref, Allocator& alloc) noexcept
972
{
2,640,051✔
973
    destroy_deep(MemRef(ref, alloc), alloc);
2,640,051✔
974
}
2,640,051✔
975

976
inline void Array::destroy_deep(MemRef mem, Allocator& alloc) noexcept
977
{
2,640,468✔
978
    if (!get_hasrefs_from_header(mem.get_addr())) {
2,640,468✔
979
        alloc.free_(mem);
1,964,025✔
980
        return;
1,964,025✔
981
    }
1,964,025✔
982
    Array array(alloc);
676,443✔
983
    array.init_from_mem(mem);
676,443✔
984
    array.destroy_deep();
676,443✔
985
}
676,443✔
986

987

988
inline void Array::adjust(size_t ndx, int_fast64_t diff)
989
{
54,306,654✔
990
    REALM_ASSERT_3(ndx, <=, m_size);
54,306,654✔
991
    if (diff != 0) {
54,344,901✔
992
        // FIXME: Should be optimized
993
        int_fast64_t v = get(ndx);
54,344,901✔
994
        set(ndx, int64_t(v + diff)); // Throws
54,344,901✔
995
    }
54,344,901✔
996
}
54,306,654✔
997

998
inline void Array::adjust(size_t begin, size_t end, int_fast64_t diff)
999
{
2,370,180✔
1000
    if (diff != 0) {
2,370,180✔
1001
        // FIXME: Should be optimized
1002
        for (size_t i = begin; i != end; ++i)
16,669,146✔
1003
            adjust(i, diff); // Throws
15,056,166✔
1004
    }
1,612,980✔
1005
}
2,370,180✔
1006

1007

1008
//-------------------------------------------------
1009

1010

1011
inline size_t Array::get_byte_size() const noexcept
1012
{
34,820,691✔
1013
    const char* header = get_header_from_data(m_data);
34,820,691✔
1014
    size_t num_bytes = NodeHeader::get_byte_size_from_header(header);
34,820,691✔
1015

1016
    REALM_ASSERT_7(m_alloc.is_read_only(m_ref), ==, true, ||, num_bytes, <=, get_capacity_from_header(header));
34,820,691✔
1017

1018
    return num_bytes;
34,820,691✔
1019
}
34,820,691✔
1020

1021

1022
//-------------------------------------------------
1023

1024
inline MemRef Array::create_empty_array(Type type, bool context_flag, Allocator& alloc)
1025
{
1,821,426✔
1026
    size_t size = 0;
1,821,426✔
1027
    int_fast64_t value = 0;
1,821,426✔
1028
    return create_array(type, context_flag, size, value, alloc); // Throws
1,821,426✔
1029
}
1,821,426✔
1030

1031
inline MemRef Array::create_array(Type type, bool context_flag, size_t size, int_fast64_t value, Allocator& alloc)
1032
{
13,767,882✔
1033
    return create(type, context_flag, wtype_Bits, size, value, alloc); // Throws
13,767,882✔
1034
}
13,767,882✔
1035

1036
inline size_t Array::get_max_byte_size(size_t num_elems) noexcept
1037
{
615,558✔
1038
    int max_bytes_per_elem = 8;
615,558✔
1039
    return header_size + num_elems * max_bytes_per_elem;
615,558✔
1040
}
615,558✔
1041

1042
inline void Array::update_child_ref(size_t child_ndx, ref_type new_ref)
1043
{
16,992,891✔
1044
    set(child_ndx, new_ref);
16,992,891✔
1045
}
16,992,891✔
1046

1047
inline ref_type Array::get_child_ref(size_t child_ndx) const noexcept
1048
{
148,569,384✔
1049
    return get_as_ref(child_ndx);
148,569,384✔
1050
}
148,569,384✔
1051

1052
inline void Array::ensure_minimum_width(int_fast64_t value)
1053
{
209,916,045✔
1054
    if (value >= m_lbound && value <= m_ubound)
209,916,045✔
1055
        return;
200,719,212✔
1056
    do_ensure_minimum_width(value);
9,196,833✔
1057
}
9,196,833✔
1058

1059
inline ref_type Array::write(_impl::ArrayWriterBase& out, bool deep, bool only_if_modified,
1060
                             bool compress_in_flight) const
1061
{
8,869,515✔
1062
    REALM_ASSERT_DEBUG(is_attached());
8,869,515✔
1063
    // The default allocator cannot be trusted wrt is_read_only():
1064
    REALM_ASSERT_DEBUG(!only_if_modified || &m_alloc != &Allocator::get_default());
8,869,515✔
1065
    if (only_if_modified && m_alloc.is_read_only(m_ref))
8,869,515✔
1066
        return m_ref;
2,483,559✔
1067

1068
    if (!deep || !m_has_refs) {
6,385,956✔
1069
        // however - creating an array using ANYTHING BUT the default allocator during commit is also wrong....
1070
        // it only works by accident, because the whole slab area is reinitialized after commit.
1071
        // We should have: Array encoded_array{Allocator::get_default()};
1072
        Array compressed_array{Allocator::get_default()};
5,201,916✔
1073
        if (compress_in_flight && compress_array(compressed_array)) {
5,201,916✔
1074
#ifdef REALM_DEBUG
103,080✔
1075
            const auto encoding = compressed_array.m_integer_compressor.get_encoding();
103,080✔
1076
            REALM_ASSERT_DEBUG(encoding == Encoding::Flex || encoding == Encoding::Packed);
103,080✔
1077
            REALM_ASSERT_DEBUG(size() == compressed_array.size());
103,080✔
1078
            for (size_t i = 0; i < compressed_array.size(); ++i) {
14,329,395✔
1079
                REALM_ASSERT_DEBUG(get(i) == compressed_array.get(i));
14,226,315✔
1080
            }
14,226,315✔
1081
#endif
103,080✔
1082
            auto ref = compressed_array.do_write_shallow(out);
103,080✔
1083
            compressed_array.destroy();
103,080✔
1084
            return ref;
103,080✔
1085
        }
103,080✔
1086
        return do_write_shallow(out); // Throws
5,098,836✔
1087
    }
5,201,916✔
1088

1089
    return do_write_deep(out, only_if_modified, compress_in_flight); // Throws
1,184,040✔
1090
}
6,385,956✔
1091

1092
inline ref_type Array::write(ref_type ref, Allocator& alloc, _impl::ArrayWriterBase& out, bool only_if_modified,
1093
                             bool compress_in_flight)
1094
{
68,718,945✔
1095
    // The default allocator cannot be trusted wrt is_read_only():
1096
    REALM_ASSERT_DEBUG(!only_if_modified || &alloc != &Allocator::get_default());
68,718,945✔
1097
    if (only_if_modified && alloc.is_read_only(ref))
68,882,658✔
1098
        return ref;
55,678,599✔
1099

1100
    Array array(alloc);
13,040,346✔
1101
    array.init_from_ref(ref);
13,040,346✔
1102
    REALM_ASSERT_DEBUG(array.is_attached());
13,040,346✔
1103

1104
    if (!array.m_has_refs) {
13,040,346✔
1105
        Array compressed_array{Allocator::get_default()};
11,856,324✔
1106
        if (compress_in_flight && array.compress_array(compressed_array)) {
11,856,324✔
1107
#ifdef REALM_DEBUG
9,378✔
1108
            const auto encoding = compressed_array.m_integer_compressor.get_encoding();
9,378✔
1109
            REALM_ASSERT_DEBUG(encoding == Encoding::Flex || encoding == Encoding::Packed);
9,378✔
1110
            REALM_ASSERT_DEBUG(array.size() == compressed_array.size());
9,378✔
1111
            for (size_t i = 0; i < compressed_array.size(); ++i) {
2,502,939✔
1112
                REALM_ASSERT_DEBUG(array.get(i) == compressed_array.get(i));
2,493,561✔
1113
            }
2,493,561✔
1114
#endif
9,378✔
1115
            auto ref = compressed_array.do_write_shallow(out);
9,378✔
1116
            compressed_array.destroy();
9,378✔
1117
            return ref;
9,378✔
1118
        }
9,378✔
1119
        else {
11,846,946✔
1120
            return array.do_write_shallow(out); // Throws
11,846,946✔
1121
        }
11,846,946✔
1122
    }
11,856,324✔
1123
    return array.do_write_deep(out, only_if_modified, compress_in_flight); // Throws
1,184,022✔
1124
}
13,040,346✔
1125

1126

1127
} // namespace realm
1128

1129
#endif // REALM_ARRAY_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