Several performance improvements
This commit is contained in:
parent
f03a608526
commit
768bc9ae09
6 changed files with 19 additions and 7 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -5,6 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
|
||||||
[Keep a CHANGELOG](http://keepachangelog.com).
|
[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
|
## 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)
|
This version introduces a new graph builder DSL. See the [new guide](https://rdf-elixir.dev/rdf-ex/description-and-graph-dsl.html)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.12.0
|
0.12.1-pre
|
||||||
|
|
|
@ -382,7 +382,8 @@ defimpl RDF.Data, for: RDF.Dataset do
|
||||||
def objects(dataset), do: Dataset.objects(dataset)
|
def objects(dataset), do: Dataset.objects(dataset)
|
||||||
def resources(dataset), do: Dataset.resources(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 statement_count(dataset), do: Dataset.statement_count(dataset)
|
||||||
def values(dataset, opts \\ []), do: Dataset.values(dataset, opts)
|
def values(dataset, opts \\ []), do: Dataset.values(dataset, opts)
|
||||||
def map(dataset, fun), do: Dataset.map(dataset, fun)
|
def map(dataset, fun), do: Dataset.map(dataset, fun)
|
||||||
|
|
|
@ -528,7 +528,7 @@ defmodule RDF.Dataset do
|
||||||
"""
|
"""
|
||||||
@spec graph_count(t) :: non_neg_integer
|
@spec graph_count(t) :: non_neg_integer
|
||||||
def graph_count(%__MODULE__{} = dataset) do
|
def graph_count(%__MODULE__{} = dataset) do
|
||||||
Enum.count(dataset.graphs)
|
map_size(dataset.graphs)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -488,7 +488,7 @@ defmodule RDF.Description do
|
||||||
[{object, _}] = Enum.take(objects, 1)
|
[{object, _}] = Enum.take(objects, 1)
|
||||||
|
|
||||||
popped =
|
popped =
|
||||||
if Enum.count(objects) == 1,
|
if map_size(objects) == 1,
|
||||||
do: elem(Map.pop(predications, predicate), 1),
|
do: elem(Map.pop(predications, predicate), 1),
|
||||||
else: elem(pop_in(predications, [predicate, object]), 1)
|
else: elem(pop_in(predications, [predicate, object]), 1)
|
||||||
|
|
||||||
|
@ -633,7 +633,7 @@ defmodule RDF.Description do
|
||||||
@spec statement_count(t) :: non_neg_integer
|
@spec statement_count(t) :: non_neg_integer
|
||||||
def statement_count(%__MODULE__{} = description) do
|
def statement_count(%__MODULE__{} = description) do
|
||||||
Enum.reduce(description.predications, 0, fn {_, objects}, count ->
|
Enum.reduce(description.predications, 0, fn {_, objects}, count ->
|
||||||
count + Enum.count(objects)
|
count + map_size(objects)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -830,7 +830,7 @@ defmodule RDF.Description do
|
||||||
| predications:
|
| predications:
|
||||||
Enum.reduce(description.predications, description.predications, fn
|
Enum.reduce(description.predications, description.predications, fn
|
||||||
{predicate, objects}, predications ->
|
{predicate, objects}, predications ->
|
||||||
original_object_count = Enum.count(predications)
|
original_object_count = map_size(predications)
|
||||||
|
|
||||||
filtered_objects =
|
filtered_objects =
|
||||||
Enum.reject(objects, &match?({quoted_triple, _} when is_tuple(quoted_triple), &1))
|
Enum.reject(objects, &match?({quoted_triple, _} when is_tuple(quoted_triple), &1))
|
||||||
|
|
|
@ -819,7 +819,7 @@ defmodule RDF.Graph do
|
||||||
"""
|
"""
|
||||||
@spec subject_count(t) :: non_neg_integer
|
@spec subject_count(t) :: non_neg_integer
|
||||||
def subject_count(%__MODULE__{} = graph) do
|
def subject_count(%__MODULE__{} = graph) do
|
||||||
Enum.count(graph.descriptions)
|
map_size(graph.descriptions)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
Loading…
Reference in a new issue