aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2024-12-08 15:00:31 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2024-12-08 15:00:31 -0300
commitc67ed574a7a95db73d9349d58727452850bd47b9 (patch)
tree8bc1c0e98b72ead8bf0ba71fe0ffeccbff7c9fd5 /lib
parent75f1ff70f92b9b7e7c72580ce210b5c7622918bf (diff)
downloadSakura-c67ed574a7a95db73d9349d58727452850bd47b9.tar.gz
Sakura-c67ed574a7a95db73d9349d58727452850bd47b9.zip
planner seq scan assuming ordering of results
Diffstat (limited to 'lib')
-rw-r--r--lib/planner.ml12
-rw-r--r--lib/schema.ml4
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/planner.ml b/lib/planner.ml
index ceaf815..b88090d 100644
--- a/lib/planner.ml
+++ b/lib/planner.ml
@@ -1,7 +1,17 @@
module Scan = struct
open Disk
let execute commit locations (entity: string) =
- Executor.read commit locations ~filename:entity
+ 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
diff --git a/lib/schema.ml b/lib/schema.ml
index 74ce720..81632b4 100644
--- a/lib/schema.ml
+++ b/lib/schema.ml
@@ -38,7 +38,7 @@ let test_schema_write_and_retrieve() =
let locations: Executor.locations = Executor.StringMap.empty in
let open Extensions.Result in
let+ user_relation =
- let relation: Protocol.relation = { name = "user"; attributes = [{name = "first-name"; attr_type = "string"}; {name = "last-name"; attr_type = "string"}] } in
+ let relation: Protocol.relation = { name = "schema~user"; attributes = [{name = "first-name"; attr_type = "string"}; {name = "last-name"; attr_type = "string"}] } in
Result.map_error (fun _ -> "Failed to serialize relation to binary format.")
@@ Binary.to_bytes Protocol.relation_encoding relation
in
@@ -46,7 +46,7 @@ let test_schema_write_and_retrieve() =
{kind = Command.WRITE; timestamp = 10.0; hash = ""; content = Bytes.to_string user_relation; filename = "user"; references = []} in
let+ ((stream, locations), Command.ComputedHash handle) = Command.commit_and_perform stream locations command_write in
let command_read: Command.t =
- {kind = Command.READ; timestamp = 10.0; hash = handle; content = ""; filename = "user"; references = []} in
+ {kind = Command.READ; timestamp = 10.0; hash = handle; content = ""; filename = "schema~user"; references = []} in
let+ ((stream, locations), Command.Read content) = Command.commit_and_perform stream locations command_read in
let+ user_relation =
Result.map_error (fun _ -> "Failed to deserialize relation from binary format.")