aboutsummaryrefslogtreecommitdiffstats
path: root/lib/relation.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2025-03-22 20:55:14 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2025-03-22 20:55:14 -0300
commit3b4556e23f19272e0f63d316842c887365676568 (patch)
tree5de00230226bc2297274a6f618a726b16e0a5f8c /lib/relation.ml
parentfb0ade9daf1e9d1cd0a29dd1abe87468ab03a174 (diff)
downloadSakura-3b4556e23f19272e0f63d316842c887365676568.tar.gz
Sakura-3b4556e23f19272e0f63d316842c887365676568.zip
fix commit updates
Diffstat (limited to 'lib/relation.ml')
-rw-r--r--lib/relation.ml138
1 files changed, 92 insertions, 46 deletions
diff --git a/lib/relation.ml b/lib/relation.ml
index 275bd10..1ce67ae 100644
--- a/lib/relation.ml
+++ b/lib/relation.ml
@@ -1,3 +1,15 @@
+let print_references references =
+ Disk.Executor.StringMap.iter
+ (fun k v ->
+ print_endline ("→ " ^ k ^ ": ");
+ Disk.Executor.IntMap.iter
+ (fun k v ->
+ print_endline (" ↳ " ^ Int64.to_string k);
+ List.iter (fun v -> print_endline (" → " ^ v)) v)
+ v;
+ print_newline ())
+ references
+
let write_and_retrieve () =
let open Disk in
let schema =
@@ -39,9 +51,10 @@ let write_and_retrieve () =
filename = "user/first-name";
}
in
- let+ (commit, locations, references), Command.ComputedHash handle11 =
+ let+ (commit, locations), Command.ComputedHash handle11 =
Command.commit_and_perform commit locations command_write1
in
+ print_references commit.references;
let command_write2 : Command.t =
{
kind = Command.WRITE;
@@ -52,63 +65,106 @@ let write_and_retrieve () =
filename = "user/last-name";
}
in
- let+ (commit, locations, references), Command.ComputedHash handle12 =
+ let+ (commit, locations), Command.ComputedHash handle12 =
Command.commit_and_perform commit locations command_write2
in
- let entity_id = 1L in
- let command_write3 : Command.t =
- {
- kind = Command.WRITE;
- timestamp = 10.0;
- hash = "";
- content = "Minnie";
- entity_id = Some 1L;
- filename = "user/first-name";
- }
- in
- let+ (commit, locations, references), Command.ComputedHash handle21 =
- Command.commit_and_perform commit locations command_write3
- in
- let command_write4 : Command.t =
+ print_references commit.references;
+ let command_write1_address : Command.t =
{
kind = Command.WRITE;
timestamp = 10.0;
hash = "";
- content = "Mouse";
- entity_id = Some 1L;
- filename = "user/last-name";
+ content = "Saint James St.";
+ entity_id = Some 0L;
+ filename = "address/street";
}
in
- let+ (commit, locations, references), Command.ComputedHash handle22 =
- Command.commit_and_perform commit locations command_write4
+ let+ (commit, locations), Command.ComputedHash handle12 =
+ Command.commit_and_perform commit locations command_write1_address
in
- let entity_id = 2L in
- let command_write5 : Command.t =
+ print_references commit.references;
+ let command_write2_address : Command.t =
{
kind = Command.WRITE;
timestamp = 10.0;
hash = "";
- content = "Billie";
- entity_id = Some 2L;
- filename = "user/first-name";
+ content = "41";
+ entity_id = Some 0L;
+ filename = "address/number";
}
in
- let+ (commit, locations, references), Command.ComputedHash handle31 =
- Command.commit_and_perform commit locations command_write5
+ let+ (commit, locations), Command.ComputedHash handle12 =
+ Command.commit_and_perform commit locations command_write2_address
in
- let command_write6 : Command.t =
+ print_references commit.references;
+ let command_write2_5 : Command.t =
{
kind = Command.WRITE;
timestamp = 10.0;
hash = "";
- content = "Beans";
- entity_id = Some 2L;
- filename = "user/last-name";
+ content = "0";
+ entity_id = Some 0L;
+ filename = "user/address";
}
in
- let+ (commit, locations, references), Command.ComputedHash handle32 =
- Command.commit_and_perform commit locations command_write6
- in
+ let+ (commit, locations), Command.ComputedHash handle12 =
+ Command.commit_and_perform commit locations command_write2_5
+ in
+ print_references commit.references;
+ (* let entity_id = 1L in *)
+ (* let command_write3 : Command.t = *)
+ (* { *)
+ (* kind = Command.WRITE; *)
+ (* timestamp = 10.0; *)
+ (* hash = ""; *)
+ (* content = "Minnie"; *)
+ (* entity_id = Some 1L; *)
+ (* filename = "user/first-name"; *)
+ (* } *)
+ (* in *)
+ (* let+ (commit, locations, references), Command.ComputedHash handle21 = *)
+ (* Command.commit_and_perform commit locations command_write3 *)
+ (* in *)
+ (* let command_write4 : Command.t = *)
+ (* { *)
+ (* kind = Command.WRITE; *)
+ (* timestamp = 10.0; *)
+ (* hash = ""; *)
+ (* content = "Mouse"; *)
+ (* entity_id = Some 1L; *)
+ (* filename = "user/last-name"; *)
+ (* } *)
+ (* in *)
+ (* let+ (commit, locations, references), Command.ComputedHash handle22 = *)
+ (* Command.commit_and_perform commit locations command_write4 *)
+ (* in *)
+ (* let entity_id = 2L in *)
+ (* let command_write5 : Command.t = *)
+ (* { *)
+ (* kind = Command.WRITE; *)
+ (* timestamp = 10.0; *)
+ (* hash = ""; *)
+ (* content = "Billie"; *)
+ (* entity_id = Some 2L; *)
+ (* filename = "user/first-name"; *)
+ (* } *)
+ (* in *)
+ (* let+ (commit, locations, references), Command.ComputedHash handle31 = *)
+ (* Command.commit_and_perform commit locations command_write5 *)
+ (* in *)
+ (* let command_write6 : Command.t = *)
+ (* { *)
+ (* kind = Command.WRITE; *)
+ (* timestamp = 10.0; *)
+ (* hash = ""; *)
+ (* content = "Beans"; *)
+ (* entity_id = Some 2L; *)
+ (* filename = "user/last-name"; *)
+ (* } *)
+ (* in *)
+ (* let+ (commit, locations, references), Command.ComputedHash handle32 = *)
+ (* Command.commit_and_perform commit locations command_write6 *)
+ (* in *)
let command_read : Command.t =
{
kind = Command.READ;
@@ -122,16 +178,6 @@ let write_and_retrieve () =
let+ _, (Command.Read content as response) =
Command.commit_and_perform commit locations command_read
in
- Executor.StringMap.iter
- (fun k v ->
- print_endline ("→ " ^ k ^ ": ");
- Executor.IntMap.iter
- (fun k v ->
- print_endline (" ↳ " ^ Int64.to_string k);
- List.iter (fun v -> print_endline (" → " ^ v)) v)
- v;
- print_newline ())
- references;
print_endline (Command.show_return response);
Ok (commit, locations)
[@@warning "-8-27-26"]