aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2021-06-28 15:09:28 +0200
committerpukkamustard <pukkamustard@posteo.net>2021-06-28 15:09:28 +0200
commitb218a2e77f070dacb984f033e5ed27413d7a933c (patch)
treec884909b8ee77f702a1c8f0d5a9e9fb4ea306540
parent1ceecb984c9943c609563aa56d2629580dcc4d8e (diff)
Rdf_fragment_graph: Fix compare and make equality checks much more efficient.
-rw-r--r--lib/fragment_graph/rdf_fragment_graph.ml18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/fragment_graph/rdf_fragment_graph.ml b/lib/fragment_graph/rdf_fragment_graph.ml
index 967c91c..68696b2 100644
--- a/lib/fragment_graph/rdf_fragment_graph.ml
+++ b/lib/fragment_graph/rdf_fragment_graph.ml
@@ -162,8 +162,8 @@ module Make(H: HASH) = struct
match (a, b) with
| FragmentReference a, FragmentReference b -> String.compare a b
| Iri a, Iri b -> Rdf.Iri.compare a b
- | FragmentReference _, _ -> -1
- | Iri _, _ -> 1
+ | FragmentReference _, Iri _ -> -1
+ | Iri _, FragmentReference _ -> 1
let expand ~base_subject = function
| FragmentReference fragment ->
@@ -207,8 +207,10 @@ module Make(H: HASH) = struct
| FragmentReference a, FragmentReference b -> String.compare a b
| Iri a, Iri b -> Rdf.Iri.compare a b
| Literal a, Literal b -> Rdf.Literal.compare a b
- | FragmentReference _, _ -> -1
- | Literal _, _ -> -1
+ | FragmentReference _, Literal _ -> -1
+ | FragmentReference _, Iri _ -> -1
+ | Literal _, FragmentReference _ -> 1
+ | Literal _, Iri _ -> -1
| Iri _, _ -> 1
let expand ~base_subject = function
@@ -506,12 +508,10 @@ module Make(H: HASH) = struct
|> canonical
|> H.hash
-
- (* Order of insertion matters so we use *)
let equal a b =
- Rdf.Iri.equal
- (base_subject a)
- (base_subject b)
+ PredicateMap.equal ObjectSet.equal a.statements b.statements
+ &&
+ FragmentMap.equal (PredicateMap.equal ObjectSet.equal) a.fragment_statements b.fragment_statements
let to_triples fragment_graph =
let base_subject = base_subject fragment_graph in