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

realm / realm-core / nicola.cabiddu_1772

31 May 2024 12:58PM UTC coverage: 90.685%. First build
nicola.cabiddu_1772

Pull #7668

Evergreen

jedelbo
Update tests
Pull Request #7668: RCORE-2094 Compressing Integer Arrays

102170 of 180138 branches covered (56.72%)

1749 of 1914 new or added lines in 36 files covered. (91.38%)

217024 of 239317 relevant lines covered (90.68%)

6624441.54 hits per line

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

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

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

70
bool FlexCompressor::find_all_match(size_t start, size_t end, size_t baseindex, QueryStateBase* state)
71
{
36✔
72
    REALM_ASSERT_DEBUG(state->match_count() < state->limit());
36✔
73
    const auto process = state->limit() - state->match_count();
36✔
74
    const auto end2 = end - start > process ? start + process : end;
36✔
75
    for (; start < end2; start++)
7,596✔
76
        if (!state->match(start + baseindex))
7,560✔
NEW
77
            return false;
×
78
    return true;
36✔
79
}
36✔
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