diff options
| author | Marcos Magueta <mmagueta@MacMini.local> | 2024-12-08 12:05:27 -0300 |
|---|---|---|
| committer | Marcos Magueta <mmagueta@MacMini.local> | 2024-12-08 12:05:27 -0300 |
| commit | f43943346e3c6d347b829bbbaeccae5f49327749 (patch) | |
| tree | e1dc5af28e599c64e74affb0c1bc9f8a0132e68d /lib/planner.ml | |
| parent | 872fc56a414f8c2a4818463be9e104195a0b6242 (diff) | |
| download | Sakura-f43943346e3c6d347b829bbbaeccae5f49327749.tar.gz Sakura-f43943346e3c6d347b829bbbaeccae5f49327749.zip | |
seq scan initial implementation
Diffstat (limited to 'lib/planner.ml')
| -rw-r--r-- | lib/planner.ml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/planner.ml b/lib/planner.ml new file mode 100644 index 0000000..ceaf815 --- /dev/null +++ b/lib/planner.ml @@ -0,0 +1,24 @@ +module Scan = struct + open Disk + let execute commit locations (entity: string) = + Executor.read commit locations ~filename:entity +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 + +module Filter = struct +end |
