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

22485 Differentiates accum_entity_roots and assign_entity_roots in transaction logs #346

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Amalgam/amlg_code/full_test.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -3546,6 +3546,8 @@
(assign_to_entities "Contained" (assoc a 6 b 10) )
(print (unparse (retrieve_from_entity "Contained" "a") (true) (true)))
(set_entity_rand_seed "Contained" "bbbb")
(accum_to_entities "Contained" (assoc b 12) )
(accum_entity_roots "Contained" (list (set_labels 14 (list "a"))))
(destroy_entities "Contained")
)
)
Expand Down
20 changes: 10 additions & 10 deletions src/Amalgam/entity/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,16 @@ void Entity::AccumRoot(EvaluableNodeReference accum_code, bool allocated_with_en
node_flags_need_update = true;
}

if(write_listeners != nullptr)
{
if(write_listeners->size() > 0)
{
for(auto &wl : *write_listeners)
wl->LogEntityAccumRoot(this, accum_code);
}
asset_manager.UpdateEntityRoot(this);
}

//accum, but can't treat as unique in case any other thread is accessing the data
EvaluableNodeReference new_root = AccumulateEvaluableNodeIntoEvaluableNode(
EvaluableNodeReference(previous_root, false), accum_code, &evaluableNodeManager);
Expand Down Expand Up @@ -977,16 +987,6 @@ void Entity::AccumRoot(EvaluableNodeReference accum_code, bool allocated_with_en
container_caches->UpdateAllEntityLabels(this, GetEntityIndexOfContainer());
}

if(write_listeners != nullptr)
{
if(write_listeners->size() > 0)
{
for(auto &wl : *write_listeners)
wl->LogWriteToEntityRoot(this);
}
asset_manager.UpdateEntityRoot(this);
}

#ifdef AMALGAM_MEMORY_INTEGRITY
VerifyEvaluableNodeIntegrity();
#endif
Expand Down
14 changes: 13 additions & 1 deletion src/Amalgam/entity/EntityWriteListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ void EntityWriteListener::LogWriteToEntityRoot(Entity *entity)
#ifdef MULTITHREAD_SUPPORT
Concurrency::SingleLock lock(mutex);
#endif

EvaluableNode *new_write = BuildNewWriteOperation(ENT_ASSIGN_ENTITY_ROOTS, entity);
EvaluableNode *new_root = entity->GetRoot(&listenerStorage, EvaluableNodeManager::ENMM_LABEL_ESCAPE_INCREMENT);
EvaluableNode *new_lambda = listenerStorage.AllocNode(EvaluableNodeType::ENT_LAMBDA);
Expand All @@ -148,6 +147,19 @@ void EntityWriteListener::LogWriteToEntityRoot(Entity *entity)
LogNewEntry(new_write);
}

void EntityWriteListener::LogEntityAccumRoot(Entity *entity, EvaluableNodeReference accum_code)
{
#ifdef MULTITHREAD_SUPPORT
Concurrency::SingleLock lock(mutex);
#endif
EvaluableNode *new_write = BuildNewWriteOperation(ENT_ACCUM_ENTITY_ROOTS, entity);
EvaluableNode *new_lambda = listenerStorage.AllocNode(EvaluableNodeType::ENT_LAMBDA);
new_lambda->AppendOrderedChildNode(listenerStorage.DeepAllocCopy(accum_code));
new_write->AppendOrderedChildNode(new_lambda);

LogNewEntry(new_write);
}

