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

realm / realm-core / jorgen.edelbo_385

12 Aug 2024 01:14PM UTC coverage: 91.1% (-0.007%) from 91.107%
jorgen.edelbo_385

Pull #7826

Evergreen

jedelbo
Merge tag 'v14.12.0' into next-major
Pull Request #7826: Merge Next major

103514 of 182200 branches covered (56.81%)

3132 of 3493 new or added lines in 52 files covered. (89.67%)

154 existing lines in 17 files now uncovered.

219973 of 241462 relevant lines covered (91.1%)

6545726.52 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
{
32,793✔
36
    using Encoding = NodeHeader::Encoding;
32,793✔
37
    ::init_header(h, Encoding::Flex, flags, v_width, ndx_width, v_size, ndx_size);
32,793✔
38
}
32,793✔
39

40
void FlexCompressor::copy_data(const Array& arr, const std::vector<int64_t>& values,
41
                               const std::vector<unsigned>& indices)
42
{
32,793✔
43
    using Encoding = NodeHeader::Encoding;
32,793✔
44
    REALM_ASSERT_DEBUG(arr.is_attached());
32,793✔
45
    const auto& compressor = arr.integer_compressor();
32,793✔
46
    REALM_ASSERT_DEBUG(compressor.get_encoding() == Encoding::Flex);
32,793✔
47
    const auto v_width = compressor.v_width();
32,793✔
48
    const auto ndx_width = compressor.ndx_width();
32,793✔
49
    const auto v_size = values.size();
32,793✔
50
    const auto data = (uint64_t*)arr.m_data;
32,793✔
51
    const auto offset = static_cast<size_t>(v_size * v_width);
32,793✔
52
    BfIterator it_value{data, 0, v_width, v_width, 0};
32,793✔
53
    BfIterator it_index{data, offset, ndx_width, ndx_width, 0};
32,793✔
54
    for (size_t i = 0; i < v_size; ++i) {
1,318,086✔
55
        it_value.set_value(values[i]);
1,285,293✔
56
        REALM_ASSERT_DEBUG(sign_extend_value(v_width, it_value.get_value()) == values[i]);
1,285,293✔
57
        ++it_value;
1,285,293✔
58
    }
1,285,293✔
59
    for (size_t i = 0; i < indices.size(); ++i) {
3,841,611✔
60
        REALM_ASSERT_DEBUG(values[indices[i]] ==
3,808,818✔
61
                           sign_extend_value(v_width, read_bitfield(data, indices[i] * v_width, v_width)));
3,808,818✔
62
        it_index.set_value(indices[i]);
3,808,818✔
63
        REALM_ASSERT_DEBUG(indices[i] == it_index.get_value());
3,808,818✔
64
        REALM_ASSERT_DEBUG(values[indices[i]] ==
3,808,818✔
65
                           sign_extend_value(v_width, read_bitfield(data, indices[i] * v_width, v_width)));
3,808,818✔
66
        ++it_index;
3,808,818✔
67
    }
3,808,818✔
68
}
32,793✔
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

© 2026 Coveralls, Inc