Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove enum string feature #7858

Merged
merged 5 commits into from
Jul 10, 2024
Merged

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Jul 2, 2024

What, How & Why?

This feature is no longer relevant as string interning will now be performed automatically.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed
  • bindgen/spec.yml, if public C++ API changed

Copy link

coveralls-official bot commented Jul 2, 2024

Pull Request Test Coverage Report for Build jorgen.edelbo_335

Details

  • 30 of 30 (100.0%) changed or added relevant lines in 8 files are covered.
  • 16 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+0.8%) to 91.611%

Files with Coverage Reduction New Missed Lines %
src/realm/dictionary.cpp 1 85.52%
test/fuzz_tester.hpp 1 57.73%
test/test_query.cpp 1 98.97%
src/realm/sync/network/http.hpp 2 82.27%
src/realm/sync/noinst/client_impl_base.cpp 2 82.71%
src/realm/table.cpp 2 97.26%
src/realm/util/future.hpp 3 95.94%
src/realm/array_string.cpp 4 98.36%
Totals Coverage Status
Change from base Build jorgen.edelbo_334: 0.8%
Covered Lines: 225717
Relevant Lines: 246386

💛 - Coveralls

Copy link

coveralls-official bot commented Jul 2, 2024

Pull Request Test Coverage Report for Build jorgen.edelbo_336

Details

  • 16 of 16 (100.0%) changed or added relevant lines in 7 files are covered.
  • 155 unchanged lines in 21 files lost coverage.
  • Overall coverage decreased (-0.05%) to 90.783%

Files with Coverage Reduction New Missed Lines %
src/realm/dictionary.cpp 1 85.52%
test/test_dictionary.cpp 1 99.83%
test/test_query.cpp 1 96.24%
src/realm/array_with_find.hpp 2 98.15%
src/realm/query_engine.cpp 2 92.05%
src/realm/sync/network/http.hpp 2 82.27%
test/test_index_string.cpp 2 93.33%
src/realm/obj.cpp 3 89.85%
src/realm/table.cpp 3 90.05%
src/realm/util/future.hpp 3 95.94%
Totals Coverage Status
Change from base Build jorgen.edelbo_334: -0.05%
Covered Lines: 217469
Relevant Lines: 239548

💛 - Coveralls

Copy link
Member

@nicola-cab nicola-cab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some small stuff..

size_t index = size_t(static_cast<Array*>(m_arr)->get(ndx));
return m_string_enum_values->get(index);
}
case Type::interned_strings: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this has been deleted?

Copy link
Contributor Author

@jedelbo jedelbo Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has not been deleted, but the diff view plays tricks on you. It is the next function that is deleted.

@@ -1002,7 +990,6 @@ void setup_multi_table(Table& table, size_t rows, std::vector<ObjKey>& keys, std
auto string_col = table.add_column(type_String, "string"); // 4
auto string_long_col = table.add_column(type_String, "string_long"); // 5
auto string_big_col = table.add_column(type_String, "string_big_blobs"); // 6
auto string_enum_col = table.add_column(type_String, "string_enum"); // 7 - becomes StringEnumColumn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the numbers in the comment being decreased as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the numbers dates back to the days where we referenced columns by their index and not by the stable ColKey. But in a sense it is ok to leave the numbers as the ColKeys will not change.

// Create the enumkeys list if needed
if (!m_enumkeys.is_attached()) {
m_enumkeys.create(Array::type_HasRefs, false, m_num_public_columns);
m_top.set(4, m_enumkeys.get_ref());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should we do with Spec::m_enumkeys and Spec::s_enum_keys_ndx ? I think they can be removed as nobody should be using them, but maybe we should also assert that there is nothing stored there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was an oversight. Should be removed.

int_fast64_t v(from_ref(mem.get_ref()));
spec_set.add(v); // Throws
dg_2.release();
spec_set.add(from_ref(mem.get_ref())); // Throws
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old code seems to be very cautious about allocation failure...
are we safe without it because we can rely on commit rollbacks? Alternatively, could we order things like this?

spec_set.add(0);
MemRef mem = create_empty_array(...);
spec_set.set(spec_set.size() - 1, from_ref(mem.get_ref()));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these destroy guards are from the time where we could have freestanding tables. They are not needed when we have transactions. Allocations will always be done in the slab area and it will be reset by every commit/rollback (reset_free_space_tracking()).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for confirming!

@@ -115,50 +99,35 @@ MemRef Spec::create_empty_spec(Allocator& alloc)
// The 'spec_set' contains the specification (types and names) of
// all columns and sub-tables
Array spec_set(alloc);
_impl::DeepArrayDestroyGuard dg(&spec_set);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't we keep this one?

@@ -100,7 +100,7 @@ class Spec {
ArrayStringShort m_names; // 2nd slot in m_top
Array m_attr; // 3rd slot in m_top
// 4th slot in m_top not cached
Array m_enumkeys; // 5th slot in m_top
// 5th slot in m_top
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest adding to the comment something like this: "5th slot in m_top, old enum keys which was never released"

Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the attention to detail. Please double check CI, though it may be an issue with the underlying branch.

@jedelbo jedelbo merged commit ce6f196 into feature/string-compression Jul 10, 2024
13 of 37 checks passed
@jedelbo jedelbo deleted the je/remove-enum-column branch July 10, 2024 08:50
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants