diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a3f6df..6f2e956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com). +## Unreleased + +### Changed + +- several performance improvements + + +[Compare v0.12.0...HEAD](https://github.com/rdf-elixir/rdf-ex/compare/v0.12.0...HEAD) + + + ## 0.12.0 - 2022-04-11 This version introduces a new graph builder DSL. See the [new guide](https://rdf-elixir.dev/rdf-ex/description-and-graph-dsl.html) diff --git a/VERSION b/VERSION index ac454c6..a5c379e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.12.0 +0.12.1-pre diff --git a/lib/rdf/data.ex b/lib/rdf/data.ex index 811f330..c9f21ad 100644 --- a/lib/rdf/data.ex +++ b/lib/rdf/data.ex @@ -382,7 +382,8 @@ defimpl RDF.Data, for: RDF.Dataset do def objects(dataset), do: Dataset.objects(dataset) def resources(dataset), do: Dataset.resources(dataset) - def subject_count(dataset), do: dataset |> subjects |> Enum.count() + def subject_count(dataset), do: dataset |> subjects() |> MapSet.size() + def statement_count(dataset), do: Dataset.statement_count(dataset) def values(dataset, opts \\ []), do: Dataset.values(dataset, opts) def map(dataset, fun), do: Dataset.map(dataset, fun) diff --git a/lib/rdf/dataset.ex b/lib/rdf/dataset.ex index db4ccf8..c820e71 100644 --- a/lib/rdf/dataset.ex +++ b/lib/rdf/dataset.ex @@ -528,7 +528,7 @@ defmodule RDF.Dataset do """ @spec graph_count(t) :: non_neg_integer def graph_count(%__MODULE__{} = dataset) do - Enum.count(dataset.graphs) + map_size(dataset.graphs) end @doc """ diff --git a/lib/rdf/description.ex b/lib/rdf/description.ex index bc5959e..a7fe708 100644 --- a/lib/rdf/description.ex +++ b/lib/rdf/description.ex @@ -488,7 +488,7 @@ defmodule RDF.Description do [{object, _}] = Enum.take(objects, 1) popped = - if Enum.count(objects) == 1, + if map_size(objects) == 1, do: elem(Map.pop(predications, predicate), 1), else: elem(pop_in(predications, [predicate, object]), 1) @@ -633,7 +633,7 @@ defmodule RDF.Description do @spec statement_count(t) :: non_neg_integer def statement_count(%__MODULE__{} = description) do Enum.reduce(description.predications, 0, fn {_, objects}, count -> - count + Enum.count(objects) + count + map_size(objects) end) end @@ -830,7 +830,7 @@ defmodule RDF.Description do | predications: Enum.reduce(description.predications, description.predications, fn {predicate, objects}, predications -> - original_object_count = Enum.count(predications) + original_object_count = map_size(predications) filtered_objects = Enum.reject(objects, &match?({quoted_triple, _} when is_tuple(quoted_triple), &1)) diff --git a/lib/rdf/graph.ex b/lib/rdf/graph.ex index a88792c..6922382 100644 --- a/lib/rdf/graph.ex +++ b/lib/rdf/graph.ex @@ -819,7 +819,7 @@ defmodule RDF.Graph do """ @spec subject_count(t) :: non_neg_integer def subject_count(%__MODULE__{} = graph) do - Enum.count(graph.descriptions) + map_size(graph.descriptions) end @doc """