diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2025-06-29 01:33:13 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2025-06-29 01:33:13 -0300 |
| commit | 998cf183c45e604430b4a80425bd2332fb30cfe1 (patch) | |
| tree | caa8ffbd2cd14867dbb0b0e875822520b5d202a0 | |
| parent | 592cc506c055996e99ace34fa4a0767f5ada63b7 (diff) | |
| download | Sakura-998cf183c45e604430b4a80425bd2332fb30cfe1.tar.gz Sakura-998cf183c45e604430b4a80425bd2332fb30cfe1.zip | |
base serialization and command reorganization
| -rw-r--r-- | .envrc | 1 | ||||
| -rw-r--r-- | README.org | 3 | ||||
| -rw-r--r-- | client.el | 2 | ||||
| -rw-r--r-- | lib/disk.ml | 20 | ||||
| -rw-r--r-- | lib/protocol.ml | 2 | ||||
| -rw-r--r-- | lib/server.ml | 13 | ||||
| -rw-r--r-- | sources/Geometry64x64.png | bin | 0 -> 1017 bytes |
7 files changed, 33 insertions, 8 deletions
@@ -0,0 +1 @@ +use flake @@ -4,6 +4,9 @@ This is a relational engine. * Roadmap +- [ ] State + - [ ] Add the schema modifications to the commit state hash + - [ ] Save a history of the schema - [ ] Filesystem [0/6] - [ ] Durability - [ ] Immutable storage @@ -8,7 +8,7 @@ (message "Received: %s" response) (delete-process process))) -(setq relational-engine-address "localhost") +(setq relational-engine-address "/tmp/relational_engine.socket") (setq relational-engine-port 7524) (defun relational-client (content) diff --git a/lib/disk.ml b/lib/disk.ml index 8d9d062..6996b2d 100644 --- a/lib/disk.ml +++ b/lib/disk.ml @@ -129,6 +129,8 @@ module Executor = struct (tup2 (list string) string) end + open Sexplib0.Sexp_conv + type relational_type = | Text | Integer32 @@ -137,7 +139,7 @@ module Executor = struct (* | DiscriminatedUnion of (string * relational_type option) list * string *) (* [("MemberA", None); ("MemberB", Some Integer32)], "NameOfDU" *) | Relation of string - [@@deriving show] + [@@deriving show, sexp] type relational_literal = | LText of string @@ -443,7 +445,13 @@ module Command = struct type': Executor.relational_type; } - type t = SequentialRead of { relation_name : string } + open Sexplib0.Sexp_conv + + type t = + | SequentialRead of { relation_name : string } + | SpecifyRelation of { relation_name: string; + attributes: (string*Executor.relational_type) list } + [@@deriving sexp] let command_encoding = conv @@ -526,9 +534,13 @@ module Command = struct | Some _, None -> Error "Cannot write an entity without its referential." | None, _ -> Ok ((commit, locations), Nothing) - let perform (commit : Executor.commit) (locations : Executor.locations) - (command : t) = + let perform (commit : Executor.commit) (locations : Executor.locations) (command : t) = match command with + | SpecifyRelation {relation_name; attributes} -> + (* If it already exists under the relation name key, it will be replaced *) + Ok (({ commit with + schema = commit.schema + |> Executor.StringMap.add relation_name attributes}, locations), Nothing) | SequentialRead { relation_name } -> let relation_name = List.hd @@ String.split_on_char '/' relation_name in let entities : (string * Executor.relational_type * string) list Executor.IntMap.t = diff --git a/lib/protocol.ml b/lib/protocol.ml index 79ed8d0..5fe29d1 100644 --- a/lib/protocol.ml +++ b/lib/protocol.ml @@ -3,6 +3,8 @@ open Sexplib0.Sexp_conv type tuple = string list [@@deriving sexp, protocol ~driver:(module Xml_light)] +type command = Disk.Command.t [@@deriving sexp] + type relation = { attribute_name : string; attribute_type : string; diff --git a/lib/server.ml b/lib/server.ml index 4a99b29..4af94fb 100644 --- a/lib/server.ml +++ b/lib/server.ml @@ -25,9 +25,16 @@ let client_read sock maxlen = let acc = acc ^ Bytes.to_string (Bytes.sub str 0 recvlen) in if recvlen <= maxlen then Lwt.return acc else _read sock acc in - _read sock String.empty >>= fun _ -> - match Relation.write_and_retrieve () with - | Ok (last_commit, locations) -> + _read sock String.empty >>= fun x -> + print_string "RECEIVED: "; + print_endline x; + let command = Protocol.command_of_sexp (Sexplib0.Sexp_conv.sexp_of_string x) in + match + (* Relation.write_and_retrieve () *) + command + with + | Disk.Command.SequentialRead {relation} + (* | Ok (last_commit, locations) -> *) (* let (first_names, last_names) = (Planner.Scan.execute last_commit locations "user/first-name", Planner.Scan.execute last_commit locations "user/last-name") in *) (* let tuples = Planner.Join.execute first_names last_names locations in *) let fname, lname = List.split [] in diff --git a/sources/Geometry64x64.png b/sources/Geometry64x64.png Binary files differnew file mode 100644 index 0000000..d256e49 --- /dev/null +++ b/sources/Geometry64x64.png |
