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 /lib/disk.ml | |
| parent | 592cc506c055996e99ace34fa4a0767f5ada63b7 (diff) | |
| download | Sakura-998cf183c45e604430b4a80425bd2332fb30cfe1.tar.gz Sakura-998cf183c45e604430b4a80425bd2332fb30cfe1.zip | |
base serialization and command reorganization
Diffstat (limited to 'lib/disk.ml')
| -rw-r--r-- | lib/disk.ml | 20 |
1 files changed, 16 insertions, 4 deletions
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 = |
