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

realm / realm-core / github_pull_request_281750

30 Oct 2023 03:37PM UTC coverage: 90.528% (-1.0%) from 91.571%
github_pull_request_281750

Pull #6073

Evergreen

jedelbo
Log free space and history sizes when opening file
Pull Request #6073: Merge next-major

95488 of 175952 branches covered (0.0%)

8973 of 12277 new or added lines in 149 files covered. (73.09%)

622 existing lines in 51 files now uncovered.

233503 of 257934 relevant lines covered (90.53%)

6533720.56 hits per line

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

88.89
/src/realm/array_decimal128.hpp
1
/*************************************************************************
2
 *
3
 * Copyright 2019 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_DECIMAL128_HPP
20
#define REALM_ARRAY_DECIMAL128_HPP
21

22
#include <realm/array.hpp>
23
#include <realm/decimal128.hpp>
24

25
namespace realm {
26

27
class ArrayDecimal128 : public ArrayPayload, private Array {
28
public:
29
    using value_type = Decimal128;
30

31
    using Array::Array;
32
    using Array::destroy;
33
    using Array::get_ref;
34
    using Array::init_from_mem;
35
    using Array::init_from_parent;
36
    using Array::size;
37
    using Array::truncate;
38
    using Array::update_parent;
39
    using Array::verify;
40

41
    static Decimal128 default_value(bool nullable)
42
    {
81,048✔
43
        return nullable ? Decimal128(realm::null()) : Decimal128(0);
62,601✔
44
    }
81,048✔
45

46
    void create()
47
    {
18,990✔
48
        auto mem = Array::create(type_Normal, false, wtype_Multiply, 0, 0, m_alloc); // Throws
18,990✔
49
        Array::init_from_mem(mem);
18,990✔
50
    }
18,990✔
51

52
    void init_from_ref(ref_type ref) noexcept override
53
    {
611,103✔
54
        Array::init_from_ref(ref);
611,103✔
55
    }
611,103✔
56

57
    void set_parent(ArrayParent* parent, size_t ndx_in_parent) noexcept override
58
    {
667,950✔
59
        Array::set_parent(parent, ndx_in_parent);
667,950✔
60
    }
667,950✔
61

62
    bool is_null(size_t ndx) const
63
    {
11,031✔
64
        if (m_width == 0) {
11,031✔
65
            return !get_context_flag();
183✔
66
        }
183✔
67
        return get(ndx).is_null();
10,848✔
68
    }
10,848✔
69

70
    Decimal128 get(size_t ndx) const
71
    {
2,686,503✔
72
        REALM_ASSERT(ndx < m_size);
2,686,503✔
73
        switch (m_width) {
2,686,503✔
74
            case 0:
28,536✔
75
                return get_context_flag() ? Decimal128() : Decimal128(realm::null());
27,486✔
76
            case 4: {
543,843✔
77
                auto values = reinterpret_cast<Decimal128::Bid32*>(this->m_data);
543,843✔
78
                return Decimal128(values[ndx]);
543,843✔
NEW
79
            }
×
80
            case 8: {
720✔
81
                auto values = reinterpret_cast<Decimal128::Bid64*>(this->m_data);
720✔
82
                return Decimal128(values[ndx]);
720✔
NEW
83
            }
×
84
            case 16: {
2,113,404✔
85
                auto values = reinterpret_cast<Decimal128*>(this->m_data);
2,113,404✔
86
                return values[ndx];
2,113,404✔
NEW
87
            }
×
NEW
88
        }
×
NEW
89
        return {};
×
UNCOV
90
    }
×
91

92
    Mixed get_any(size_t ndx) const override;
93

94
    void add(Decimal128 value)
95
    {
276✔
96
        insert(size(), value);
276✔
97
    }
276✔
98

99
    void set(size_t ndx, Decimal128 value);
100
    void set_null(size_t ndx)
101
    {
1,830✔
102
        set(ndx, Decimal128(realm::null()));
1,830✔
103
    }
1,830✔
104

105
    void insert(size_t ndx, Decimal128 value);
106
    void erase(size_t ndx);
107
    void move(ArrayDecimal128& dst, size_t ndx);
108
    void clear()
109
    {
420✔
110
        truncate(0);
420✔
111
    }
420✔
112

113
    size_t find_first(Decimal128 value, size_t begin = 0, size_t end = npos) const noexcept;
114

115
    uint8_t get_width() const noexcept
116
    {
12✔
117
        return m_width;
12✔
118
    }
12✔
119

120
protected:
121
    size_t calc_byte_len(size_t num_items, size_t) const override
122
    {
218,604✔
123
        return num_items * sizeof(Decimal128) + header_size;
218,604✔
124
    }
218,604✔
125
    size_t upgrade_leaf(uint8_t width);
126
};
127

128
} // namespace realm
129

130
#endif /* REALM_ARRAY_DECIMAL128_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