Skip to content

Commit

Permalink
Merge branch 'master' of github.com:realm/realm-core into nc/array_co…
Browse files Browse the repository at this point in the history
…mpression_with_nested_collections
  • Loading branch information
nicola-cab committed Mar 21, 2024
2 parents d8f4934 + 4d707c4 commit 655e18c
Show file tree
Hide file tree
Showing 29 changed files with 887 additions and 456 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/lock-threads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Lock Threads'

on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write
discussions: write

concurrency:
group: lock-threads

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
with:
issue-inactive-days: 30
pr-inactive-days: 30
log-output: true
28 changes: 23 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* Nested path included in 'OutOfBoundsø error message ([#7438](https://github.com/realm/realm-core/issues/7438))
* Improve file compaction performance on platforms with page sizes greater than 4k (for example arm64 Apple platforms) for files less than 256 pages in size ([PR #7492](https://github.com/realm/realm-core/pull/7492)).
* None.

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Modifying nested collections left the accessor used to make the modification in a stale state, resulting in some unneccesary work being done when making multiple modifications via one accessor ([PR #7470](https://github.com/realm/realm-core/pull/7470), since v14.0.0).
* Fix depth level for nested collection in debug mode, set it to the same level as release ([#7484](https://github.com/realm/realm-core/issues/7484), since v14.0.0).
* None.

### Breaking changes
* Update C-API log callback signature to include the log category, and `realm_set_log_callback` to not take a `realm_log_level_e`. ([PR #7494](https://github.com/realm/realm-core/pull/7494)
* None.

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.
Expand All @@ -23,6 +21,26 @@

----------------------------------------------

# 14.4.0 Release notes

### Enhancements
* Nested path included in 'OutOfBoundsø error message ([#7438](https://github.com/realm/realm-core/issues/7438))
* Improve file compaction performance on platforms with page sizes greater than 4k (for example arm64 Apple platforms) for files less than 256 pages in size ([PR #7492](https://github.com/realm/realm-core/pull/7492)).

### Fixed
* Modifying nested collections left the accessor used to make the modification in a stale state, resulting in some unneccesary work being done when making multiple modifications via one accessor ([PR #7470](https://github.com/realm/realm-core/pull/7470), since v14.0.0).
* Fix depth level for nested collection in debug mode, set it to the same level as release ([#7484](https://github.com/realm/realm-core/issues/7484), since v14.0.0).
* Fix opening realm with cached user while offline results in fatal error and session does not retry connection. ([#7349](https://github.com/realm/realm-core/issues/7349), since v13.26.0)
* Fix disallow Sets in ArrayMixed. ([#7502](https://github.com/realm/realm-core/pull/7502), since v14.0.0)

### Breaking changes
* Update C-API log callback signature to include the log category, and `realm_set_log_callback` to not take a `realm_log_level_e`. ([PR #7494](https://github.com/realm/realm-core/pull/7494)

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.

----------------------------------------------

# 14.3.0 Release notes

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import PackageDescription
import Foundation

let versionStr = "14.3.0"
let versionStr = "14.4.0"
let versionPieces = versionStr.split(separator: "-")
let versionCompontents = versionPieces[0].split(separator: ".")
let versionExtra = versionPieces.count > 1 ? versionPieces[1] : ""
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME: realm-core
VERSION: 14.3.0
VERSION: 14.4.0
OPENSSL_VERSION: 3.2.0
ZLIB_VERSION: 1.2.13
# https://github.com/10gen/baas/commits
Expand Down
2 changes: 1 addition & 1 deletion external/catch
Submodule catch updated 251 files
2 changes: 2 additions & 0 deletions src/realm.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef bool (*realm_migration_func_t)(realm_userdata_t userdata, realm_t* old_r
typedef bool (*realm_data_initialization_func_t)(realm_userdata_t userdata, realm_t* realm);
typedef bool (*realm_should_compact_on_launch_func_t)(realm_userdata_t userdata, uint64_t total_bytes,
uint64_t used_bytes);

typedef enum realm_schema_mode {
RLM_SCHEMA_MODE_AUTOMATIC,
RLM_SCHEMA_MODE_IMMUTABLE,
Expand Down Expand Up @@ -2977,6 +2978,7 @@ RLM_API realm_auth_provider_e realm_auth_credentials_get_provider(realm_app_cred
RLM_API realm_app_config_t* realm_app_config_new(const char* app_id,
const realm_http_transport_t* http_transport) RLM_API_NOEXCEPT;

RLM_API const char* realm_app_get_default_base_url(void) RLM_API_NOEXCEPT;
RLM_API void realm_app_config_set_base_url(realm_app_config_t*, const char*) RLM_API_NOEXCEPT;
RLM_API void realm_app_config_set_default_request_timeout(realm_app_config_t*, uint64_t ms) RLM_API_NOEXCEPT;
RLM_API void realm_app_config_set_platform_version(realm_app_config_t*, const char*) RLM_API_NOEXCEPT;
Expand Down
2 changes: 1 addition & 1 deletion src/realm/array_mixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ int64_t ArrayMixed::store(const Mixed& value)
break;
}
default:
REALM_ASSERT(type == type_List || type == type_Dictionary || type == type_Set);
REALM_ASSERT(type == type_List || type == type_Dictionary);
ensure_ref_array();
size_t ndx = m_refs.size();
m_refs.add(value.get_ref());
Expand Down
108 changes: 66 additions & 42 deletions src/realm/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1653,50 +1653,74 @@ ref_type Cluster::typed_write(ref_type ref, _impl::ArrayWriterBase& out, const T
else if (col_type == col_type_Mixed) {
const auto sz = leaf.size();
REALM_ASSERT(sz == 6);
for (size_t i = 0; i < sz; ++i) {
auto rot = leaf.get_as_ref_or_tagged(i);
if (rot.is_ref() && rot.get_as_ref()) {

/*
In order to know how Mixed stores things, we need to take in consideration this enum
enum {
payload_idx_type,
payload_idx_int,
payload_idx_pair,
payload_idx_str,
payload_idx_ref,
payload_idx_key,
payload_idx_size
};
Note:
1. First 3 entries can be compressed (they are integers)
2. entry number 4 is for strings (no compression for now)
3. entry number 5 is actually storing refs to collections (List or Dictionaries).
They can only be BPlusTree<int, Mixed> or BPlusTree<string, Mixed>.
4. Other entries should be skipped, we do not compress them.
*/

const auto do_compress = (i < 3) ? true : false;
if (i == 4) {
// TODO this is not working...
bool compress = true;
auto bptree_rot = leaf.get_as_ref_or_tagged(i);
if (bptree_rot.is_ref() && bptree_rot.get_as_ref()) {
written_leaf.set_as_ref(i, BPlusTreeBase::typed_write(bptree_rot.get_as_ref(), out,
m_alloc, col_type, deep,
only_modified, compress));
}
else {
written_leaf.set(i, bptree_rot);
}

/*
In order to know how Mixed stores things, we need to take in consideration this enum
enum {
payload_idx_type,
payload_idx_int,
payload_idx_pair,
payload_idx_str,
payload_idx_ref,
payload_idx_key,
payload_idx_size
};
Note:
1. entry at index 0 is the parent pointer
2. entries at indices 1 and 2 can be compressed (they are integers)
3. entry at index 3 is for strings (no compression for now)
4. entry at index 4 is actually storing refs to all the stored types,
including to collections (List or Dictionaries).
They can only be BPlusTree<int, Mixed> or BPlusTree<string, Mixed>.
5. Is the key array, marks whether the composite array at position i is a collection or not
*/
auto rot_parent = leaf.get_as_ref_or_tagged(0);
auto rot_int = leaf.get_as_ref_or_tagged(1);
auto rot_pair_int = leaf.get_as_ref_or_tagged(2);
auto rot_string = leaf.get_as_ref_or_tagged(3);
auto rot_composite = leaf.get_as_ref_or_tagged(4);
auto rot_key = leaf.get_as_ref_or_tagged(5);

if (rot_parent.get_as_ref())
written_leaf.set(0, Array::write(rot_parent.get_as_ref(), m_alloc, out, only_modified, false));
else
written_leaf.set(0, rot_parent);

if (rot_int.get_as_ref())
written_leaf.set_as_ref(1, Array::write(rot_int.get_as_ref(), m_alloc, out, only_modified, true));
else
written_leaf.set(1, rot_int);

if (rot_pair_int.get_as_ref())
written_leaf.set_as_ref(
2, Array::write(rot_pair_int.get_as_ref(), m_alloc, out, only_modified, true));
else
written_leaf.set(2, rot_pair_int);

written_leaf.set(3, rot_string); // no compression for strings now.

if (rot_composite.get_as_ref() && rot_key.get_as_ref()) {
Array composite(Allocator::get_default());
Array keys(Allocator::get_default());
composite.init_from_ref(rot_composite.get_as_ref());
keys.init_from_ref(rot_key.get_as_ref());

for (size_t i = 0; i < composite.size(); ++i) {
if (i < keys.size() && keys.get(i)) {
// collection.
auto rot = composite.get_as_ref_or_tagged(i);
REALM_ASSERT_DEBUG(rot.is_ref() && rot.get_as_ref());
const auto new_ref = BPlusTreeBase::typed_write(rot.get_as_ref(), out, m_alloc, col_type,
deep, only_modified, true);
composite.set_as_ref(i, new_ref);
}
// compress only mixed arrays that are integers. skip all the rest for now.
written_leaf.set_as_ref(
i, Array::write(rot.get_as_ref(), m_alloc, out, only_modified, do_compress));
}
else {
written_leaf.set(i, rot);
}
written_leaf.set(4, rot_composite);
written_leaf.set(5, rot_key);
}
else {
written_leaf.set(4, rot_composite);
written_leaf.set(5, rot_key);
}
}
else {
Expand Down
5 changes: 5 additions & 0 deletions src/realm/object-store/c_api/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ static inline bson::BsonArray parse_ejson_array(const char* serialized)
}
}

RLM_API const char* realm_app_get_default_base_url(void) noexcept
{
return app::App::default_base_url.data();
}

RLM_API realm_app_credentials_t* realm_app_credentials_new_anonymous(bool reuse_credentials) noexcept
{
return new realm_app_credentials_t(AppCredentials::anonymous(reuse_credentials));
Expand Down
Loading

0 comments on commit 655e18c

Please sign in to comment.