-
Notifications
You must be signed in to change notification settings - Fork 165
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
Changes from 1 commit
8ccfc23
932c09d
04a17b6
1d1dea8
7f1271f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,14 +51,6 @@ void Spec::init(MemRef mem) noexcept | |
m_top.add(0); | ||
} | ||
|
||
// Enumkeys array is only there when there are StringEnum columns | ||
if (auto ref = m_top.get_as_ref(s_enum_keys_ndx)) { | ||
m_enumkeys.init_from_ref(ref); | ||
} | ||
else { | ||
m_enumkeys.detach(); | ||
} | ||
|
||
if (m_top.get_as_ref(s_col_keys_ndx) == 0) { | ||
// This is an upgrade - create column key array | ||
MemRef mem_ref = Array::create_empty_array(Array::type_Normal, false, m_top.get_alloc()); // Throws | ||
|
@@ -96,14 +88,6 @@ void Spec::update_from_parent() noexcept | |
m_types.update_from_parent(); | ||
m_names.update_from_parent(); | ||
m_attr.update_from_parent(); | ||
|
||
if (m_top.get_as_ref(s_enum_keys_ndx) != 0) { | ||
m_enumkeys.update_from_parent(); | ||
} | ||
else { | ||
m_enumkeys.detach(); | ||
} | ||
|
||
m_keys.update_from_parent(); | ||
|
||
update_internals(); | ||
|
@@ -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); | ||
spec_set.create(Array::type_HasRefs); // Throws | ||
|
||
_impl::DeepArrayRefDestroyGuard dg_2(alloc); | ||
{ | ||
// One type for each column | ||
bool context_flag = false; | ||
MemRef mem = Array::create_empty_array(Array::type_Normal, context_flag, alloc); // Throws | ||
dg_2.reset(mem.get_ref()); | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the old code seems to be very cautious about allocation failure...
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks for confirming! |
||
} | ||
{ | ||
size_t size = 0; | ||
// One name for each column | ||
MemRef mem = ArrayStringShort::create_array(size, alloc); // Throws | ||
dg_2.reset(mem.get_ref()); | ||
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 | ||
} | ||
{ | ||
// One attrib set for each column | ||
bool context_flag = false; | ||
MemRef mem = Array::create_empty_array(Array::type_Normal, context_flag, alloc); // Throws | ||
dg_2.reset(mem.get_ref()); | ||
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 | ||
} | ||
spec_set.add(0); // Nested collections array | ||
spec_set.add(0); // Enumkeys array | ||
{ | ||
// One key for each column | ||
bool context_flag = false; | ||
MemRef mem = Array::create_empty_array(Array::type_Normal, context_flag, alloc); // Throws | ||
dg_2.reset(mem.get_ref()); | ||
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 | ||
} | ||
|
||
dg.release(); | ||
return spec_set.get_mem(); | ||
} | ||
|
||
|
@@ -204,10 +173,6 @@ void Spec::insert_column(size_t column_ndx, ColKey col_key, ColumnType type, Str | |
m_attr.insert(column_ndx, attr); // Throws | ||
m_keys.insert(column_ndx, col_key.value); | ||
|
||
if (m_enumkeys.is_attached() && type != col_type_BackLink) { | ||
m_enumkeys.insert(column_ndx, 0); | ||
} | ||
|
||
update_internals(); | ||
} | ||
|
||
|
@@ -216,21 +181,6 @@ void Spec::erase_column(size_t column_ndx) | |
REALM_ASSERT(column_ndx < m_types.size()); | ||
|
||
if (ColumnType(int(m_types.get(column_ndx))) != col_type_BackLink) { | ||
// Remove this column from the enum keys lookup and clean it up if it's now empty | ||
if (m_enumkeys.is_attached()) { | ||
m_enumkeys.erase(column_ndx); // Throws | ||
bool all_empty = true; | ||
for (size_t i = 0; i < m_enumkeys.size(); i++) { | ||
if (m_enumkeys.get(i) != 0) { | ||
all_empty = false; | ||
break; | ||
} | ||
} | ||
if (all_empty) { | ||
m_enumkeys.destroy_deep(); | ||
m_top.set(4, 0); | ||
} | ||
} | ||
m_num_public_columns--; | ||
m_names.erase(column_ndx); // Throws | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ class Spec { | |
static constexpr size_t s_names_ndx = 1; | ||
static constexpr size_t s_attributes_ndx = 2; | ||
static constexpr size_t s_vacant_1 = 3; | ||
static constexpr size_t s_enum_keys_ndx = 4; | ||
// static constexpr size_t s_enum_keys_ndx = 4; | ||
static constexpr size_t s_col_keys_ndx = 5; | ||
static constexpr size_t s_spec_max_size = 6; | ||
|
||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" |
||
Array m_keys; // 6th slot in m_top | ||
size_t m_num_public_columns = 0; | ||
|
||
|
@@ -150,13 +150,11 @@ inline Spec::Spec(Allocator& alloc) noexcept | |
, m_types(alloc) | ||
, m_names(alloc) | ||
, m_attr(alloc) | ||
, m_enumkeys(alloc) | ||
, m_keys(alloc) | ||
{ | ||
m_types.set_parent(&m_top, s_types_ndx); | ||
m_names.set_parent(&m_top, s_names_ndx); | ||
m_attr.set_parent(&m_top, s_attributes_ndx); | ||
m_enumkeys.set_parent(&m_top, s_enum_keys_ndx); | ||
m_keys.set_parent(&m_top, s_col_keys_ndx); | ||
} | ||
|
||
|
There was a problem hiding this comment.
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?