aboutsummaryrefslogtreecommitdiffstats
path: root/lib/backend/managers
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 00:51:11 -0300
committerGitHub <noreply@github.com>2026-07-11 00:51:11 -0300
commitbb3156b8ab78b035ce886bbe3021ec7cbe269d03 (patch)
tree82dd52655d25e49519a035f1245c703e910a2152 /lib/backend/managers
parent85bff2fc22a131cce5ec2b4eb4b3dd8269c247cd (diff)
downloadRNT-bb3156b8ab78b035ce886bbe3021ec7cbe269d03.tar.gz
RNT-bb3156b8ab78b035ce886bbe3021ec7cbe269d03.zip
FOL: First Order Logic Execution Engine
Co-authored-by: Estevan Castilho <tevo@riajuu.net>
Diffstat (limited to '')
-rw-r--r--lib/backend/managers/Cursor.ml18
-rw-r--r--lib/backend/managers/Cursor.mli16
-rw-r--r--lib/backend/managers/Handle.ml51
-rw-r--r--lib/backend/managers/Handle.mli22
4 files changed, 107 insertions, 0 deletions
diff --git a/lib/backend/managers/Cursor.ml b/lib/backend/managers/Cursor.ml
new file mode 100644
index 0000000..3295cae
--- /dev/null
+++ b/lib/backend/managers/Cursor.ml
@@ -0,0 +1,18 @@
+type descriptor =
+ | Stored of {merkle_root: string}
+ | Ephemeral of {merkle_root: string; dependencies: string BatFingerTree.t}
+
+module Make (Store : Abstract.Storage.STORAGE) = struct
+ type cursor = unit
+
+ let open_ (_txn : Store.transaction) (descriptor : descriptor)
+ ~(args : Concepts.Value.value BatFingerTree.t) : (cursor, Concepts.Condition.condition) result
+ =
+ ignore (descriptor, args);
+ failwith "NOT IMPLEMENTED: open a cursor by paging the relation's Merkle tree over Store.get"
+
+ let next (_cursor : cursor) : (Concepts.Tuple.t option, Concepts.Condition.condition) result =
+ failwith "NOT IMPLEMENTED: page the next tuple over Store.get"
+
+ let close (_cursor : cursor) : unit = ()
+end
diff --git a/lib/backend/managers/Cursor.mli b/lib/backend/managers/Cursor.mli
new file mode 100644
index 0000000..71fb15d
--- /dev/null
+++ b/lib/backend/managers/Cursor.mli
@@ -0,0 +1,16 @@
+type descriptor =
+ | Stored of {merkle_root: string}
+ | Ephemeral of {merkle_root: string; dependencies: string BatFingerTree.t}
+
+module Make (Store : Abstract.Storage.STORAGE) : sig
+ type cursor
+
+ val open_ :
+ Store.transaction ->
+ descriptor ->
+ args:Concepts.Value.value BatFingerTree.t ->
+ (cursor, Concepts.Condition.condition) result
+
+ val next : cursor -> (Concepts.Tuple.t option, Concepts.Condition.condition) result
+ val close : cursor -> unit
+end
diff --git a/lib/backend/managers/Handle.ml b/lib/backend/managers/Handle.ml
new file mode 100644
index 0000000..ed2f220
--- /dev/null
+++ b/lib/backend/managers/Handle.ml
@@ -0,0 +1,51 @@
+module type HANDLER = sig
+ type t
+ type handle
+ type cursor
+
+ val open_ : t -> path:Concepts.Path.t -> (handle, Concepts.Condition.condition) result
+
+ val open_cursor :
+ handle ->
+ args:Concepts.Value.value BatFingerTree.t ->
+ (cursor, Concepts.Condition.condition) result
+
+ val next : cursor -> (Concepts.Tuple.t option, Concepts.Condition.condition) result
+ val close : cursor -> unit
+end
+
+let not_a_relation () : Concepts.Condition.condition =
+ Concepts.Condition.condition "not-a-relation"
+ "handle does not refer to a stored or ephemeral relation" Concepts.Condition.empty
+
+module Make (Store : Abstract.Storage.STORAGE) = struct
+ module Cur = Cursor.Make (Store)
+
+ type t = {objects: Object.rnt_object_tree; txn: Store.transaction}
+ type handle = {object_: Object.registry; txn: Store.transaction}
+ type cursor = Cur.cursor
+
+ let create objects txn = {objects; txn}
+
+ let open_ t ~path =
+ let object_ = Object.find path t.objects in
+ Ok {object_; txn= t.txn}
+
+ let relation_descriptor (object_ : Object.registry) :
+ (Cursor.descriptor, Concepts.Condition.condition) result =
+ let {Object.entry; _} = object_ in
+ match entry.Object.kind with
+ | Object.Relation {merkle_root} -> Ok (Cursor.Stored {merkle_root})
+ | Object.EphemeralRelation {merkle_root; dependencies} ->
+ Ok (Cursor.Ephemeral {merkle_root; dependencies})
+ | _ -> Error (not_a_relation ())
+
+ let open_cursor handle ~args =
+ let open Utilities.Result in
+ let* descriptor = relation_descriptor handle.object_ in
+ Cur.open_ handle.txn descriptor ~args
+
+ let next = Cur.next
+ let close = Cur.close
+ let object_ (handle : handle) = handle.object_
+end
diff --git a/lib/backend/managers/Handle.mli b/lib/backend/managers/Handle.mli
new file mode 100644
index 0000000..5fc82b8
--- /dev/null
+++ b/lib/backend/managers/Handle.mli
@@ -0,0 +1,22 @@
+module type HANDLER = sig
+ type t
+ type handle
+ type cursor
+
+ val open_ : t -> path:Concepts.Path.t -> (handle, Concepts.Condition.condition) result
+
+ val open_cursor :
+ handle ->
+ args:Concepts.Value.value BatFingerTree.t ->
+ (cursor, Concepts.Condition.condition) result
+
+ val next : cursor -> (Concepts.Tuple.t option, Concepts.Condition.condition) result
+ val close : cursor -> unit
+end
+
+module Make (Store : Abstract.Storage.STORAGE) : sig
+ include HANDLER
+
+ val create : Object.rnt_object_tree -> Store.transaction -> t
+ val object_ : handle -> Object.registry
+end