Skip to content

Commit

Permalink
21364: Improves entity persistence: works as single transactional fil…
Browse files Browse the repository at this point in the history
…es as well as performance improvements, MINOR (#315)
  • Loading branch information
howsohazard authored Dec 16, 2024
1 parent ba08bba commit 6371d3f
Show file tree
Hide file tree
Showing 24 changed files with 1,378 additions and 888 deletions.
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ <h2>File I/O</h2>
<div class='td1'><span class="parameter">flatten<span></div><div class='td2'>If true, then will attempt to flatten all contained entities into one executable object and thus one file.</div><br />
<div class='td1'><span class="parameter">parallel_create<span></div><div class='td2'>If true, will attempt use concurrency to store and load entities in parallel.</div><br />
<div class='td1'><span class="parameter">execute_on_load<span></div><div class='td2'>If true, will execute the code upon load, which is required when entities are stored using flatten in order to create all of the entity structures.</div><br />
<div class='td1'><span class="parameter">require_version_compatibility<span></div><div class='td2'>If true, will fail on a load if the version of Amalgam is not compatible with the file version.</div><br />

File formats supported are amlg, json, yaml, csv, and caml; anything not in this list will be loaded as a binary string. Note that loading from a non-'.amlg' extension will only ever provide lists, assocs, numbers, and strings.

Expand Down
4 changes: 2 additions & 2 deletions docs/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,11 +1165,11 @@ var data = [
},

{
"parameter" : "flatten_entity id entity [bool include_rand_seeds] [bool parallel_create]",
"parameter" : "flatten_entity id entity [bool include_rand_seeds] [bool parallel_create] [bool include_version]",
"output" : "*",
"permissions" : "e",
"new value" : "new",
"description" : "Evaluates to code that, if called, would completely reproduce the entity specified by id, as well as all contained entities. If include_rand_seeds is true, its default, it will include all entities' random seeds. If parallel_create is true, then the creates will be performed with parallel markers as appropriate for each group of contained entities. The code returned accepts two parameters, create_new_entity, which defaults to true, and new_entity, which defaults to null. If create_new_entity is true, then it will create a new entity with id specified by new_entity, where null will create an unnamed entity. If create_new_entity is false, then it will overwrite the current entity's code and create all contained entities.",
"description" : "Evaluates to code that, if called, would completely reproduce the entity specified by id, as well as all contained entities. If include_rand_seeds is true, its default, it will include all entities' random seeds. If parallel_create is true, then the creates will be performed with parallel markers as appropriate for each group of contained entities. If include_version is true, it will include a comment on the top node that is the current version of the Amalgam interpreter, which can be used for validating interoperability when loading code. The code returned accepts two parameters, create_new_entity, which defaults to true, and new_entity, which defaults to null. If create_new_entity is true, then it will create a new entity with id specified by new_entity, where null will create an unnamed entity. If create_new_entity is false, then it will overwrite the current entity's code and create all contained entities.",
"example" : "(create_entities \"FlattenTest\" (lambda\n (parallel ##a (rand) )\n))\n(let (assoc fe (flatten_entity \"FlattenTest\"))\n (print fe)\n (print (flatten_entity (call fe)))\n (print (difference_entities \"FlattenTest\" (call fe)))\n (call fe (assoc create_new_entity (false) new_entity \"new_entity_name\")) \n)"
},

Expand Down
9 changes: 5 additions & 4 deletions src/Amalgam/AmalgamMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,15 @@ PLATFORM_MAIN_CONSOLE
{
//run the standard amlg command line interface
EntityExternalInterface::LoadEntityStatus status;
AssetManager::AssetParameters asset_params(amlg_file_to_run, "", true);
std::string file_type = "";
AssetManager::AssetParametersRef asset_params
= std::make_shared<AssetManager::AssetParameters>(amlg_file_to_run, "", true);

Entity *entity = asset_manager.LoadEntityFromResource(asset_params, false, random_seed, nullptr, status);

if(!status.loaded)
return 1;

asset_manager.SetRootPermission(entity, true);
asset_manager.SetEntityPermissions(entity, EntityPermissions::AllPermissions());

PrintListener *print_listener = nullptr;
std::vector<EntityWriteListener *> write_listeners;
Expand All @@ -258,7 +259,7 @@ PLATFORM_MAIN_CONSOLE

if(write_log_filename != "")
{
EntityWriteListener *write_log = new EntityWriteListener(entity, false, write_log_filename);
EntityWriteListener *write_log = new EntityWriteListener(entity, false, false, false, write_log_filename);
write_listeners.push_back(write_log);
}

Expand Down
Loading

0 comments on commit 6371d3f

Please sign in to comment.