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

realm / realm-core / 2466

02 Jul 2024 04:06AM UTC coverage: 90.974% (-0.2%) from 91.147%
2466

push

Evergreen

web-flow
Merge pull request #7576 from realm/tg/multi-process-launch-actions

RCORE-1900 Make "next launch" metadata actions multiprocess-safe

102260 of 180446 branches covered (56.67%)

348 of 356 new or added lines in 15 files covered. (97.75%)

334 existing lines in 18 files now uncovered.

215128 of 236473 relevant lines covered (90.97%)

5909897.4 hits per line

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

98.48
/src/realm/chunked_binary.cpp
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
#include <realm/chunked_binary.hpp>
20
#include <realm/util/hex_dump.hpp>
21

22
using namespace realm;
23

24
BinaryIterator ChunkedBinaryData::iterator() const noexcept
25
{
1,301,292✔
26
    return m_begin;
1,301,292✔
27
}
1,301,292✔
28

29
size_t ChunkedBinaryData::size() const noexcept
30
{
3,129,834✔
31
    BinaryIterator copy = m_begin;
3,129,834✔
32
    size_t result = 0;
3,129,834✔
33
    BinaryData chunk;
3,129,834✔
34
    do {
5,256,822✔
35
        chunk = copy.get_next();
5,256,822✔
36
        result += chunk.size();
5,256,822✔
37
    } while (chunk.size() > 0);
5,256,822✔
38
    return result;
3,129,834✔
39
}
3,129,834✔
40

41
bool ChunkedBinaryData::is_null() const
42
{
503,745✔
43
    BinaryIterator copy = m_begin;
503,745✔
44
    BinaryData chunk = copy.get_next();
503,745✔
45
    return chunk.is_null();
503,745✔
46
}
503,745✔
47

48
bool ChunkedBinaryData::empty() const
49
{
305,715✔
50
    BinaryIterator copy = m_begin;
305,715✔
51
    BinaryData chunk = copy.get_next();
305,715✔
52
    return chunk.size() == 0;
305,715✔
53
}
305,715✔
54

55
char ChunkedBinaryData::operator[](size_t index) const
56
{
54✔
57
    BinaryIterator copy = m_begin;
54✔
58
    size_t i = index;
54✔
59
    BinaryData chunk;
54✔
60
    do {
66✔
61
        chunk = copy.get_next();
66✔
62
        if (chunk.size() > i) {
66✔
63
            return chunk[i];
54✔
64
        }
54✔
65
        i -= chunk.size();
12✔
66
    } while (chunk.size() != 0);
12✔
67

UNCOV
68
    throw RuntimeError(ErrorCodes::RangeError, "Offset is out of range");
×
69
}
54✔
70

71
std::string ChunkedBinaryData::hex_dump(const char* separator, int min_digits) const
72
{
6✔
73
    BinaryIterator copy = m_begin;
6✔
74
    BinaryData chunk;
6✔
75
    std::string dump; // FIXME: Reserve memory
6✔
76
    while (!(chunk = copy.get_next()).is_null()) {
12✔
77
        dump += util::hex_dump(chunk.data(), chunk.size(), separator, min_digits);
6✔
78
    }
6✔
79
    return dump;
6✔
80
}
6✔
81

82
void ChunkedBinaryData::write_to(util::ResettableExpandableBufferOutputStream& out) const
83
{
129,489✔
84
    BinaryIterator copy = m_begin;
129,489✔
85
    BinaryData chunk;
129,489✔
86
    while (!(chunk = copy.get_next()).is_null()) {
258,978✔
87
        out.write(chunk.data(), chunk.size());
129,489✔
88
    }
129,489✔
89
}
129,489✔
90

91
void ChunkedBinaryData::copy_to(util::AppendBuffer<char>& dest) const
92
{
12✔
93
    size_t sz = size();
12✔
94
    dest.resize(sz);
12✔
95
    util::Span out(dest);
12✔
96

97
    BinaryIterator copy = m_begin;
12✔
98
    BinaryData chunk;
12✔
99
    while (!(chunk = copy.get_next()).is_null()) {
24✔
100
        std::copy(chunk.data(), chunk.data() + chunk.size(), out.data());
12✔
101
        out = out.sub_span(chunk.size());
12✔
102
    }
12✔
103
}
12✔
104

105
// get_first_chunk() is used in situations
106
// where it is known that there is exactly one
107
// chunk. This is the case if the ChunkedBinaryData
108
// has been constructed from BinaryData.
109
BinaryData ChunkedBinaryData::get_first_chunk() const
110
{
266,169✔
111
    return m_begin.get_only();
266,169✔
112
}
266,169✔
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