aboutsummaryrefslogtreecommitdiffstats
path: root/lib/planner.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2025-01-19 21:50:01 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2025-01-19 21:50:01 -0300
commit919b7f1a81982533ff4ab33730c68313690c2b77 (patch)
tree81ca1f9779a8af22d505cbc34fe2cba5a3c9c72b /lib/planner.ml
parentfbb9318eede78561970676c9d98d82e3851aeae5 (diff)
downloadSakura-919b7f1a81982533ff4ab33730c68313690c2b77.tar.gz
Sakura-919b7f1a81982533ff4ab33730c68313690c2b77.zip
cleanup and format
Diffstat (limited to 'lib/planner.ml')
-rw-r--r--lib/planner.ml50
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/planner.ml b/lib/planner.ml
index f0fbc59..1d4d830 100644
--- a/lib/planner.ml
+++ b/lib/planner.ml
@@ -1,33 +1,33 @@
module Scan = struct
(* open Disk
- let execute commit locations (entity: string) =
- let binary = Executor.read commit locations ~filename:("schema~" ^ entity) in
- let relation =
- Result.map_error (fun _ -> "Failed to deserialize relation from binary format.")
- @@ Data_encoding.Binary.of_bytes Schema.Protocol.relation_encoding (Bytes.concat Bytes.empty binary) in
- match relation with
- | Ok relation ->
- begin
- let attrs = List.map (fun (a: Schema.Protocol.attribute) -> relation.name ^ "/" ^ a.name) relation.attributes in
- Executor.read commit locations ~filename:("schema~" ^ entity)
- end
- | Error err -> failwith err *)
+ let execute commit locations (entity: string) =
+ let binary = Executor.read commit locations ~filename:("schema~" ^ entity) in
+ let relation =
+ Result.map_error (fun _ -> "Failed to deserialize relation from binary format.")
+ @@ Data_encoding.Binary.of_bytes Schema.Protocol.relation_encoding (Bytes.concat Bytes.empty binary) in
+ match relation with
+ | Ok relation ->
+ begin
+ let attrs = List.map (fun (a: Schema.Protocol.attribute) -> relation.name ^ "/" ^ a.name) relation.attributes in
+ Executor.read commit locations ~filename:("schema~" ^ entity)
+ end
+ | Error err -> failwith err *)
end
module Join = struct
(* open Disk
- let execute (left_attributes: bytes list) (right_attributes: bytes list) locations =
- (* Redundant operations that are already in the locations, but this is easier to implement now *)
- (* Fix this when we persist the indexes *)
- let left_computed_hashes: (int * string) list = List.mapi (fun index elem -> (index, Interop.Sha256.compute_hash elem)) left_attributes in
- let right_computed_hashes: (int * string) list = List.mapi (fun index elem -> (index, Interop.Sha256.compute_hash elem)) right_attributes in
- let references_locations_right = List.filter_map (fun (index, rhash) -> Option.map (fun (elem: Executor.Location.t) -> index, rhash, elem.references)
- @@ Executor.StringMap.find_opt rhash locations) right_computed_hashes in
- let indexes =
- List.filter_map (fun (lindex, lhash) -> Option.map (fun (rindex, rhash, _) -> lindex, rindex, lhash, rhash)
- @@ List.find_opt (fun (_rindex, _rhash, references) -> List.exists ((=) lhash) references) references_locations_right) left_computed_hashes
- in List.map (fun (lindex, rindex, _, _) -> List.nth left_attributes lindex, List.nth right_attributes rindex) indexes *)
-end
+ let execute (left_attributes: bytes list) (right_attributes: bytes list) locations =
+ (* Redundant operations that are already in the locations, but this is easier to implement now *)
+ (* Fix this when we persist the indexes *)
+ let left_computed_hashes: (int * string) list = List.mapi (fun index elem -> (index, Interop.Sha256.compute_hash elem)) left_attributes in
+ let right_computed_hashes: (int * string) list = List.mapi (fun index elem -> (index, Interop.Sha256.compute_hash elem)) right_attributes in
+ let references_locations_right = List.filter_map (fun (index, rhash) -> Option.map (fun (elem: Executor.Location.t) -> index, rhash, elem.references)
+ @@ Executor.StringMap.find_opt rhash locations) right_computed_hashes in
+ let indexes =
+ List.filter_map (fun (lindex, lhash) -> Option.map (fun (rindex, rhash, _) -> lindex, rindex, lhash, rhash)
+ @@ List.find_opt (fun (_rindex, _rhash, references) -> List.exists ((=) lhash) references) references_locations_right) left_computed_hashes
+ in List.map (fun (lindex, rindex, _, _) -> List.nth left_attributes lindex, List.nth right_attributes rindex) indexes *)
-module Filter = struct
end
+
+module Filter = struct end