void EntityWriteListener::LogCreateEntity(Entity *new_entity)
{
if(new_entity == nullptr)
Expand Down
3 changes: 3 additions & 0 deletions src/Amalgam/entity/EntityWriteListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class EntityWriteListener
//logs the new entity root, assuming it has already been set
void LogWriteToEntityRoot(Entity *entity);

//logs accum to the entity root
void LogEntityAccumRoot(Entity *entity, EvaluableNodeReference accum_code);

void LogCreateEntity(Entity *new_entity);

void LogDestroyEntity(Entity *destroyed_entity);
Expand Down
94 changes: 53 additions & 41 deletions src/Amalgam/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ infinity test c or d: ["c" "c" "d" "d"]
[1 3 4]

--get_rand_seed--
ü—õ暧I`¦!šc”lÿ
���暧I`�!�c�l�
--set_rand_seed--
0.3458744430299684
0.5141404672826732
Expand Down Expand Up @@ -1853,27 +1853,27 @@ comment too
"e"
"f"
"g"
"ï"
"¬"
""
"ê"
"­"
""
"Ï"
"¡"
¿½"
"�"
"�"
"�"
"�"
"�"
"�"
"�"
]
[
"ab"
"cd"
"ef"
"gï"
"¬—"
"ê­"
"–Ï"
"¡"
"g�"
"��"
"�"
"��"
"�"
]
["abc" "def" "gï¬" "—ê­" "Ï¡"]
["abcd" "efgï" "¬—ê­" "Ï¡"]
["abc" "def" "g�" "��" "�ϡ"]
["abcd" "efg�" "���" "�ϡ"]
--split--
["hello world"]
["hello" "world"]
Expand Down Expand Up @@ -1927,11 +1927,11 @@ h[e]ll[o] w[o]rld
h[e]ll[o] world
abcdefgﬗꭖϡ
bcdefgﬗꭖϡ
bcdefgﬗê­
bcdefgﬗ�
bcdefgﬗꭖϡ
bcdefgﬗꭖ
gﬗꭖ
­–Ï
���
axdefgﬗꭖϡ
--concat--
hello world
Expand Down Expand Up @@ -2565,7 +2565,7 @@ abcdoxyz
87
--flatten_entity--
0.40971200496539806
iûÛAŽ;@Vëó¬OV-ÿ
i��A�;@V��OV-�
0.7136950384635786
0.7136950384635786
0.6522822782263927
Expand All @@ -2592,7 +2592,7 @@ flatten restore with seeds test
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "»¶Â£=ô€mVëó¬OV-ÿ")
(set_entity_rand_seed new_entity "��£=�mV��OV-�")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -2604,7 +2604,7 @@ flatten restore with seeds test
)
)
)
"aE&K\"Øà¸Õ(X&€\0ÿ"
"�aE&K\"���(X&�\0�"
)
new_entity
)
Expand All @@ -2629,7 +2629,7 @@ flatten restore with seeds test
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "M:ù÷püVVëó¬OV-ÿ")
(set_entity_rand_seed new_entity "�M:��p�VV��OV-�")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -2641,7 +2641,7 @@ flatten restore with seeds test
)
)
)
"aE&K\"Øà¸Õ(X&€\0ÿ"
"�aE&K\"���(X&�\0�"
)
new_entity
)
Expand Down Expand Up @@ -2702,7 +2702,7 @@ flatten restore without seeds test
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "{'ÔI¢ÑùÜÌCÓ­Ìÿ")
(set_entity_rand_seed new_entity "{'�I�����C����")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -2714,7 +2714,7 @@ flatten restore without seeds test
)
)
)
"í5š¥ºz^\rãFä/ VQÿ"
"�5���z^\r�F�/�V�Q�"
)
new_entity
)
Expand Down Expand Up @@ -2744,7 +2744,7 @@ flatten restore with parallel
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "»¶Â£=ô€mVëó¬OV-ÿ")
(set_entity_rand_seed new_entity "��£=�mV��OV-�")
||(parallel
(set_entity_rand_seed
(first
Expand All @@ -2757,7 +2757,7 @@ flatten restore with parallel
)
)
)
"aE&K\"Øà¸Õ(X&€\0ÿ"
"�aE&K\"���(X&�\0�"
)
)
new_entity
Expand All @@ -2783,7 +2783,7 @@ flatten restore with parallel
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "M:ù÷püVVëó¬OV-ÿ")
(set_entity_rand_seed new_entity "�M:��p�VV��OV-�")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -2795,7 +2795,7 @@ flatten restore with parallel
)
)
)
"aE&K\"Øà¸Õ(X&€\0ÿ"
"�aE&K\"���(X&�\0�"
)
new_entity
)
Expand Down Expand Up @@ -3625,9 +3625,9 @@ this is a fully described entity
#c 3
)
--get_entity_rand_seed--
3„yàrœ>ƒ89012345ÿ
3�y�r�>�89012345�
0.812564396753873
aâÿdx€)5® iDÿ
a��dx�)5� iD�
--set_entity_rand_seed--
0.21086495653466275
0.21086495653466275
Expand Down Expand Up @@ -3824,7 +3824,7 @@ hello
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "þ¢X¿~wb¢ô3æ©‚ºÿ")
(set_entity_rand_seed new_entity "��X�~wb��3�����")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -3838,7 +3838,7 @@ hello
)
)
)
"DA3¬ðí0ŸW^v½haÍ&ÿ"
"DA3���0�W^v�ha�&�"
)
(set_entity_rand_seed
(first
Expand All @@ -3853,7 +3853,7 @@ hello
)
)
)
"= ÝûÆ\0F†yf×@)‹¬ÿ"
"= ���\0F�yf�@)���"
)
new_entity
)
Expand Down Expand Up @@ -3881,7 +3881,7 @@ persistent loads
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "1a2Ø.²³W«w¸ˆæÿ")
(set_entity_rand_seed new_entity "1a2�.��W�w�����")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -3891,7 +3891,7 @@ persistent loads
)
)
)
"ˆ-ìO[¿ë3yC“Å’ŒÑÿ"
"�-�O[��3yC�Œ���"
)
(set_entity_rand_seed
(first
Expand All @@ -3906,7 +3906,7 @@ persistent loads
)
)
)
"&Ì$Ü´@nÏ>ƒ\"ëFNÿ"
"&�$ܴ@n�>�\"��FN�"
)
new_entity
)
Expand All @@ -3933,7 +3933,7 @@ persistent loads
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "1a2Ø.²³W«w¸ˆæÿ")
(set_entity_rand_seed new_entity "1a2�.��W�w�����")
(set_entity_rand_seed
(first
(create_entities
Expand All @@ -3947,7 +3947,7 @@ persistent loads
)
)
)
"&Ì$Ü´@nÏ>ƒ\"ëFNÿ"
"&�$ܴ@n�>�\"��FN�"
)
new_entity
)
Expand Down Expand Up @@ -4608,6 +4608,18 @@ execution limits tests
"bbbb"
(false)
)
(accum_to_entities
["CEGCTest" "Contained"]
{b 12}
)
(accum_entity_roots
["CEGCTest" "Contained"]
(lambda
[
#a 14
]
)
)
(destroy_entities
["CEGCTest" "Contained"]
)
Expand Down Expand Up @@ -4683,7 +4695,7 @@ entity cyclic test:
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "߉$OtFNÜŽ5ÿ")
(set_entity_rand_seed new_entity "߉�$Ot3�FN܎5�")
new_entity
)
3
Expand Down Expand Up @@ -4713,7 +4725,7 @@ entity cyclic test:
(assign_entity_roots new_entity _)
)
)
(set_entity_rand_seed new_entity "߉$OtFNÜŽ5ÿ")
(set_entity_rand_seed new_entity "߉�$Ot3�FN܎5�")
new_entity
)
cyclic lookup test:
Expand Down
Loading