aboutsummaryrefslogtreecommitdiffstats
path: root/lib/relation.ml
diff options
context:
space:
mode:
authorMarcos Magueta <mmagueta@MacMini.local>2024-12-08 12:05:27 -0300
committerMarcos Magueta <mmagueta@MacMini.local>2024-12-08 12:05:27 -0300
commitf43943346e3c6d347b829bbbaeccae5f49327749 (patch)
treee1dc5af28e599c64e74affb0c1bc9f8a0132e68d /lib/relation.ml
parent872fc56a414f8c2a4818463be9e104195a0b6242 (diff)
downloadSakura-f43943346e3c6d347b829bbbaeccae5f49327749.tar.gz
Sakura-f43943346e3c6d347b829bbbaeccae5f49327749.zip
seq scan initial implementation
Diffstat (limited to 'lib/relation.ml')
-rw-r--r--lib/relation.ml33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/relation.ml b/lib/relation.ml
index 5a896d4..5c8d1e0 100644
--- a/lib/relation.ml
+++ b/lib/relation.ml
@@ -10,10 +10,10 @@ module Protocol = struct
attribute_type: string;
tuples: tuple }
[@@deriving sexp, protocol ~driver:(module Xml_light)]
- type t = relation list [@@deriving sexp, protocol ~driver:(module Xml_light)]
+ type facts = relation list [@@deriving sexp, protocol ~driver:(module Xml_light)]
end
-let write_and_retrieve() =
+let test_write_and_retrieve() =
let open Disk in
let stream: Executor.history = [{state = Executor._EMPTY_SHA_HASH_; files = Executor.StringMap.empty}] in
let locations: Executor.locations = Executor.StringMap.empty in
@@ -45,6 +45,33 @@ let write_and_retrieve() =
let relation_result: Protocol.relation list =
[{attribute_name = "user/first-name"; attribute_type = "string"; tuples = List.map Bytes.to_string first_name};
{attribute_name = "user/last-name"; attribute_type = "string"; tuples = List.map Bytes.to_string last_name}] in
- Ok (Xml.to_string (Protocol.to_xml_light relation_result))
+ Ok (Xml.to_string (Protocol.facts_to_xml_light relation_result))
(* (Sexp.to_string (Protocol.sexp_of_t )) *)
[@@warning "-8"] (* Suppress pattern match incomplete warnings *)
+
+
+let write_and_retrieve() =
+ let open Disk in
+ let stream: Executor.history = [{state = Executor._EMPTY_SHA_HASH_; files = Executor.StringMap.empty}] in
+ let locations: Executor.locations = Executor.StringMap.empty in
+ let open Extensions.Result in
+ let command_write1: Command.t =
+ {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Daisy"; filename = "user/first-name"; references = []} in
+ let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write1 in
+ let command_write2: Command.t =
+ {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Blossom"; filename = "user/last-name"; references = [handle]} in
+ let command_write3: Command.t =
+ {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Minnie"; filename = "user/first-name"; references = []} in
+ let+ ((stream, locations), Command.ComputedHash _handle) = Command.commit_and_perform stream locations command_write2 in
+ let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write3 in
+ let command_write4: Command.t =
+ {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Mouse"; filename = "user/last-name"; references = [handle]} in
+ let+ ((stream, locations), Command.ComputedHash _handle) = Command.commit_and_perform stream locations command_write4 in
+ let command_write5: Command.t =
+ {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Billie"; filename = "user/first-name"; references = []} in
+ let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write5 in
+ let command_write6: Command.t =
+ {kind = Command.WRITE; timestamp = 10.0; hash = ""; content = "Beans"; filename = "user/last-name"; references = [handle]} in
+ let+ ((stream, locations), Command.ComputedHash _handle) = Command.commit_and_perform stream locations command_write6 in
+ Ok (stream, locations)
+ [@@warning "-8"] (* Suppress pattern match incomplete warnings *)