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

realm / realm-core / jorgen.edelbo_337

03 Jul 2024 01:04PM UTC coverage: 90.864% (-0.1%) from 90.984%
jorgen.edelbo_337

Pull #7826

Evergreen

nicola-cab
Merge branch 'master' of github.com:realm/realm-core into next-major
Pull Request #7826: Merge Next major

102968 of 181176 branches covered (56.83%)

3131 of 3738 new or added lines in 54 files covered. (83.76%)

106 existing lines in 23 files now uncovered.

217725 of 239616 relevant lines covered (90.86%)

6844960.2 hits per line

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

86.96
/src/realm/integer_flex_compressor.cpp
1
/*************************************************************************
2
 *
3
 * Copyright 2023 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#include <realm/integer_flex_compressor.hpp>
20
#include <realm/node_header.hpp>
21
#include <realm/array_direct.hpp>
22

23
#include <vector>
24
#include <algorithm>
25

26
#ifdef REALM_DEBUG
27
#include <iostream>
28
#include <sstream>
29
#endif
30

31
using namespace realm;
32

33
void FlexCompressor::init_header(char* h, uint8_t flags, uint8_t v_width, uint8_t ndx_width, size_t v_size,
34
                                 size_t ndx_size)
35
{
29,919✔
36
    using Encoding = NodeHeader::Encoding;
29,919✔
37
    ::init_header(h, Encoding::Flex, flags, v_width, ndx_width, v_size, ndx_size);
29,919✔
38
}
29,919✔
39

40
void FlexCompressor::copy_data(const Array& arr, const std::vector<int64_t>& values,
41
                               const std::vector<unsigned>& indices)
42
{
29,919✔
43
    using Encoding = NodeHeader::Encoding;
29,919✔
44
    REALM_ASSERT_DEBUG(arr.is_attached());
29,919✔
45
    const auto& compressor = arr.integer_compressor();
29,919✔
46
    REALM_ASSERT_DEBUG(compressor.get_encoding() == Encoding::Flex);
29,919✔
47
    const auto v_width = compressor.v_width();
29,919✔
48
    const auto ndx_width = compressor.ndx_width();
29,919✔
49
    const auto v_size = values.size();
29,919✔
50
    const auto data = (uint64_t*)arr.m_data;
29,919✔
51
    const auto offset = static_cast<size_t>(v_size * v_width);
29,919✔
52
    BfIterator it_value{data, 0, v_width, v_width, 0};
29,919✔
53
    BfIterator it_index{data, offset, ndx_width, ndx_width, 0};
29,919✔
54
    for (size_t i = 0; i < v_size; ++i) {
1,415,127✔
55
        it_value.set_value(values[i]);
1,385,208✔
56
        REALM_ASSERT_DEBUG(sign_extend_value(v_width, it_value.get_value()) == values[i]);
1,385,208✔
57
        ++it_value;
1,385,208✔
58
    }
1,385,208✔
59
    for (size_t i = 0; i < indices.size(); ++i) {
3,898,101✔
60
        REALM_ASSERT_DEBUG(values[indices[i]] ==
3,868,182✔
61
                           sign_extend_value(v_width, read_bitfield(data, indices[i] * v_width, v_width)));
3,868,182✔
62
        it_index.set_value(indices[i]);
3,868,182✔
63
        REALM_ASSERT_DEBUG(indices[i] == it_index.get_value());
3,868,182✔
64
        REALM_ASSERT_DEBUG(values[indices[i]] ==
3,868,182✔
65
                           sign_extend_value(v_width, read_bitfield(data, indices[i] * v_width, v_width)));
3,868,182✔
66
        ++it_index;
3,868,182✔
67
    }
3,868,182✔
68
}
29,919✔
69

70
bool FlexCompressor::find_all_match(size_t start, size_t end, size_t baseindex, QueryStateBase* state)
71
{
714✔
72
    REALM_ASSERT_DEBUG(state->match_count() < state->limit());
714✔
73
    while (start < end) {
18,354✔
74
        if (!state->match(start + baseindex))
18,270✔
75
            return false;
630✔
76
        start++;
17,640✔
77
    }
17,640✔
78
    return true;
84✔
79
}
714✔
80

81
size_t FlexCompressor::lower_bound(size_t size, int64_t value, uint64_t mask, BfIterator& data_iterator) noexcept
NEW
82
{
×
NEW
83
    return impl::lower_bound(nullptr, 0, size, value, [&](auto, size_t ndx) {
×
NEW
84
        data_iterator.move(ndx);
×
NEW
85
        return sign_extend_field_by_mask(mask, *data_iterator);
×
NEW
86
    });
×
NEW
87
}
×
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